CourseContentServiceImpl.java
2.24 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
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.stereotype.Service;
import java.util.List;
/**
* <p>
* 课程目录表 服务实现类
* </p>
*
* @author DengMin
* @since 2021-10-11
*/
@Service
public class CourseContentServiceImpl extends ServiceImpl<CourseContentMapper, CourseContentDO> implements CourseContentService {
@Override
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));
}
@Override
public String deleteContent(CourseContentDO courseContentDO){
this.baseMapper.deleteById(courseContentDO.getId());
return ConstantUtils.DELETE_SUCCESS;
}
@Override
public String addContent(CourseContentDO courseContentDO){
Integer orderNoTmp = this.baseMapper.selectMaxOrderNo(courseContentDO.getCourseId());
int orderNo = 1 ;
if (null!=orderNoTmp){
orderNo = orderNoTmp+1;
}
courseContentDO.setOrderNo(orderNo);
this.baseMapper.insert(courseContentDO);
return ConstantUtils.ADD_SUCCESS;
}
@Override
public String updateContent(CourseContentDO courseContentDO){
int count = this.baseMapper.selectCount(new QueryWrapper<CourseContentDO>()
.lambda()
.eq(CourseContentDO::getCourseId,courseContentDO.getCourseId())
.eq(CourseContentDO::getContent,courseContentDO.getContent())
.ne(CourseContentDO::getId,courseContentDO.getId()));
if (count>0){
throw new HttpException(40001);
}
this.baseMapper.updateById(courseContentDO);
return ConstantUtils.SET_SUCCESS;
}
}