1
This commit is contained in:
@@ -0,0 +1,9 @@
|
||||
package com.peanut.modules.common.dao;
|
||||
|
||||
import com.github.yulichang.base.MPJBaseMapper;
|
||||
import com.peanut.modules.common.entity.UserToCourseEntity;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
@Mapper
|
||||
public interface UserToCourseDao extends MPJBaseMapper<UserToCourseEntity> {
|
||||
}
|
||||
@@ -15,6 +15,8 @@ public class CourseCatalogueChapterEntity {
|
||||
|
||||
private Integer courseId;
|
||||
|
||||
private Integer catalogueId;
|
||||
|
||||
private String title;
|
||||
|
||||
private String imgUrl;
|
||||
|
||||
@@ -15,6 +15,8 @@ public class CourseCatalogueEntity{
|
||||
@TableId
|
||||
private Integer id;
|
||||
|
||||
private Integer type;
|
||||
|
||||
private Integer courseId;
|
||||
|
||||
private String title;
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
package com.peanut.modules.common.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableLogic;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
@Data
|
||||
@TableName("user_to_course")
|
||||
public class UserToCourseEntity {
|
||||
|
||||
@TableId
|
||||
private Integer id;
|
||||
|
||||
private Integer userId;
|
||||
|
||||
private Integer courseId;
|
||||
|
||||
private Integer catalogueId;
|
||||
|
||||
private Date createTime;
|
||||
|
||||
private Integer days;
|
||||
|
||||
private Date startTime;
|
||||
|
||||
private Date endTime;
|
||||
|
||||
@TableLogic
|
||||
private Integer delFlag;
|
||||
}
|
||||
@@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.peanut.common.utils.R;
|
||||
import com.peanut.modules.common.entity.CourseCatalogueEntity;
|
||||
import com.peanut.modules.common.entity.CourseEntity;
|
||||
import com.peanut.modules.common.to.ParamTo;
|
||||
import com.peanut.modules.master.service.CourseCatalogueService;
|
||||
import com.peanut.modules.master.service.CourseService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@@ -55,4 +56,18 @@ public class CourseController {
|
||||
return R.ok().put("catalogues",courseCatalogues);
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping("/addCourseCatalogue")
|
||||
public R addCourseCatalogue(@RequestBody CourseCatalogueEntity courseCatalogue){
|
||||
|
||||
//课程这里增加对应商品的还没有做
|
||||
courseCatalogueService.save(courseCatalogue);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
@RequestMapping("/delCourseCatalogue")
|
||||
public R delCourseCatalogue(@RequestBody ParamTo param){
|
||||
return courseCatalogueService.delCourseCatalogue(param.getId());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.peanut.modules.master.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.peanut.common.utils.R;
|
||||
import com.peanut.modules.common.entity.CourseCatalogueEntity;
|
||||
|
||||
import java.util.List;
|
||||
@@ -8,4 +9,6 @@ import java.util.List;
|
||||
public interface CourseCatalogueService extends IService<CourseCatalogueEntity> {
|
||||
|
||||
List<CourseCatalogueEntity> getCourseCatalogues(int id);
|
||||
|
||||
R delCourseCatalogue(int id);
|
||||
}
|
||||
|
||||
@@ -2,18 +2,28 @@ package com.peanut.modules.master.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.peanut.common.utils.R;
|
||||
import com.peanut.modules.common.dao.CourseCatalogueChapterDao;
|
||||
import com.peanut.modules.common.dao.CourseCatalogueDao;
|
||||
import com.peanut.modules.common.dao.UserToCourseDao;
|
||||
import com.peanut.modules.common.entity.CourseCatalogueChapterEntity;
|
||||
import com.peanut.modules.common.entity.CourseCatalogueEntity;
|
||||
import com.peanut.modules.common.entity.UserToCourseEntity;
|
||||
import com.peanut.modules.master.service.CourseCatalogueService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
@Slf4j
|
||||
@Service("masterCourseCatalogueService")
|
||||
public class CourseCatalogueServiceImpl extends ServiceImpl<CourseCatalogueDao, CourseCatalogueEntity> implements CourseCatalogueService {
|
||||
|
||||
@Autowired
|
||||
private CourseCatalogueChapterDao courseCatalogueChapterDao;
|
||||
@Autowired
|
||||
private UserToCourseDao userToCourseDao;
|
||||
|
||||
@Override
|
||||
public List<CourseCatalogueEntity> getCourseCatalogues(int id) {
|
||||
@@ -22,4 +32,21 @@ public class CourseCatalogueServiceImpl extends ServiceImpl<CourseCatalogueDao,
|
||||
List<CourseCatalogueEntity> list = this.list(courseCatalogueEntityLambdaQueryWrapper);
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public R delCourseCatalogue(int id) {
|
||||
Integer integer = courseCatalogueChapterDao.selectCount(new LambdaQueryWrapper<CourseCatalogueChapterEntity>().eq(CourseCatalogueChapterEntity::getCatalogueId, id));
|
||||
if(integer>0){
|
||||
return R.error(502,"删除失败,请先清空章节");
|
||||
}
|
||||
LambdaQueryWrapper<UserToCourseEntity> userToCourseEntityLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||
userToCourseEntityLambdaQueryWrapper.eq(UserToCourseEntity::getCatalogueId,id);
|
||||
userToCourseEntityLambdaQueryWrapper.gt(UserToCourseEntity::getEndTime,new Date());
|
||||
Integer integer1 = userToCourseDao.selectCount(userToCourseEntityLambdaQueryWrapper);
|
||||
if(integer1>0){
|
||||
return R.error(502,"删除失败,有人以购买此课程");
|
||||
}
|
||||
this.removeById(id);
|
||||
return R.ok();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -51,7 +51,7 @@ public class CourseServiceImpl extends ServiceImpl<CourseDao, CourseEntity> impl
|
||||
List<Integer> collect1 = courseToCategoryDao.selectList(new LambdaQueryWrapper<CourseToCategoryEntity>().in(CourseToCategoryEntity::getCategoryId, collect)).stream().map(CourseToCategoryEntity::getCourseId).collect(Collectors.toList());
|
||||
wrapper.in(collect1.size()>0,CourseEntity::getId,collect1);
|
||||
}else{
|
||||
return null;
|
||||
return new Page();
|
||||
}
|
||||
} else if (map.get("type").toString().equals("2")) {
|
||||
Integer sociologyId = Integer.valueOf(map.get("sociologyId").toString());
|
||||
@@ -65,10 +65,14 @@ public class CourseServiceImpl extends ServiceImpl<CourseDao, CourseEntity> impl
|
||||
List<Integer> collect = courseToSociologyDao.selectList(new LambdaQueryWrapper<CourseToSociologyEntity>().in(CourseToSociologyEntity::getSociologyId, c)).stream().map(CourseToSociologyEntity::getCourseId).collect(Collectors.toList());
|
||||
wrapper.in(collect.size()>0,CourseEntity::getId,collect);
|
||||
}else{
|
||||
return null;
|
||||
return new Page();
|
||||
}
|
||||
}
|
||||
wrapper.like(ObjectUtils.isNotBlank(map,"keywords"),CourseEntity::getTitle,map.get("keywords").toString());
|
||||
|
||||
if(ObjectUtils.isNotBlank(map,"keywords")){
|
||||
wrapper.like(CourseEntity::getTitle,map.get("keywords").toString());
|
||||
}
|
||||
|
||||
Page<CourseEntity> courseEntityPage = this.getBaseMapper().selectPage(new Page<>(page, limit), wrapper);
|
||||
for (CourseEntity c:courseEntityPage.getRecords()){
|
||||
List<CourseCatalogueEntity> courseCatalogueEntities = courseCatalogueDao.selectList(new LambdaQueryWrapper<CourseCatalogueEntity>().eq(CourseCatalogueEntity::getCourseId, c.getId()).orderByAsc(CourseCatalogueEntity::getSort));
|
||||
|
||||
Reference in New Issue
Block a user