心灵空间

This commit is contained in:
wuchunlei
2025-02-11 09:48:04 +08:00
parent 6d30ebc8a4
commit 0e8b4d2e0e
5 changed files with 265 additions and 3 deletions

View File

@@ -0,0 +1,7 @@
package com.peanut.modules.common.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.peanut.modules.common.entity.UserCourseStudying;
public interface UserCourseStudyingService extends IService<UserCourseStudying> {
}

View File

@@ -0,0 +1,13 @@
package com.peanut.modules.common.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.peanut.modules.common.dao.UserCourseStudyingDao;
import com.peanut.modules.common.entity.UserCourseStudying;
import com.peanut.modules.common.service.UserCourseStudyingService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
@Slf4j
@Service("commonUserCourseStudyingService")
public class UserCourseStudyingServiceImpl extends ServiceImpl<UserCourseStudyingDao, UserCourseStudying> implements UserCourseStudyingService {
}

View File

@@ -0,0 +1,153 @@
package com.peanut.modules.psyche.controller;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.github.yulichang.wrapper.MPJLambdaWrapper;
import com.peanut.common.utils.R;
import com.peanut.common.utils.ShiroUtils;
import com.peanut.modules.common.entity.*;
import com.peanut.modules.common.service.UserCourseStudyingService;
import com.peanut.modules.common.service.UserVipService;
import com.peanut.modules.master.service.CourseCatalogueService;
import com.peanut.modules.master.service.CourseService;
import com.peanut.modules.master.service.UserCourseBuyService;
import lombok.extern.slf4j.Slf4j;
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.HashMap;
import java.util.List;
import java.util.Map;
@Slf4j
@RestController("psycheCourse")
@RequestMapping("psyche/course")
public class PsycheCourseController {
@Autowired
private CourseService courseService;
@Autowired
private CourseCatalogueService coursecatalogueService;
@Autowired
private UserVipService userVipService;
@Autowired
private UserCourseBuyService userCoursebuyService;
@Autowired
private UserCourseStudyingService userCourseStudyingService;
//我的课程-全部
@RequestMapping("/getUserCourseBuy")
public R getUserCourseBuy(){
MPJLambdaWrapper<CourseEntity> wrapper = new MPJLambdaWrapper<>();
wrapper.leftJoin(CourseCatalogueEntity.class,CourseCatalogueEntity::getCourseId,CourseEntity::getId);
wrapper.leftJoin(CourseToPsyche.class,CourseToPsyche::getCourseId,CourseEntity::getId);
wrapper.leftJoin(UserCourseBuyEntity.class,UserCourseBuyEntity::getCourseId,CourseEntity::getId);
wrapper.eq(UserCourseBuyEntity::getUserId,ShiroUtils.getUId());
wrapper.selectAll(CourseEntity.class);
wrapper.selectAs(CourseCatalogueEntity::getId,"catalogueId");
wrapper.selectAs(CourseCatalogueEntity::getTitle,"catalogueTitle");
wrapper.orderByAsc(CourseEntity::getSort);
wrapper.orderByAsc(CourseCatalogueEntity::getSort);
List<Map<String,Object>> courseList = courseService.listMaps(wrapper);
return R.ok().put("courseList",courseList);
}
//我的课程-过期课程
@RequestMapping("/getCourseExpire")
public R getCourseExpire(@RequestBody Map<String,Object> param){
String vip = ShiroUtils.getUser().getVip();
List courseEntities = null;
if (!"1".equals(vip)){
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(CourseToPsyche.class,CourseToPsyche::getCourseId,CourseEntity::getId);
wrapper.eq(UserCourseBuyEntity::getUserId,ShiroUtils.getUId());
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);
courseEntities = courseService.listMaps(wrapper);
}
return R.ok().put("courseList",courseEntities);
}
//我的课程-正在学习(收藏)
@RequestMapping("/getUserCourseStudying")
public R getUserCourseStudying(){
MyUserEntity user = ShiroUtils.getUser();
MPJLambdaWrapper<CourseEntity> wrapper = new MPJLambdaWrapper<>();
wrapper.leftJoin(CourseToPsyche.class,CourseToPsyche::getCourseId,CourseEntity::getId);
wrapper.leftJoin(UserCourseStudying.class,UserCourseStudying::getCourseId,CourseEntity::getId);
wrapper.eq(UserCourseStudying::getUserId,ShiroUtils.getUId());
wrapper.selectAll(CourseEntity.class);
wrapper.orderByAsc(CourseEntity::getSort);
List<CourseEntity> courseEntities = courseService.list(wrapper);
if(courseEntities!=null&&courseEntities.size()>0){
for (CourseEntity co:courseEntities){
List<CourseCatalogueEntity> courseCatalogueEntities = coursecatalogueService.list(new MPJLambdaWrapper<CourseCatalogueEntity>()
.eq(CourseCatalogueEntity::getCourseId, co.getId()).orderByAsc(CourseCatalogueEntity::getSort));
if (courseCatalogueEntities.size() > 0) {
//查询目录添加,购买的课程目录详细信息
for (CourseCatalogueEntity courseCatalogueEntity : courseCatalogueEntities) {
List<UserVip> userVipList = userVipService.list(new LambdaQueryWrapper<UserVip>()
.eq(UserVip::getUserId, user.getId()));
List<UserCourseBuyEntity> userCourseBuyList = userCoursebuyService.list(new LambdaQueryWrapper<UserCourseBuyEntity>()
.eq(UserCourseBuyEntity::getUserId, ShiroUtils.getUId()).eq(UserCourseBuyEntity::getCatalogueId, courseCatalogueEntity.getId()));
//是否购买,生效时间
if ("1".equals(user.getVip())){
//是超级会员或者国学会员
if (userVipList.size() > 0) {
courseCatalogueEntity.setStartTime(userVipList.get(0).getStartTime());
courseCatalogueEntity.setEndTime(userVipList.get(0).getEndTime());
}
courseCatalogueEntity.setIsBuy(1);
}else{
//普通用户
if (userCourseBuyList.size() > 0) {
courseCatalogueEntity.setIsBuy(1);
courseCatalogueEntity.setStartTime(userCourseBuyList.get(0).getStartTime());
courseCatalogueEntity.setEndTime(userCourseBuyList.get(0).getEndTime());
}else {
courseCatalogueEntity.setIsBuy(0);
}
}
}
}
co.setCourseCatalogueEntityList(courseCatalogueEntities);
}
}
return R.ok().put("courseList",courseEntities);
}
//加入收藏(加入正在学习)
@RequestMapping("/addUserCourseStudying")
public R addUserCourseStudying(@RequestBody Map<String,Integer> map){
int isExist = userCourseStudyingService.count(new LambdaQueryWrapper<UserCourseStudying>()
.eq(UserCourseStudying::getUserId,ShiroUtils.getUId())
.eq(UserCourseStudying::getCourseId,map.get("courseId")));
if (isExist>0){
return R.error("已存在");
}else {
UserCourseStudying userCourseStudying = new UserCourseStudying();
userCourseStudying.setUserId(ShiroUtils.getUId());
userCourseStudying.setCourseId(map.get("courseId"));
userCourseStudyingService.save(userCourseStudying);
return R.ok().put("result",userCourseStudying);
}
}
//移出收藏(移出正在学习)
@RequestMapping("/removeUserCourseStudying")
public R removeUserCourseStudying(@RequestBody Map<String,Integer> map){
userCourseStudyingService.remove(new LambdaQueryWrapper<UserCourseStudying>()
.eq(UserCourseStudying::getUserId,ShiroUtils.getUId()).eq(UserCourseStudying::getCourseId,map.get("courseId")));
return R.ok();
}
}

