太湖英才绑定课程

This commit is contained in:
wuchunlei
2025-06-19 16:48:13 +08:00
parent 7579e4ad98
commit 82c834b272

View File

@@ -2,16 +2,28 @@ package com.peanut.modules.master.controller;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.github.yulichang.wrapper.MPJLambdaWrapper;
import com.peanut.common.utils.R;
import com.peanut.modules.common.entity.CourseEntity;
import com.peanut.modules.common.entity.CourseToTaihumed;
import com.peanut.modules.common.entity.CourseToTalent;
import com.peanut.modules.common.entity.TaihuTalent;
import com.peanut.modules.common.service.CourseToTaihumedService;
import com.peanut.modules.common.service.CourseToTalentService;
import com.peanut.modules.common.service.TaihuTalentService;
import com.peanut.modules.common.to.ParamTo;
import com.peanut.modules.master.service.CourseService;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
@Slf4j
@RestController("masterTaihuTalent")
@@ -20,6 +32,71 @@ public class TaihuTalentController {
@Autowired
private TaihuTalentService taihuTalentService;
@Autowired
private CourseService courseService;
@Autowired
private CourseToTalentService courseToTalentService;
@Autowired
private CourseToTaihumedService courseToTaihumedService;
//太湖英才课程列表
@RequestMapping("/getCourseListForTalent")
public R getCourseListForTalent(@RequestBody Map<String,Object> params){
MPJLambdaWrapper<CourseEntity> wrapper = new MPJLambdaWrapper<>();
wrapper.rightJoin(CourseToTalent.class,CourseToTalent::getCourseId,CourseEntity::getId);
wrapper.selectAll(CourseEntity.class);
wrapper.eq(CourseToTalent::getTalentId,params.get("talentId"));
wrapper.like(StringUtils.isNotBlank(params.get("title").toString()),CourseEntity::getTitle,params.get("title"));
Page<CourseEntity> page = courseService.page(new Page<>(Long.parseLong(params.get("current").toString()),
Long.parseLong(params.get("limit").toString())), wrapper);
return R.ok().put("page",page);
}
//太湖英才可绑定课程列表
@RequestMapping("/getCourseListCanTalent")
public R getCourseListCanTalent(@RequestBody Map<String,Object> params){
List<Integer> collect = courseToTalentService.list(new LambdaQueryWrapper<CourseToTalent>()
.eq(CourseToTalent::getTalentId, params.get("talentId")))
.stream().map(CourseToTalent::getCourseId).collect(Collectors.toList());
MPJLambdaWrapper<CourseEntity> wrapper = new MPJLambdaWrapper<>();
wrapper.rightJoin(CourseToTaihumed.class,CourseToTaihumed::getCourseId,CourseEntity::getId);
wrapper.selectAll(CourseEntity.class);
if (collect.size() != 0){
wrapper.notIn(CourseEntity::getId,collect);
}
wrapper.like(StringUtils.isNotBlank(params.get("title").toString()),CourseEntity::getTitle,params.get("title"));
Page<CourseEntity> page = courseService.page(new Page<>(Long.parseLong(params.get("current").toString()),
Long.parseLong(params.get("limit").toString())), wrapper);
return R.ok().put("page",page);
}
//绑定课程和太湖英才
@RequestMapping("/bindCourseAndTalent")
public R bindCourseAndTalent(@RequestBody CourseToTalent courseToTalent){
//去重
CourseToTalent one = courseToTalentService.getOne(new LambdaQueryWrapper<CourseToTalent>()
.eq(CourseToTalent::getCourseId, courseToTalent.getCourseId())
.eq(CourseToTalent::getTalentId, courseToTalent.getTalentId()));
if(one != null){
return R.error(501,"绑定失败,绑定关系已将存在");
}
courseToTalentService.save(courseToTalent);
return R.ok();
}
//解绑课程和太湖英才
@RequestMapping("/unbindCourseAndTalent")
public R unbindCourseAndTalent(@RequestBody CourseToTalent courseToTalent){
boolean b = courseToTalentService.removeById(courseToTalent.getId());
if(b){
return R.ok();
}else {
return R.error("error");
}
}
//太湖英才列表
@RequestMapping("/getTaihuTalents")
@@ -49,8 +126,11 @@ public class TaihuTalentController {
//删除太湖英才
@RequestMapping("/delTaihuTalent")
@Transactional
public R delTaihuTalent(@RequestBody TaihuTalent taihuTalent){
taihuTalentService.removeById(taihuTalent);
courseToTalentService.remove(new LambdaQueryWrapper<CourseToTalent>()
.eq(CourseToTalent::getTalentId,taihuTalent.getId()));
return R.ok();
}