太湖云医标签
This commit is contained in:
@@ -15,7 +15,7 @@ public class CourseToTaihumed {
|
|||||||
|
|
||||||
private Integer courseId;
|
private Integer courseId;
|
||||||
|
|
||||||
private Integer medicalId;
|
private Integer taihumedId;
|
||||||
|
|
||||||
private Integer sort;
|
private Integer sort;
|
||||||
|
|
||||||
|
|||||||
@@ -6,10 +6,9 @@ import com.github.yulichang.wrapper.MPJLambdaWrapper;
|
|||||||
import com.peanut.common.utils.R;
|
import com.peanut.common.utils.R;
|
||||||
import com.peanut.common.utils.ShiroUtils;
|
import com.peanut.common.utils.ShiroUtils;
|
||||||
import com.peanut.modules.common.entity.*;
|
import com.peanut.modules.common.entity.*;
|
||||||
import com.peanut.modules.common.service.CourseTaihumedService;
|
import com.peanut.modules.common.service.*;
|
||||||
import com.peanut.modules.common.service.CourseToTalentService;
|
|
||||||
import com.peanut.modules.common.service.TaihuTalentService;
|
|
||||||
import com.peanut.modules.master.service.CourseService;
|
import com.peanut.modules.master.service.CourseService;
|
||||||
|
import com.peanut.modules.master.service.UserCourseBuyService;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
@@ -18,9 +17,9 @@ import org.springframework.web.bind.annotation.RequestMapping;
|
|||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@RestController("taihumedCourse")
|
@RestController("taihumedCourse")
|
||||||
@@ -30,24 +29,124 @@ public class CourseController {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private CourseTaihumedService courseTaihumedService;
|
private CourseTaihumedService courseTaihumedService;
|
||||||
@Autowired
|
@Autowired
|
||||||
|
private CourseToTaihumedService courseToTaihumedService;
|
||||||
|
@Autowired
|
||||||
private CourseToTalentService courseToTalentService;
|
private CourseToTalentService courseToTalentService;
|
||||||
@Autowired
|
@Autowired
|
||||||
private TaihuTalentService taihuTalentService;
|
private TaihuTalentService taihuTalentService;
|
||||||
@Autowired
|
@Autowired
|
||||||
private CourseService courseService;
|
private CourseService courseService;
|
||||||
|
@Autowired
|
||||||
|
private UserVipService userVipService;
|
||||||
|
@Autowired
|
||||||
|
private UserCourseBuyService userCourseBuyService;
|
||||||
|
|
||||||
|
|
||||||
|
//课程标签列表
|
||||||
|
@RequestMapping("/getCourseTaihumedList")
|
||||||
|
public R getCourseTaihumedList(){
|
||||||
|
List<CourseTaihumed> list = courseTaihumedService.list(new LambdaQueryWrapper<CourseTaihumed>()
|
||||||
|
.eq(CourseTaihumed::getPid,0)
|
||||||
|
.orderByAsc(CourseTaihumed::getSort));
|
||||||
|
return R.ok().put("list",list);
|
||||||
|
}
|
||||||
|
|
||||||
|
//标签下课程列表
|
||||||
|
@RequestMapping("/getCourseToTaihumedList")
|
||||||
|
public R getCourseToTaihumedList(@RequestBody Map<String,Object> params){
|
||||||
|
MPJLambdaWrapper<CourseEntity> wrapper = new MPJLambdaWrapper();
|
||||||
|
wrapper.rightJoin(CourseToTaihumed.class,CourseToTaihumed::getCourseId,CourseEntity::getId);
|
||||||
|
wrapper.orderByAsc(CourseToTaihumed::getSort);
|
||||||
|
wrapper.selectAll(CourseEntity.class);
|
||||||
|
wrapper.eq(CourseToTaihumed::getTaihumedId,params.get("taihumedId"));
|
||||||
|
if (StringUtils.isNotEmpty(params.get("userName").toString())){
|
||||||
|
wrapper.leftJoin(CourseToTalent.class,CourseToTalent::getCourseId,CourseEntity::getId);
|
||||||
|
wrapper.leftJoin(TaihuTalent.class,TaihuTalent::getId,CourseToTalent::getTalentId);
|
||||||
|
wrapper.selectAs(TaihuTalent::getId,"taihuTalentId");
|
||||||
|
wrapper.like(StringUtils.isNotEmpty(params.get("userName").toString()),TaihuTalent::getName,params.get("userName"));
|
||||||
|
}
|
||||||
|
wrapper.like(StringUtils.isNotEmpty(params.get("courseName").toString()),CourseEntity::getTitle,params.get("courseName"));
|
||||||
|
Page<CourseEntity> pageRes = courseService.page(new Page<>(Long.parseLong(params.get("current").toString())
|
||||||
|
, Long.parseLong(params.get("limit").toString())),wrapper);
|
||||||
|
for (CourseEntity course:pageRes.getRecords()){
|
||||||
|
if (course.getTaihuTalentId()!=null){
|
||||||
|
course.setTaihuTalent(taihuTalentService.getById(course.getTaihuTalentId()));
|
||||||
|
}else {
|
||||||
|
CourseToTalent courseToTalent = courseToTalentService.getOne(new LambdaQueryWrapper<CourseToTalent>()
|
||||||
|
.eq(CourseToTalent::getCourseId,course.getId()));
|
||||||
|
if (courseToTalent!=null){
|
||||||
|
TaihuTalent taihuTalent = taihuTalentService.getById(courseToTalent.getTalentId());
|
||||||
|
course.setTaihuTalent(taihuTalent);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return R.ok().put("pageRes",pageRes);
|
||||||
|
}
|
||||||
|
|
||||||
|
//当前课程是否可看
|
||||||
|
@RequestMapping("/checkPermission")
|
||||||
|
public R checkPermission(@RequestBody Map<String,Object> params){
|
||||||
|
boolean flag = false;
|
||||||
|
String endTime = "";
|
||||||
|
//查询当前课程绑定的标签
|
||||||
|
List<CourseToTaihumed> courseToTaihumeds = courseToTaihumedService.list(new LambdaQueryWrapper<CourseToTaihumed>()
|
||||||
|
.eq(CourseToTaihumed::getCourseId,params.get("courseId")));
|
||||||
|
List<Integer> taihumedLabelIds = new ArrayList<>();
|
||||||
|
//当前课程的顶级标签
|
||||||
|
for (CourseToTaihumed ctt:courseToTaihumeds){
|
||||||
|
topLael(taihumedLabelIds,ctt.getTaihumedId());
|
||||||
|
}
|
||||||
|
//超级vip可看当前板块所有课程
|
||||||
|
for (int i:taihumedLabelIds){
|
||||||
|
if (i==99&&userVipService.is4569SVip(ShiroUtils.getUId())){
|
||||||
|
flag = true;
|
||||||
|
}
|
||||||
|
if (i==100&&userVipService.is78SVip(ShiroUtils.getUId())){
|
||||||
|
flag = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!flag){
|
||||||
|
//太湖英才可看自己和当前板块的所有课程
|
||||||
|
TaihuTalent taihuTalent = taihuTalentService.getOne(new LambdaQueryWrapper<TaihuTalent>()
|
||||||
|
.eq(TaihuTalent::getUserId,ShiroUtils.getUId()));
|
||||||
|
if (taihuTalent != null){
|
||||||
|
List<CourseToTalent> courseToTalents = courseToTalentService.list(new LambdaQueryWrapper<CourseToTalent>()
|
||||||
|
.eq(CourseToTalent::getTalentId,taihuTalent.getId()));
|
||||||
|
List<Integer> collect = courseToTalents.stream().map(CourseToTalent::getCourseId).collect(Collectors.toList());
|
||||||
|
List<CourseToTaihumed> cTTs = courseToTaihumedService.list(new LambdaQueryWrapper<CourseToTaihumed>()
|
||||||
|
.in(CourseToTaihumed::getCourseId,collect));
|
||||||
|
List<Integer> tls = new ArrayList<>();
|
||||||
|
for (CourseToTaihumed ctt:cTTs){
|
||||||
|
topLael(tls,ctt.getTaihumedId());
|
||||||
|
}
|
||||||
|
for (int i:tls){
|
||||||
|
for (int j:taihumedLabelIds){
|
||||||
|
if (i==j){
|
||||||
|
flag = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!flag){
|
||||||
|
//不是太湖英才,不是vip,查询买课
|
||||||
|
List<UserCourseBuyEntity> ucbs = userCourseBuyService.list(new LambdaQueryWrapper<UserCourseBuyEntity>()
|
||||||
|
.eq(UserCourseBuyEntity::getUserId,ShiroUtils.getUId())
|
||||||
|
.eq(UserCourseBuyEntity::getCatalogueId,params.get("catalogueId"))
|
||||||
|
.orderByDesc(UserCourseBuyEntity::getEndTime));
|
||||||
|
if (ucbs.size() > 0){
|
||||||
|
endTime = ucbs.get(0).getEndTime()==null?"":ucbs.get(0).getEndTime().toString();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return R.ok().put("flag",flag).put("endTime",endTime);
|
||||||
|
}
|
||||||
|
|
||||||
//我的课程
|
//我的课程
|
||||||
@RequestMapping("/getMyCourseList")
|
@RequestMapping("/getMyCourseList")
|
||||||
public R getMyCourseList(@RequestBody Map<String,Object> params){
|
public R getMyCourseList(@RequestBody Map<String,Object> params){
|
||||||
MPJLambdaWrapper<CourseEntity> wrapper = new MPJLambdaWrapper<>();
|
MPJLambdaWrapper<CourseEntity> wrapper = new MPJLambdaWrapper<>();
|
||||||
wrapper.distinct();
|
wrapper.distinct();
|
||||||
int count = courseTaihumedService.count(new LambdaQueryWrapper<CourseTaihumed>()
|
wrapper.rightJoin(CourseToTaihumed.class,CourseToTaihumed::getCourseId,CourseEntity::getId);
|
||||||
.eq(CourseTaihumed::getPid,0));
|
|
||||||
if (count > 0){
|
|
||||||
wrapper.rightJoin(CourseToTaihumed.class,CourseToTaihumed::getCourseId,CourseEntity::getId);
|
|
||||||
}else {
|
|
||||||
wrapper.rightJoin(CourseToTalent.class,CourseToTalent::getCourseId,CourseEntity::getId);
|
|
||||||
}
|
|
||||||
wrapper.leftJoin(UserCourseBuyEntity.class,UserCourseBuyEntity::getCourseId,CourseEntity::getId);
|
wrapper.leftJoin(UserCourseBuyEntity.class,UserCourseBuyEntity::getCourseId,CourseEntity::getId);
|
||||||
wrapper.eq(UserCourseBuyEntity::getUserId,ShiroUtils.getUId());
|
wrapper.eq(UserCourseBuyEntity::getUserId,ShiroUtils.getUId());
|
||||||
wrapper.selectAll(CourseEntity.class);
|
wrapper.selectAll(CourseEntity.class);
|
||||||
@@ -57,34 +156,17 @@ public class CourseController {
|
|||||||
return R.ok().put("pageRes",pageRes);
|
return R.ok().put("pageRes",pageRes);
|
||||||
}
|
}
|
||||||
|
|
||||||
//名医精彩列表
|
public void topLael(List<Integer> list, int courseTaihumedId){
|
||||||
@RequestMapping("/getCourseToTalentList")
|
CourseTaihumed courseTaihumed = courseTaihumedService.getById(courseTaihumedId);
|
||||||
public R getCourseToTalentList(@RequestBody Map<String,Object> params){
|
if (courseTaihumed.getPid()==0){
|
||||||
MPJLambdaWrapper<CourseEntity> wrapper = new MPJLambdaWrapper();
|
list.add(courseTaihumed.getId());
|
||||||
int count = courseTaihumedService.count(new LambdaQueryWrapper<CourseTaihumed>()
|
|
||||||
.eq(CourseTaihumed::getPid,0));
|
|
||||||
if (count > 0){
|
|
||||||
wrapper.rightJoin(CourseToTaihumed.class,CourseToTaihumed::getCourseId,CourseEntity::getId);
|
|
||||||
wrapper.orderByAsc(CourseToTaihumed::getSort);
|
|
||||||
}else {
|
}else {
|
||||||
wrapper.rightJoin(CourseToTalent.class,CourseToTalent::getCourseId,CourseEntity::getId);
|
CourseTaihumed pCourseTaihumed = courseTaihumedService.getOne(new LambdaQueryWrapper<CourseTaihumed>()
|
||||||
wrapper.orderByAsc(CourseToTalent::getSort);
|
.eq(CourseTaihumed::getId,courseTaihumed.getPid()));
|
||||||
|
topLael(list,pCourseTaihumed.getId());
|
||||||
}
|
}
|
||||||
wrapper.leftJoin(CourseToTalent.class,CourseToTalent::getCourseId,CourseEntity::getId);
|
|
||||||
wrapper.leftJoin(TaihuTalent.class,TaihuTalent::getId,CourseToTalent::getTalentId);
|
|
||||||
wrapper.selectAll(CourseEntity.class);
|
|
||||||
wrapper.selectAs(TaihuTalent::getId,"taihuTalentId");
|
|
||||||
wrapper.like(StringUtils.isNotEmpty(params.get("userName").toString()),TaihuTalent::getName,params.get("userName"));
|
|
||||||
wrapper.like(StringUtils.isNotEmpty(params.get("courseName").toString()),CourseEntity::getTitle,params.get("courseName"));
|
|
||||||
Page<CourseEntity> pageRes = courseService.page(new Page<>(Long.parseLong(params.get("current").toString())
|
|
||||||
, Long.parseLong(params.get("limit").toString())),wrapper);
|
|
||||||
for (CourseEntity course:pageRes.getRecords()){
|
|
||||||
course.setTaihuTalent(taihuTalentService.getById(course.getTaihuTalentId()));
|
|
||||||
}
|
|
||||||
return R.ok().put("pageRes",pageRes);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user