我的课程
This commit is contained in:
@@ -27,10 +27,6 @@ public class PsycheCourseController {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private UserVipService userVipService;
|
private UserVipService userVipService;
|
||||||
@Autowired
|
@Autowired
|
||||||
private CourseCatalogueService coursecatalogueService;
|
|
||||||
@Autowired
|
|
||||||
private UserCourseBuyService userCoursebuyService;
|
|
||||||
@Autowired
|
|
||||||
private UserCourseStudyingService userCourseStudyingService;
|
private UserCourseStudyingService userCourseStudyingService;
|
||||||
|
|
||||||
|
|
||||||
@@ -38,23 +34,20 @@ public class PsycheCourseController {
|
|||||||
@RequestMapping("/getUserCourseBuy")
|
@RequestMapping("/getUserCourseBuy")
|
||||||
public R getUserCourseBuy(){
|
public R getUserCourseBuy(){
|
||||||
MPJLambdaWrapper<CourseEntity> wrapper = new MPJLambdaWrapper<>();
|
MPJLambdaWrapper<CourseEntity> wrapper = new MPJLambdaWrapper<>();
|
||||||
wrapper.leftJoin(CourseCatalogueEntity.class,CourseCatalogueEntity::getCourseId,CourseEntity::getId);
|
wrapper.distinct();
|
||||||
wrapper.rightJoin(CourseToPsyche.class,CourseToPsyche::getCourseId,CourseEntity::getId);
|
wrapper.rightJoin(CourseToPsyche.class,CourseToPsyche::getCourseId,CourseEntity::getId);
|
||||||
if (!userVipService.isPsycheVip()){
|
if (!userVipService.isPsycheVip()){
|
||||||
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);
|
||||||
wrapper.selectAs(CourseCatalogueEntity::getId,"catalogueId");
|
|
||||||
wrapper.selectAs(CourseCatalogueEntity::getTitle,"catalogueTitle");
|
|
||||||
wrapper.orderByAsc(CourseEntity::getSort);
|
wrapper.orderByAsc(CourseEntity::getSort);
|
||||||
wrapper.orderByAsc(CourseCatalogueEntity::getSort);
|
List<CourseEntity> courseList = courseService.list(wrapper);
|
||||||
List<Map<String,Object>> courseList = courseService.listMaps(wrapper);
|
for (CourseEntity c:courseList){
|
||||||
for (Map<String,Object> map:courseList){
|
|
||||||
int i = userCourseStudyingService.count(new LambdaQueryWrapper<UserCourseStudying>()
|
int i = userCourseStudyingService.count(new LambdaQueryWrapper<UserCourseStudying>()
|
||||||
.eq(UserCourseStudying::getCourseId,map.get("id"))
|
.eq(UserCourseStudying::getCourseId,c.getId())
|
||||||
.eq(UserCourseStudying::getUserId,ShiroUtils.getUId()));
|
.eq(UserCourseStudying::getUserId,ShiroUtils.getUId()));
|
||||||
map.put("isStudying",i>0?1:0);
|
c.setIsStudying(i>0?1:0);
|
||||||
}
|
}
|
||||||
return R.ok().put("courseList",courseList);
|
return R.ok().put("courseList",courseList);
|
||||||
}
|
}
|
||||||
@@ -96,36 +89,6 @@ public class PsycheCourseController {
|
|||||||
wrapper.selectAll(CourseEntity.class);
|
wrapper.selectAll(CourseEntity.class);
|
||||||
wrapper.orderByAsc(CourseEntity::getSort);
|
wrapper.orderByAsc(CourseEntity::getSort);
|
||||||
List<CourseEntity> courseEntities = courseService.list(wrapper);
|
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<UserCourseBuyEntity> userCourseBuyList = userCoursebuyService.list(new LambdaQueryWrapper<UserCourseBuyEntity>()
|
|
||||||
.eq(UserCourseBuyEntity::getUserId, ShiroUtils.getUId()).eq(UserCourseBuyEntity::getCatalogueId, courseCatalogueEntity.getId()));
|
|
||||||
//是否购买,生效时间
|
|
||||||
UserVip userVip = userVipService.ownCourseCatalogueByVip(courseCatalogueEntity.getCourseId());
|
|
||||||
if (userVip!=null){
|
|
||||||
courseCatalogueEntity.setStartTime(userVip.getStartTime());
|
|
||||||
courseCatalogueEntity.setEndTime(userVip.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);
|
return R.ok().put("courseList",courseEntities);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user