| | |
| | | import oshi.driver.mac.net.NetStat; |
| | | |
| | | import javax.annotation.Resource; |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import java.math.BigDecimal; |
| | | import java.time.LocalDate; |
| | | import java.util.*; |
| | |
| | | |
| | | @ApiOperation(value = "定制推荐-2政策3公示",tags = {"web-首页"}) |
| | | @PostMapping(value = "/consultation/list") |
| | | public R<List<TConsultation>> consultationlist(@RequestParam Integer type,@RequestParam(required = false) Integer regionId) { |
| | | public R<List<TConsultation>> consultationlist(@RequestParam Integer type, @RequestParam(required = false) Integer regionId, HttpServletRequest request) { |
| | | String token = request.getHeader("Authorization"); |
| | | TUserChange one =null; |
| | | if(StringUtils.isNotEmpty(token)){ |
| | | //获取当前登录人id |
| | | Long userId = tokenService.getLoginUser().getUserId(); |
| | | TUserChange one = changeService.lambdaQuery().eq(TUserChange::getUserId, userId).orderByDesc(TUserChange::getCreateTime).last("limit 1").one(); |
| | | one = changeService.lambdaQuery().eq(TUserChange::getUserId, userId).orderByDesc(TUserChange::getCreateTime).last("limit 1").one(); |
| | | } |
| | | List<TConsultation> notices = new ArrayList<>(); |
| | | |
| | | if (type==1){ |
| | |
| | | .eq(TConsultation::getRegionId,tUserChangeDetail.getRegionId()) |
| | | .eq(TConsultation::getMajorId, tUserChangeDetail.getMajorId()) |
| | | .eq(TConsultation::getLevel, tUserChangeDetail.getLevelId()) |
| | | .eq(TConsultation::getIsRecommend,1) |
| | | .orderByDesc(TConsultation::getClassificationSort,TConsultation::getCreateTime).list(); |
| | | notices.addAll(list1); |
| | | } |
| | |
| | | List<Integer> regionIds = regions.stream().map(TRegion::getId).collect(Collectors.toList()); |
| | | List<TConsultation> list1 = consultationService.lambdaQuery().eq(TConsultation::getClassificationId,type) |
| | | .in(TConsultation::getRegionId,regionIds) |
| | | .eq(TConsultation::getIsRecommend,1) |
| | | .orderByDesc(TConsultation::getCreateTime,TConsultation::getClassificationSort).list(); |
| | | notices.addAll(list1); |
| | | notices.sort(Comparator.comparing(TConsultation::getCreateTime).reversed()); |
| | | } |
| | | List<TConsultation> list1 = consultationService.lambdaQuery().eq(TConsultation::getClassificationId,type).eq(TConsultation::getIsRecommend,1).last("ORDER BY RAND() LIMIT 16").list(); |
| | | notices.addAll(list1); |
| | | if (notices.size() > 16) { |
| | | // List<TConsultation> list1 = consultationService.lambdaQuery().eq(TConsultation::getClassificationId,type).eq(TConsultation::getIsRecommend,1).last("ORDER BY RAND() LIMIT 16").list(); |
| | | // notices.addAll(list1); |
| | | if (notices.size() > 2) { |
| | | // 只保留前 16 条记录 |
| | | notices = new ArrayList<>(notices.subList(0, 16)); |
| | | notices = new ArrayList<>(notices.subList(0, 2)); |
| | | } |
| | | }else { |
| | | if (one!=null){ |
| | |
| | | notices.addAll(list1); |
| | | notices.sort(Comparator.comparing(TConsultation::getCreateTime).reversed()); |
| | | } |
| | | List<TConsultation> list1 = consultationService.lambdaQuery().eq(TConsultation::getClassificationId,type).last("ORDER BY RAND() LIMIT 16").list(); |
| | | notices.addAll(list1); |
| | | if (notices.size() > 16) { |
| | | // List<TConsultation> list1 = consultationService.lambdaQuery().eq(TConsultation::getClassificationId,type).last("ORDER BY RAND() LIMIT 16").list(); |
| | | // notices.addAll(list1); |
| | | if (notices.size() > 2) { |
| | | // 只保留前 16 条记录 |
| | | notices = new ArrayList<>(notices.subList(0, 16)); |
| | | notices = new ArrayList<>(notices.subList(0, 2)); |
| | | } |
| | | } |
| | | return R.ok(notices); |