/** * 根据三个条件插查询 * @param nameFilter * @param loginNameFilter * @param tellFilter * @param pageSize * @param pageIndex * @param sortOrder * @param sortType * @return */ @Override public Result findByFilterSelete(String nameFilter, String loginNameFilter, String tellFilter, int pageSize, int pageIndex, String sortOrder, String sortType) { //判断排序是倒叙还是正序 Pageable pageable = null; if(SORTORDER.equals(sortOrder)){ pageable = PageRequest.of(pageIndex-1, pageSize, new Sort(Direction.DESC , sortType)); }else{ pageable = PageRequest.of(pageIndex-1, pageSize, new Sort(Direction.ASC , sortType)); } //判断排序的条件是否为空 if(sortType==null || sortType.isEmpty()){ sortType = "createDate"; } Page<SubaccountBean> subs = null ; if(nameFilter==null && loginNameFilter==null && tellFilter==null){ subs = subaccountRepository.findAll(pageable); }else{ subs= subaccountRepository.findByUserNameLikeAndLoginNameLikeAndTellLike(nameFilter , loginNameFilter , tellFilter , pageable); } SubaccountVo[] subVos = new SubaccountVo[subs.getNumberOfElements()]; //判断查询的数据是否为空,如果是空则对象为null if(subs.getNumberOfElements()==0){ subVos = null; }else{ for (int i = 0; i < subs.getNumberOfElements(); i++) { subVos[i] = new SubaccountVo(); BeanUtils.copyProperties(subs.getContent().get(i), subVos[i]); subVos[i].setFounder(tenantFeign.getTenant(subs.getContent().get(i).getFounder())); } } PageBean pageBean = new PageBean(pageSize, pageIndex, subs.getTotalElements(), subVos); Result result = new Result(); result.setCode("200"); result.setData(pageBean); return result; }