View File

@@ -4,11 +4,15 @@ 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.CoursePsyche;
import com.peanut.modules.common.entity.CourseToPsyche;
import com.peanut.common.utils.ShiroUtils;
import com.peanut.modules.common.entity.*;
import com.peanut.modules.common.service.CoursePsycheService;
import com.peanut.modules.common.service.UserCourseStudyingService;
import com.peanut.modules.common.service.UserVipService;
import com.peanut.modules.master.service.CourseCatalogueService;
import com.peanut.modules.master.service.CourseService;
import com.peanut.modules.master.service.UserCourseBuyService;
import com.peanut.modules.sociology.service.ShopProductService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
@@ -26,6 +30,8 @@ public class PsycheHomeController {
private CoursePsycheService coursePsycheService;
@Autowired
private CourseService courseService;
@Autowired
private ShopProductService shopProductService;
//获取标签列表
@RequestMapping("/getPsycheLabels")
@@ -49,5 +55,48 @@ public class PsycheHomeController {
return R.ok().put("courses",courseEntityPage);
}
//营销标签下商品列表
@RequestMapping("/getPsycheMarketProductList")
public R getPsycheMarketProductList(@RequestBody Map<String,Object> params){
MPJLambdaWrapper<ShopProduct> wrapper = new MPJLambdaWrapper<>();
wrapper.selectAll(ShopProduct.class);
wrapper.leftJoin(ShopProductToPsycheMarket.class,ShopProductToPsycheMarket::getProductId,ShopProduct::getProductId);
wrapper.eq(ShopProductToPsycheMarket::getPsycheMarketId,params.get("shopProductToPsycheMarketId"));
wrapper.orderByAsc(ShopProductToPsycheMarket::getSort);
Page<ShopProduct> shopProductPage = shopProductService.page(new Page<>(
Long.parseLong(params.get("page").toString()), Long.parseLong(params.get("limit").toString())),wrapper);
return R.ok().put("shopProductPage",shopProductPage);
}
//营销标签下课程列表
@RequestMapping("/getPsycheMarketCourseList")
public R getPsycheMarketCourseList(@RequestBody Map<String,Object> params){
MPJLambdaWrapper<CourseEntity> wrapper = new MPJLambdaWrapper<>();
wrapper.selectAll(CourseEntity.class);
wrapper.leftJoin(CourseToPsycheMarket.class, CourseToPsycheMarket::getCourseId,CourseEntity::getId);
wrapper.eq(CourseToPsycheMarket::getPsycheMarketId,params.get("courseToPsycheMarketId"));
wrapper.orderByAsc(CourseToPsycheMarket::getSort);
Page<CourseEntity> courseEntityPage = courseService.page(new Page<>(
Long.parseLong(params.get("page").toString()), Long.parseLong(params.get("limit").toString())),wrapper);
return R.ok().put("courseEntityPage",courseEntityPage);
}
//最近学习课程列表
@RequestMapping("/getUserLateCourseList")
public R getUserLateCourseList(){
MPJLambdaWrapper<CourseEntity> wrapper = new MPJLambdaWrapper<>();
wrapper.selectAll(CourseEntity.class);
wrapper.distinct();
wrapper.leftJoin(UserToCourseEntity.class,UserToCourseEntity::getCourseId,CourseEntity::getId);
wrapper.eq(UserToCourseEntity::getUserId, ShiroUtils.getUId());
wrapper.orderByDesc(UserToCourseEntity::getUpdateTime);
wrapper.exists("select * from course_to_psyche where course_id = t.id");
wrapper.last("Limit 4");
List<CourseEntity> courseList = courseService.list(wrapper);
return R.ok().put("courseList",courseList);
}
}

