| | |
| | | import javax.annotation.Resource; |
| | | import java.math.BigDecimal; |
| | | import java.time.LocalDateTime; |
| | | import java.util.ArrayList; |
| | | import java.util.Arrays; |
| | | import java.util.List; |
| | | import java.util.Set; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | public R<Page<TInformation>> list(@RequestBody InformationQuery informationQuery) { |
| | | Long userId = tokenService.getLoginUser().getUserId(); |
| | | Page<TInformation> page; |
| | | if (informationQuery.getSortType()==1){ |
| | | page = informationService.lambdaQuery() |
| | | .like(!StringUtils.isEmpty(informationQuery.getInformationName()), TInformation::getInformationName, informationQuery.getInformationName()) |
| | | .eq(informationQuery.getRegionId() != null, TInformation::getRegionId, informationQuery.getRegionId()) |
| | | .eq(informationQuery.getTechnicalId() != null, TInformation::getTechnicalId, informationQuery.getTechnicalId()) |
| | | .eq(informationQuery.getMajorId() != null, TInformation::getMajorId, informationQuery.getMajorId()) |
| | | .eq(informationQuery.getLevel() != null, TInformation::getLevel, informationQuery.getLevel()) |
| | | .eq(informationQuery.getFree()!=null&&informationQuery.getFree() == 1, TInformation::getInformationPrice, BigDecimal.ZERO) |
| | | .ne(informationQuery.getFree()!=null&&informationQuery.getFree() == 2, TInformation::getInformationPrice, BigDecimal.ZERO) |
| | | .orderByDesc(TInformation::getCreateTime) |
| | | .page(Page.of(informationQuery.getPageNum(), informationQuery.getPageSize())); |
| | | if(StringUtils.isEmpty(informationQuery.getProvinceName())){ |
| | | if (informationQuery.getSortType()==1){ |
| | | page = informationService.lambdaQuery() |
| | | .like(!StringUtils.isEmpty(informationQuery.getInformationName()), TInformation::getInformationName, informationQuery.getInformationName()) |
| | | .eq(informationQuery.getRegionId() != null, TInformation::getRegionId, informationQuery.getRegionId()) |
| | | .eq(informationQuery.getTechnicalId() != null, TInformation::getTechnicalId, informationQuery.getTechnicalId()) |
| | | .eq(informationQuery.getMajorId() != null, TInformation::getMajorId, informationQuery.getMajorId()) |
| | | .eq(informationQuery.getLevel() != null, TInformation::getLevel, informationQuery.getLevel()) |
| | | .eq(informationQuery.getFree()!=null&&informationQuery.getFree() == 1, TInformation::getInformationPrice, BigDecimal.ZERO) |
| | | .ne(informationQuery.getFree()!=null&&informationQuery.getFree() == 2, TInformation::getInformationPrice, BigDecimal.ZERO) |
| | | .orderByDesc(TInformation::getCreateTime) |
| | | .page(Page.of(informationQuery.getPageNum(), informationQuery.getPageSize())); |
| | | }else { |
| | | page = informationService.lambdaQuery() |
| | | .like(!StringUtils.isEmpty(informationQuery.getInformationName()), TInformation::getInformationName, informationQuery.getInformationName()) |
| | | .eq(informationQuery.getRegionId() != null, TInformation::getRegionId, informationQuery.getRegionId()) |
| | | .eq(informationQuery.getTechnicalId() != null, TInformation::getTechnicalId, informationQuery.getTechnicalId()) |
| | | .eq(informationQuery.getMajorId() != null, TInformation::getMajorId, informationQuery.getMajorId()) |
| | | .eq(informationQuery.getLevel() != null, TInformation::getLevel, informationQuery.getLevel()) |
| | | .eq(informationQuery.getFree()!=null&&informationQuery.getFree() == 1, TInformation::getInformationPrice, BigDecimal.ZERO) |
| | | .ne(informationQuery.getFree()!=null&&informationQuery.getFree() == 2, TInformation::getInformationPrice, BigDecimal.ZERO) |
| | | .orderByDesc(TInformation::getCommitteeSort) |
| | | .page(Page.of(informationQuery.getPageNum(), informationQuery.getPageSize())); |
| | | } |
| | | }else { |
| | | page = informationService.lambdaQuery() |
| | | .like(!StringUtils.isEmpty(informationQuery.getInformationName()), TInformation::getInformationName, informationQuery.getInformationName()) |
| | | .eq(informationQuery.getRegionId() != null, TInformation::getRegionId, informationQuery.getRegionId()) |
| | | .eq(informationQuery.getTechnicalId() != null, TInformation::getTechnicalId, informationQuery.getTechnicalId()) |
| | | .eq(informationQuery.getMajorId() != null, TInformation::getMajorId, informationQuery.getMajorId()) |
| | | .eq(informationQuery.getLevel() != null, TInformation::getLevel, informationQuery.getLevel()) |
| | | .eq(informationQuery.getFree()!=null&&informationQuery.getFree() == 1, TInformation::getInformationPrice, BigDecimal.ZERO) |
| | | .ne(informationQuery.getFree()!=null&&informationQuery.getFree() == 2, TInformation::getInformationPrice, BigDecimal.ZERO) |
| | | .orderByDesc(TInformation::getCommitteeSort) |
| | | .page(Page.of(informationQuery.getPageNum(), informationQuery.getPageSize())); |
| | | List<TRegion> list; |
| | | // 查询省份下的市 |
| | | if(informationQuery.getProvinceName().equals("直辖市")){ |
| | | List<String> cityList = new ArrayList<>(); |
| | | cityList.add("北京市"); |
| | | cityList.add("天津市"); |
| | | cityList.add("重庆市"); |
| | | cityList.add("上海市"); |
| | | list = regionService.lambdaQuery().in(TRegion::getProvinceName, cityList).list(); |
| | | }else { |
| | | list = regionService.lambdaQuery().eq(TRegion::getProvinceName, informationQuery.getProvinceName()).list(); |
| | | } |
| | | List<Integer> ids = list.stream().map(TRegion::getId).collect(Collectors.toList()); |
| | | if (informationQuery.getSortType()==1){ |
| | | page = informationService.lambdaQuery() |
| | | .like(!StringUtils.isEmpty(informationQuery.getInformationName()), TInformation::getInformationName, informationQuery.getInformationName()) |
| | | .in( TInformation::getRegionId, ids) |
| | | .eq(informationQuery.getTechnicalId() != null, TInformation::getTechnicalId, informationQuery.getTechnicalId()) |
| | | .eq(informationQuery.getMajorId() != null, TInformation::getMajorId, informationQuery.getMajorId()) |
| | | .eq(informationQuery.getLevel() != null, TInformation::getLevel, informationQuery.getLevel()) |
| | | .eq(informationQuery.getFree()!=null&&informationQuery.getFree() == 1, TInformation::getInformationPrice, BigDecimal.ZERO) |
| | | .ne(informationQuery.getFree()!=null&&informationQuery.getFree() == 2, TInformation::getInformationPrice, BigDecimal.ZERO) |
| | | .orderByDesc(TInformation::getCreateTime) |
| | | .page(Page.of(informationQuery.getPageNum(), informationQuery.getPageSize())); |
| | | }else { |
| | | page = informationService.lambdaQuery() |
| | | .like(!StringUtils.isEmpty(informationQuery.getInformationName()), TInformation::getInformationName, informationQuery.getInformationName()) |
| | | .in( TInformation::getRegionId, ids) |
| | | .eq(informationQuery.getTechnicalId() != null, TInformation::getTechnicalId, informationQuery.getTechnicalId()) |
| | | .eq(informationQuery.getMajorId() != null, TInformation::getMajorId, informationQuery.getMajorId()) |
| | | .eq(informationQuery.getLevel() != null, TInformation::getLevel, informationQuery.getLevel()) |
| | | .eq(informationQuery.getFree()!=null&&informationQuery.getFree() == 1, TInformation::getInformationPrice, BigDecimal.ZERO) |
| | | .ne(informationQuery.getFree()!=null&&informationQuery.getFree() == 2, TInformation::getInformationPrice, BigDecimal.ZERO) |
| | | .orderByDesc(TInformation::getCommitteeSort) |
| | | .page(Page.of(informationQuery.getPageNum(), informationQuery.getPageSize())); |
| | | } |
| | | } |
| | | |
| | | Set<Long> cacheSet = redisCache.getCacheSet("INFORMATION:" + userId); |
| | | |
| | | for (TInformation record : page.getRecords()) { |