diff --git a/src/main/java/com/peanut/modules/common/controller/TaihuTalentController.java b/src/main/java/com/peanut/modules/common/controller/TaihuTalentController.java index df524394..0a494d07 100644 --- a/src/main/java/com/peanut/modules/common/controller/TaihuTalentController.java +++ b/src/main/java/com/peanut/modules/common/controller/TaihuTalentController.java @@ -4,7 +4,9 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.peanut.common.utils.R; import com.peanut.modules.common.entity.TaihuTalent; import com.peanut.modules.common.entity.UserCertificate; +import com.peanut.modules.common.entity.UserCertificateLabel; import com.peanut.modules.common.service.TaihuTalentService; +import com.peanut.modules.common.service.UserCertificateLabelService; import com.peanut.modules.common.service.UserCertificateService; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang.StringUtils; @@ -24,6 +26,8 @@ public class TaihuTalentController { private TaihuTalentService taihuTalentService; @Autowired private UserCertificateService userCertificateService; + @Autowired + private UserCertificateLabelService userCertificateLabelService; //太湖英才列表 @RequestMapping("/getTaihuTalents") @@ -38,41 +42,63 @@ public class TaihuTalentController { @RequestMapping("/taihuTalentInfo") public R taihuTalentInfo(@RequestBody Map params){ TaihuTalent taihuTalent = taihuTalentService.getById(params.get("id").toString()); - List certificates = userCertificateService.list(new LambdaQueryWrapper() - .eq(UserCertificate::getUserId,taihuTalent.getUserId())); - List res = new ArrayList<>(); - Set label = new HashSet<>(); + List labels = userCertificateLabelService.list(new LambdaQueryWrapper() + .eq(UserCertificateLabel::getPid,0)); + List filterLabels = new ArrayList<>(); + for (UserCertificateLabel label : labels){ + List us = new ArrayList<>(); + getUserCertificates(us,label,taihuTalent.getUserId()); + label.setUserCertificates(us); + if (us.size() > 0){ + filterLabels.add(label); + } + } + List res = new ArrayList<>(); + Set titleLabel = new HashSet<>(); //出师证、太湖国际中医师证、太湖国际针灸师证排在前面 - for (UserCertificate uc:certificates) { - if (uc.getLabelId()==22){ - res.add(uc); - label.add("出师证"); + for (UserCertificateLabel label:filterLabels) { + if (label.getId()==22){ + res.add(label); + titleLabel.add("出师证"); } } - for (UserCertificate uc:certificates) { - if (uc.getLabelId()==13){ - res.add(uc); - label.add("太湖国际中医师"); + for (UserCertificateLabel label:filterLabels) { + if (label.getId()==13){ + res.add(label); + titleLabel.add("太湖国际中医师"); } } - for (UserCertificate uc:certificates) { - if (uc.getLabelId()==19){ - res.add(uc); - label.add("太湖国际针灸师"); + for (UserCertificateLabel label:filterLabels) { + if (label.getId()==19){ + res.add(label); + titleLabel.add("太湖国际针灸师"); } } - for (UserCertificate uc:certificates) { - if (uc.getLabelId()!=22&&uc.getLabelId()!=13&&uc.getLabelId()!=19){ - res.add(uc); + for (UserCertificateLabel label:filterLabels) { + if (label.getId()!=22&&label.getId()!=13&&label.getId()!=19){ + res.add(label); } } return R.ok() .put("taihuTalent",taihuTalent) - .put("label",label) + .put("label",titleLabel) .put("certificates",res); } - + void getUserCertificates(List us,UserCertificateLabel label,int userId){ + if (label.getIsLast()==1) { + List userCertificates = userCertificateService.list(new LambdaQueryWrapper() + .eq(UserCertificate::getLabelId,label.getId()) + .eq(UserCertificate::getUserId,userId)); + us.addAll(userCertificates); + }else { + List ls = userCertificateLabelService.list(new LambdaQueryWrapper() + .eq(UserCertificateLabel::getPid,label.getId())); + for (UserCertificateLabel l:ls){ + getUserCertificates(us,l,userId); + } + } + } }