View File

@@ -12,8 +12,11 @@ import com.peanut.modules.common.entity.*;
import com.peanut.modules.common.service.CoursePsycheService;
import com.peanut.modules.common.service.MessageService;
import com.peanut.modules.common.to.ParamTo;
import com.peanut.modules.master.service.CourseCatalogueService;
import com.peanut.modules.master.service.CourseToSociologyService;
import com.peanut.modules.medical.service.CourseMedicalService;
import com.peanut.modules.medical.service.CourseService;
import com.peanut.modules.sociology.service.CourseCatalogueChapterService;
import com.peanut.modules.sociology.service.CourseSociologyService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
@@ -51,6 +54,10 @@ public class VisitorController {
@Autowired
private CourseSociologyService sociologyService;
@Autowired
private CourseCatalogueService courseCatalogueService;
@Autowired
private CourseCatalogueChapterService courseCatalogueChapterService;
@Autowired
private com.peanut.modules.medical.service.ShopProductService productService;
@Autowired
private CourseService courseService;
@@ -254,6 +261,39 @@ public class VisitorController {
List<CourseSociologyEntity> labelsTree = sociologyService.getCourseSociologyTree();
return R.ok().put("labels",labelsTree);
}
//获取标签下课程
@RequestMapping("/getCourseBySociologyId")
public R getCourseBySociology(@RequestBody Map params){
MPJLambdaWrapper<CourseEntity> wrapper = new MPJLambdaWrapper();
wrapper.selectAll(CourseEntity.class);
wrapper.leftJoin(CourseToSociologyEntity.class,CourseToSociologyEntity::getCourseId,CourseEntity::getId);
wrapper.eq(CourseToSociologyEntity::getSociologyId,params.get("sociologyId"));
List<CourseEntity> courseList = courseService.list(wrapper);
return R.ok().put("courseList",courseList);
}
//课程详情
@RequestMapping("/getSociologyCourseInfo")
public R getSociologyCourseInfo(@RequestBody Map params){
Map<String, Object> courseDetail = new HashMap<>();
//基础信息
CourseEntity course = courseService.getById(params.get("courseId").toString());
courseDetail.put("course",course);
//目录信息
List<CourseCatalogueEntity> courseCatalogueEntities = courseCatalogueService.list(new LambdaQueryWrapper<CourseCatalogueEntity>()
.eq(CourseCatalogueEntity::getCourseId, course.getId()).orderByAsc(CourseCatalogueEntity::getSort));
courseDetail.put("catalogues",courseCatalogueEntities);
return R.ok().put("data",courseDetail);
}
//课程章节
@RequestMapping("/getSociologyCourseCatalogueInfo")
public R getSociologyCourseCatalogueInfo(@RequestBody Map params){
LambdaQueryWrapper<CourseCatalogueChapterEntity> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(CourseCatalogueChapterEntity::getCatalogueId,params.get("catalogueId"));
wrapper.orderByAsc(CourseCatalogueChapterEntity::getSort);
List<CourseCatalogueChapterEntity> list = courseCatalogueChapterService.list(wrapper);
return R.ok().put("list",list);
}
/**
* 国学营销标签下商品列表
*/