国学-我的课程
This commit is contained in:
@@ -38,4 +38,6 @@ public class CourseSociologyEntity {
|
||||
|
||||
@TableField(exist = false)
|
||||
private List<CourseSociologyEntity> children;
|
||||
@TableField(exist = false)
|
||||
private List<CourseEntity> courseList;
|
||||
}
|
||||
|
||||
@@ -121,8 +121,8 @@ public class CourseServiceImpl extends ServiceImpl<CourseDao, CourseEntity> impl
|
||||
wrapper.distinct();
|
||||
wrapper.leftJoin(CourseCatalogueEntity.class,CourseCatalogueEntity::getCourseId,CourseEntity::getId);
|
||||
//关掉本次查询del_flg = 0的条件,查询过期课程
|
||||
wrapper.disableSubLogicDel().leftJoin(UserCourseBuyEntity.class,UserCourseBuyEntity::getCatalogueId,CourseCatalogueEntity::getId);
|
||||
wrapper.leftJoin(CourseToMedicine.class,CourseToMedicine::getCourseId,CourseEntity::getId);
|
||||
wrapper.disableSubLogicDel().rightJoin(UserCourseBuyEntity.class,UserCourseBuyEntity::getCatalogueId,CourseCatalogueEntity::getId);
|
||||
wrapper.rightJoin(CourseToMedicine.class,CourseToMedicine::getCourseId,CourseEntity::getId);
|
||||
wrapper.eq(UserCourseBuyEntity::getUserId,param.get("userId"));
|
||||
wrapper.eq(UserCourseBuyEntity::getDelFlag,-1);
|
||||
wrapper.selectAll(CourseEntity.class);
|
||||
@@ -174,6 +174,7 @@ public class CourseServiceImpl extends ServiceImpl<CourseDao, CourseEntity> impl
|
||||
new MPJLambdaWrapper<CourseCatalogueEntity>()
|
||||
.selectAll(CourseCatalogueEntity.class)
|
||||
.leftJoin(UserCourseBuyEntity.class, UserCourseBuyEntity::getCatalogueId,CourseCatalogueEntity::getId)
|
||||
.eq(CourseCatalogueEntity::getCourseId, co.getId())
|
||||
.eq(UserCourseBuyEntity::getUserId, user.getId())
|
||||
.orderByAsc(CourseCatalogueEntity::getSort));
|
||||
co.setCourseCatalogueEntityList(courseCatalogueEntities);
|
||||
|
||||
@@ -1,31 +1,22 @@
|
||||
package com.peanut.modules.sociology.controller;
|
||||
|
||||
import com.aliyun.tea.TeaException;
|
||||
import com.aliyun.teautil.models.RuntimeOptions;
|
||||
import com.aliyun.vod20170321.Client;
|
||||
import com.aliyun.vod20170321.models.*;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.peanut.common.utils.R;
|
||||
import com.peanut.common.utils.ShiroUtils;
|
||||
import com.peanut.common.utils.SpdbUtil;
|
||||
import com.peanut.modules.common.dao.CourseCatalogueChapterVideoDao;
|
||||
import com.peanut.modules.common.entity.CourseCatalogueChapterEntity;
|
||||
import com.peanut.modules.common.entity.CourseCatalogueChapterVideoEntity;
|
||||
import com.peanut.modules.common.entity.CourseEntity;
|
||||
import com.peanut.modules.common.entity.SysCourseDirectEntity;
|
||||
import com.peanut.modules.common.entity.*;
|
||||
import com.peanut.modules.common.to.ParamTo;
|
||||
import com.peanut.modules.master.service.CourseCatalogueChapterVideoService;
|
||||
import com.peanut.modules.master.service.SysCourseDirectService;
|
||||
import com.peanut.modules.sociology.service.CourseCatalogueChapterService;
|
||||
import com.peanut.modules.sociology.service.CourseService;
|
||||
import com.peanut.modules.sociology.service.CourseSociologyService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
//import org.bytedeco.javacv.FFmpegFrameGrabber;
|
||||
//import org.bytedeco.javacv.FrameGrabber;
|
||||
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.List;
|
||||
import java.util.Map;
|
||||
|
||||
@@ -42,6 +33,8 @@ public class CourseController {
|
||||
private CourseCatalogueChapterVideoService courseCatalogueChapterVideoService;
|
||||
@Autowired
|
||||
private SysCourseDirectService sysCourseDirectService;
|
||||
@Autowired
|
||||
private CourseSociologyService courseSociologyService;
|
||||
|
||||
/**
|
||||
* 获取用户最近学习课程列表
|
||||
@@ -173,4 +166,39 @@ public class CourseController {
|
||||
return R.ok().put("courses",courses);
|
||||
}
|
||||
|
||||
//添加正在学习(收藏)
|
||||
@RequestMapping("/addUserCourseStudying")
|
||||
public R addUserCourseStudying(@RequestBody UserCourseStudying userCourseStudying){
|
||||
return R.ok().put("success",courseService.addUserCourseStudying(userCourseStudying));
|
||||
}
|
||||
|
||||
//移除正在学习(收藏)
|
||||
@RequestMapping("/delUserCourseStudying")
|
||||
public R delUserCourseStudying(@RequestBody Map<String,Object> param){
|
||||
return R.ok().put("success",courseService.delUserCourseStudying(param));
|
||||
}
|
||||
|
||||
//我的课程-正在学习(收藏)
|
||||
@RequestMapping("/getUserCourseStudying")
|
||||
public R getUserCourseStudying(@RequestBody Map<String,Object> param){
|
||||
List courseList = courseService.getUserCourseStudying(param);
|
||||
return R.ok().put("courseList",courseList);
|
||||
}
|
||||
|
||||
//我的课程-全部
|
||||
@RequestMapping("/getUserCourseBuy")
|
||||
public R getUserCourseBuy(@RequestBody Map<String,Object> param){
|
||||
List<CourseSociologyEntity> courseSociologyList = courseSociologyService.getCourseSociologyTree();
|
||||
param.put("courseSociologyList",courseSociologyList);
|
||||
List courseList = courseService.getUserCourseBuy(param);
|
||||
return R.ok().put("courseList",courseList);
|
||||
}
|
||||
|
||||
//我的课程-过期课程
|
||||
@RequestMapping("/getCourseExpire")
|
||||
public R getCourseExpire(@RequestBody Map<String,Object> param){
|
||||
List courseList = courseService.getCourseExpire(param);
|
||||
return R.ok().put("courseList",courseList);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -3,10 +3,9 @@ package com.peanut.modules.sociology.service;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.peanut.common.utils.R;
|
||||
import com.peanut.modules.common.entity.CourseCatalogueChapterEntity;
|
||||
import com.peanut.modules.common.entity.CourseEntity;
|
||||
import com.peanut.modules.common.entity.UserCourseStudying;
|
||||
import com.peanut.modules.common.to.ParamTo;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@@ -28,4 +27,14 @@ public interface CourseService extends IService<CourseEntity> {
|
||||
List getCoursePrice();
|
||||
|
||||
R startStudyForMF(int catalogueId);
|
||||
|
||||
boolean addUserCourseStudying(UserCourseStudying userCourseStudying);
|
||||
|
||||
boolean delUserCourseStudying(Map<String,Object> param);
|
||||
|
||||
List getUserCourseStudying(Map<String,Object> param);
|
||||
|
||||
List getUserCourseBuy(Map<String,Object> param);
|
||||
|
||||
List getCourseExpire(Map<String,Object> param);
|
||||
}
|
||||
|
||||
@@ -8,4 +8,6 @@ import java.util.List;
|
||||
public interface CourseSociologyService extends IService<CourseSociologyEntity> {
|
||||
|
||||
List<CourseSociologyEntity> getSociologyLabels(Integer id);
|
||||
|
||||
List<CourseSociologyEntity> getCourseSociologyTree();
|
||||
}
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package com.peanut.modules.sociology.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.enums.SqlKeyword;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.github.yulichang.wrapper.MPJLambdaWrapper;
|
||||
@@ -15,7 +14,6 @@ import com.peanut.modules.sociology.service.CourseService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@@ -40,6 +38,10 @@ public class CourseServiceImpl extends ServiceImpl<CourseDao, CourseEntity> impl
|
||||
private UserCourseVideoPositionDao userCourseVideoPositionDao;
|
||||
@Autowired
|
||||
private CourseSociologyDao courseSociologyDao;
|
||||
@Autowired
|
||||
private UserCourseStudyingDao studyingDao;
|
||||
@Autowired
|
||||
private MyUserDao userDao;
|
||||
|
||||
|
||||
//根据标签获取课程列表
|
||||
@@ -207,5 +209,121 @@ public class CourseServiceImpl extends ServiceImpl<CourseDao, CourseEntity> impl
|
||||
return courseCatalogueChapterEntities.size()==0?0:act * 100 / courseCatalogueChapterEntities.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean addUserCourseStudying(UserCourseStudying userCourseStudying) {
|
||||
if (studyingDao.insert(userCourseStudying)>0){
|
||||
return true;
|
||||
}else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean delUserCourseStudying(Map<String,Object> param) {
|
||||
if (studyingDao.deleteById(param.get("id").toString())>0){
|
||||
return true;
|
||||
}else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List getUserCourseStudying(Map<String, Object> param) {
|
||||
MPJLambdaWrapper<CourseEntity> wrapper = new MPJLambdaWrapper<>();
|
||||
wrapper.distinct();
|
||||
wrapper.leftJoin(CourseCatalogueEntity.class,CourseCatalogueEntity::getCourseId,CourseEntity::getId);
|
||||
wrapper.leftJoin(CourseToSociologyEntity.class,CourseToSociologyEntity::getCourseId,CourseEntity::getId);
|
||||
wrapper.leftJoin(UserCourseStudying.class,UserCourseStudying::getCatalogueId,CourseCatalogueEntity::getId);
|
||||
wrapper.eq(UserCourseStudying::getUserId,param.get("userId"));
|
||||
wrapper.selectAll(CourseEntity.class);
|
||||
wrapper.selectAs(CourseCatalogueEntity::getId,"catalogueId");
|
||||
wrapper.selectAs(CourseCatalogueEntity::getTitle,"catalogueTitle");
|
||||
wrapper.orderByAsc(CourseEntity::getSort);
|
||||
List courseEntities = this.getBaseMapper().selectMaps(wrapper);
|
||||
return courseEntities;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List getUserCourseBuy(Map<String, Object> param) {
|
||||
MyUserEntity user = userDao.selectById(param.get("userId").toString());
|
||||
List<CourseSociologyEntity> resultList = new ArrayList<>();
|
||||
List<CourseSociologyEntity> courseSociologyList = (List<CourseSociologyEntity>)param.get("courseSociologyList");
|
||||
for (CourseSociologyEntity c : courseSociologyList){
|
||||
if (getCourseBySociology(c,user)){
|
||||
resultList.add(c);
|
||||
}
|
||||
}
|
||||
return resultList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List getCourseExpire(Map<String, Object> param) {
|
||||
MPJLambdaWrapper<CourseEntity> wrapper = new MPJLambdaWrapper<>();
|
||||
wrapper.distinct();
|
||||
wrapper.leftJoin(CourseCatalogueEntity.class,CourseCatalogueEntity::getCourseId,CourseEntity::getId);
|
||||
//关掉本次查询del_flg = 0的条件,查询过期课程
|
||||
wrapper.disableSubLogicDel().rightJoin(UserCourseBuyEntity.class,UserCourseBuyEntity::getCatalogueId,CourseCatalogueEntity::getId);
|
||||
wrapper.rightJoin(CourseToSociologyEntity.class,CourseToSociologyEntity::getCourseId,CourseEntity::getId);
|
||||
wrapper.eq(UserCourseBuyEntity::getUserId,param.get("userId"));
|
||||
wrapper.eq(UserCourseBuyEntity::getDelFlag,-1);
|
||||
wrapper.selectAll(CourseEntity.class);
|
||||
wrapper.selectAs(CourseCatalogueEntity::getId,"catalogueId");
|
||||
wrapper.selectAs(CourseCatalogueEntity::getTitle,"catalogueTitle");
|
||||
wrapper.orderByAsc(CourseEntity::getSort);
|
||||
wrapper.orderByAsc(CourseCatalogueEntity::getSort);
|
||||
List courseEntities = this.getBaseMapper().selectMaps(wrapper);
|
||||
return courseEntities;
|
||||
}
|
||||
|
||||
|
||||
private boolean getCourseBySociology(CourseSociologyEntity c,MyUserEntity user){
|
||||
if (c.getChildren()!=null&&c.getChildren().size() > 0){
|
||||
for (CourseSociologyEntity child : c.getChildren()){
|
||||
return getCourseBySociology(child,user);
|
||||
}
|
||||
}
|
||||
List<CourseEntity> courseEntities = null;
|
||||
//0-普通 1超级vip 2医学vip 3国学vip
|
||||
if ("1".equals(user.getVip())||"3".equals(user.getVip())){
|
||||
MPJLambdaWrapper<CourseToSociologyEntity> wrapper = new MPJLambdaWrapper<>();
|
||||
wrapper.leftJoin(CourseEntity.class,CourseEntity::getId,CourseToSociologyEntity::getCourseId);
|
||||
wrapper.selectAll(CourseEntity.class);
|
||||
wrapper.eq(CourseToSociologyEntity::getSociologyId,c.getId());
|
||||
wrapper.orderByAsc(CourseEntity::getSort);
|
||||
courseEntities = courseToSociologyDao.selectJoinList(CourseEntity.class, wrapper);
|
||||
if(courseEntities!=null&&courseEntities.size()>0){
|
||||
for (CourseEntity co:courseEntities){
|
||||
List<CourseCatalogueEntity> courseCatalogueEntities = courseCatalogueDao.selectList(new LambdaQueryWrapper<CourseCatalogueEntity>().eq(CourseCatalogueEntity::getCourseId, co.getId()).orderByAsc(CourseCatalogueEntity::getSort));
|
||||
co.setCourseCatalogueEntityList(courseCatalogueEntities);
|
||||
}
|
||||
c.setCourseList(courseEntities);
|
||||
return true;
|
||||
}
|
||||
}else if ("0".equals(user.getVip())||"2".equals(user.getVip())){
|
||||
MPJLambdaWrapper<UserCourseBuyEntity> wrapper = new MPJLambdaWrapper<>();
|
||||
wrapper.leftJoin(CourseCatalogueEntity.class,CourseCatalogueEntity::getId,UserCourseBuyEntity::getCatalogueId);
|
||||
wrapper.leftJoin(CourseEntity.class,CourseEntity::getId,CourseCatalogueEntity::getCourseId);
|
||||
wrapper.leftJoin(CourseToSociologyEntity.class,CourseToSociologyEntity::getCourseId,UserCourseBuyEntity::getCourseId);
|
||||
wrapper.selectAll(CourseEntity.class);
|
||||
wrapper.eq(UserCourseBuyEntity::getUserId,user.getId());
|
||||
wrapper.eq(CourseToSociologyEntity::getSociologyId,c.getId());
|
||||
wrapper.orderByAsc(CourseEntity::getSort);
|
||||
courseEntities = userCourseBuyDao.selectJoinList(CourseEntity.class, wrapper);
|
||||
if(courseEntities!=null&&courseEntities.size()>0){
|
||||
for (CourseEntity co:courseEntities){
|
||||
List<CourseCatalogueEntity> courseCatalogueEntities = courseCatalogueDao.selectList(
|
||||
new MPJLambdaWrapper<CourseCatalogueEntity>()
|
||||
.selectAll(CourseCatalogueEntity.class)
|
||||
.leftJoin(UserCourseBuyEntity.class, UserCourseBuyEntity::getCatalogueId,CourseCatalogueEntity::getId)
|
||||
.eq(CourseCatalogueEntity::getCourseId, co.getId())
|
||||
.eq(UserCourseBuyEntity::getUserId, user.getId())
|
||||
.orderByAsc(CourseCatalogueEntity::getSort));
|
||||
co.setCourseCatalogueEntityList(courseCatalogueEntities);
|
||||
}
|
||||
c.setCourseList(courseEntities);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.peanut.modules.sociology.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.peanut.modules.common.dao.CourseSociologyDao;
|
||||
import com.peanut.modules.common.entity.CourseSociologyEntity;
|
||||
@@ -9,6 +10,7 @@ import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Slf4j
|
||||
@Service("sociologyCourseSociologyService")
|
||||
@@ -22,4 +24,30 @@ public class CourseSociologyServiceImpl extends ServiceImpl<CourseSociologyDao,
|
||||
List<CourseSociologyEntity> list = this.list(wrapper);
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<CourseSociologyEntity> getCourseSociologyTree() {
|
||||
List<CourseSociologyEntity> sociologys = this.list(new QueryWrapper<>());
|
||||
List<CourseSociologyEntity> sociologyTree = sociologys.stream().filter((courseSociology) ->
|
||||
courseSociology.getPid() == 0
|
||||
).map((sociology)->{
|
||||
sociology.setChildren(getSociologyChildrens(sociology,sociologys));
|
||||
return sociology;
|
||||
}).sorted((sort1,sort2)->{
|
||||
return (sort1.getSort() == null? 0 : sort1.getSort()) - (sort2.getSort()==null?0:sort2.getSort());
|
||||
}).collect(Collectors.toList());
|
||||
return sociologyTree;
|
||||
}
|
||||
|
||||
private List<CourseSociologyEntity> getSociologyChildrens(CourseSociologyEntity root, List<CourseSociologyEntity> all){
|
||||
List<CourseSociologyEntity> children = all.stream().filter(courseSociology -> {
|
||||
return root.getId().equals(courseSociology.getPid());
|
||||
}).map(courseSociology -> {
|
||||
courseSociology.setChildren(getSociologyChildrens(courseSociology, all));
|
||||
return courseSociology;
|
||||
}).sorted((sort1,sort2)->{
|
||||
return (sort1.getSort()==null?0:sort1.getSort()) - (sort2.getSort()==null?0:sort2.getSort());
|
||||
}).collect(Collectors.toList());
|
||||
return children;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user