CourseContentServiceImpl.java
2.45 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
package com.subsidy.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.subsidy.common.exception.HttpException;
import com.subsidy.mapper.CourseContentMapper;
import com.subsidy.model.CourseContentDO;
import com.subsidy.service.CourseContentService;
import com.subsidy.util.ConstantUtils;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* <p>
* 课程目录表 服务实现类
* </p>
*
* @author DengMin
* @since 2021-10-11
*/
@Service
public class CourseContentServiceImpl extends ServiceImpl<CourseContentMapper, CourseContentDO> implements CourseContentService {
public List<CourseContentDO> getContents(CourseContentDO courseContentDO) {
return this.baseMapper.selectList(new QueryWrapper<CourseContentDO>()
.lambda()
.eq(CourseContentDO::getCourseId, courseContentDO.getCourseId())
.orderByAsc(CourseContentDO::getOrderNo)
.orderByAsc(CourseContentDO::getCreateDate));
}
@Async
public String deleteContent(CourseContentDO courseContentDO){
this.baseMapper.deleteById(courseContentDO.getId());
return ConstantUtils.DELETE_SUCCESS;
}
@Async
public String addContent(CourseContentDO courseContentDO){
List<CourseContentDO> courseContentDOS = this.baseMapper.selectList(new QueryWrapper<CourseContentDO>()
.lambda()
.eq(CourseContentDO::getCourseId,courseContentDO.getCourseId())
.orderByDesc(CourseContentDO::getOrderNo));
int orderNo = 1 ;
if (courseContentDOS.size()>0){
orderNo = courseContentDOS.get(0).getOrderNo()+1;
}
courseContentDO.setOrderNo(orderNo);
this.baseMapper.insert(courseContentDO);
return ConstantUtils.ADD_SUCCESS;
}
@Async
public String updateContent(CourseContentDO courseContentDO){
List<CourseContentDO> courseContentDOS = this.baseMapper.selectList(new QueryWrapper<CourseContentDO>()
.lambda()
.eq(CourseContentDO::getCourseId,courseContentDO.getCourseId())
.eq(CourseContentDO::getContent,courseContentDO.getContent()));
if (courseContentDOS.size()>0){
throw new HttpException(40001);
}
this.baseMapper.updateById(courseContentDO);
return ConstantUtils.SET_SUCCESS;
}
}