详情中添加课程
This commit is contained in:
@@ -1,126 +0,0 @@
|
||||
package com.peanut.modules.common.controller;
|
||||
|
||||
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;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Slf4j
|
||||
@RestController("commonTaihuTalent")
|
||||
@RequestMapping("common/taihuTalent")
|
||||
public class TaihuTalentController {
|
||||
|
||||
@Autowired
|
||||
private TaihuTalentService taihuTalentService;
|
||||
@Autowired
|
||||
private UserCertificateService userCertificateService;
|
||||
@Autowired
|
||||
private UserCertificateLabelService userCertificateLabelService;
|
||||
|
||||
//太湖英才列表
|
||||
@RequestMapping("/getTaihuTalents")
|
||||
public R getTaihuTalents(@RequestBody Map<String,Object> params){
|
||||
LambdaQueryWrapper<TaihuTalent> wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.like(StringUtils.isNotEmpty(params.get("name").toString()),TaihuTalent::getName,params.get("name"));
|
||||
if (params.containsKey("department")){
|
||||
wrapper.like(StringUtils.isNotEmpty(params.get("department").toString()),TaihuTalent::getDepartment,params.get("department"));
|
||||
}
|
||||
wrapper.like(StringUtils.isNotEmpty(params.get("region").toString()),TaihuTalent::getRegion,params.get("region"));
|
||||
wrapper.orderByAsc(TaihuTalent::getCreateTime);
|
||||
List<TaihuTalent> list = taihuTalentService.list(wrapper);
|
||||
//按职称排序
|
||||
List<String> titleList = Arrays.asList("主任","副主任","主治医师");
|
||||
list = list.stream().sorted((taihuTalent1,taihuTalent2)->{
|
||||
for (String str:titleList){
|
||||
if (str.equals(taihuTalent1.getTitle())||str.equals(taihuTalent2.getTitle())){
|
||||
if (taihuTalent1.getTitle().equals(taihuTalent2.getTitle())){
|
||||
return 0;
|
||||
}else if (str.equals(taihuTalent1.getTitle())){
|
||||
return -1;
|
||||
}else {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}).collect(Collectors.toList());
|
||||
return R.ok().put("list",list);
|
||||
}
|
||||
|
||||
//太湖英才详情
|
||||
@RequestMapping("/taihuTalentInfo")
|
||||
public R taihuTalentInfo(@RequestBody Map<String,Object> params){
|
||||
TaihuTalent taihuTalent = taihuTalentService.getById(params.get("id").toString());
|
||||
List<UserCertificateLabel> labels = userCertificateLabelService.list(new LambdaQueryWrapper<UserCertificateLabel>()
|
||||
.eq(UserCertificateLabel::getPid,0));
|
||||
List<UserCertificateLabel> filterLabels = new ArrayList<>();
|
||||
for (UserCertificateLabel label : labels){
|
||||
List<UserCertificate> us = new ArrayList<>();
|
||||
getUserCertificates(us,label,taihuTalent.getUserId());
|
||||
label.setUserCertificates(us);
|
||||
if (us.size() > 0){
|
||||
filterLabels.add(label);
|
||||
}
|
||||
}
|
||||
List<UserCertificateLabel> res = new ArrayList<>();
|
||||
Set<String> titleLabel = new HashSet<>();
|
||||
//出师证、太湖国际中医师证、太湖国际针灸师证排在前面
|
||||
for (UserCertificateLabel label:filterLabels) {
|
||||
if (label.getId()==22){
|
||||
res.add(label);
|
||||
titleLabel.add("出师证");
|
||||
}
|
||||
}
|
||||
for (UserCertificateLabel label:filterLabels) {
|
||||
if (label.getId()==13){
|
||||
res.add(label);
|
||||
titleLabel.add("太湖国际中医师");
|
||||
}
|
||||
}
|
||||
for (UserCertificateLabel label:filterLabels) {
|
||||
if (label.getId()==19){
|
||||
res.add(label);
|
||||
titleLabel.add("太湖国际针灸师");
|
||||
}
|
||||
}
|
||||
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",titleLabel)
|
||||
.put("certificates",res);
|
||||
}
|
||||
|
||||
void getUserCertificates(List<UserCertificate> us,UserCertificateLabel label,int userId){
|
||||
if (label.getIsLast()==1) {
|
||||
List<UserCertificate> userCertificates = userCertificateService.list(new LambdaQueryWrapper<UserCertificate>()
|
||||
.eq(UserCertificate::getLabelId,label.getId())
|
||||
.eq(UserCertificate::getUserId,userId));
|
||||
us.addAll(userCertificates);
|
||||
}else {
|
||||
List<UserCertificateLabel> ls = userCertificateLabelService.list(new LambdaQueryWrapper<UserCertificateLabel>()
|
||||
.eq(UserCertificateLabel::getPid,label.getId()));
|
||||
for (UserCertificateLabel l:ls){
|
||||
getUserCertificates(us,l,userId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user