| | |
| | | import com.bstek.dorado.data.provider.Page; |
| | | import com.fzzy.igds.domain.DicArea; |
| | | import com.fzzy.igds.service.DicAreaService; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.data.domain.PageRequest; |
| | | import org.springframework.data.domain.Pageable; |
| | | import org.springframework.data.domain.Sort; |
| | | import org.springframework.data.jpa.domain.Specification; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import javax.annotation.Resource; |
| | | import javax.persistence.criteria.CriteriaBuilder; |
| | | import javax.persistence.criteria.CriteriaQuery; |
| | | import javax.persistence.criteria.Predicate; |
| | | import javax.persistence.criteria.Root; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | |
| | | /** |
| | |
| | | */ |
| | | @DataProvider |
| | | public void pageList(Page<DicArea> page, String key) { |
| | | //多参数分页查询 |
| | | Pageable pageable = PageRequest.of(page.getPageNo() - 1, page.getPageSize(), Sort.Direction.ASC, DicArea.SORT_PROP); |
| | | |
| | | if (StringUtils.isEmpty(key)) { |
| | | org.springframework.data.domain.Page<DicArea> japPage = dicAreaService.findAll(pageable); |
| | | page.setEntityCount((int) japPage.getTotalElements()); |
| | | page.setEntities(japPage.getContent()); |
| | | com.baomidou.mybatisplus.extension.plugins.pagination.Page<DicArea> corePage = new com.baomidou.mybatisplus.extension.plugins.pagination.Page<>(page.getPageNo(), page.getPageSize()); |
| | | |
| | | return; |
| | | } |
| | | Specification<DicArea> specification = new Specification<DicArea>() { |
| | | private static final long serialVersionUID = 1L; |
| | | dicAreaService.listPageData(corePage, key); |
| | | |
| | | public Predicate toPredicate(Root<DicArea> root, CriteriaQuery<?> query, CriteriaBuilder cb) { |
| | | List<Predicate> predicates = new ArrayList<Predicate>(); //所有的断言 |
| | | |
| | | Predicate predicate1 = cb.like(root.get("name"), "%" + key + "%"); |
| | | predicates.add(predicate1); |
| | | |
| | | return cb.and(predicates.toArray(new Predicate[0])); |
| | | } |
| | | }; |
| | | org.springframework.data.domain.Page<DicArea> japPage = dicAreaService.findAll(specification, pageable); |
| | | page.setEntityCount((int) japPage.getTotalElements()); |
| | | page.setEntities(japPage.getContent()); |
| | | // 重新封装 |
| | | page.setEntities(corePage.getRecords()); |
| | | page.setEntityCount(Integer.parseInt(String.valueOf(corePage.getTotal()))); |
| | | } |
| | | |
| | | /** |
| | |
| | | */ |
| | | @DataProvider |
| | | public List<DicArea> getDicAreaByParentCode(String parentCode) { |
| | | return dicAreaService.getDicAreaByParentCode(parentCode); |
| | | return dicAreaService.listData(parentCode, null, null); |
| | | } |
| | | |
| | | /** |