CourseDictServiceImpl.java
2.99 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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
package com.zhongzhi.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.zhongzhi.dao.YearDictDAO;
import com.zhongzhi.dto.course.CoursesDTO;
import com.zhongzhi.dao.VodDictDAO;
import com.zhongzhi.model.CourseDictDO;
import com.zhongzhi.dao.CourseDictDAO;
import com.zhongzhi.model.VodDictDO;
import com.zhongzhi.model.YearDictDO;
import com.zhongzhi.service.CourseDictService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.zhongzhi.vo.course.CourseVodsVO;
import com.zhongzhi.vo.course.CoursesVO;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;
/**
* <p>
* 服务实现类
* </p>
*
* @author DengMin
* @since 2022-11-14
*/
@Service
public class CourseDictServiceImpl extends ServiceImpl<CourseDictDAO, CourseDictDO> implements CourseDictService {
@Autowired
private VodDictDAO vodDictMapper;
@Autowired
private YearDictDAO yearDictDAO;
public void addCourse(CourseDictDO courseDictDO) {
this.baseMapper.insert(courseDictDO);
}
public void updateCourse(CourseDictDO courseDictDO) {
this.updateById(courseDictDO);
}
public IPage<CoursesVO> courses(CoursesDTO coursesDTO) {
Page page = new Page(coursesDTO.getPageNo(), coursesDTO.getPageSize());
return this.baseMapper.courses(page, coursesDTO.getCourseName(),coursesDTO.getYearId());
}
public void deleteCourse(CourseDictDO courseDictDO) {
this.baseMapper.deleteById(courseDictDO.getId());
//删除视频
vodDictMapper.delete(new QueryWrapper<VodDictDO>()
.lambda()
.eq(VodDictDO::getCourseId, courseDictDO.getId()));
}
public List<CourseVodsVO> courseVods(CourseDictDO courseDictDO) {
List<CourseVodsVO> courseVodsVOS = new ArrayList<>();
YearDictDO yearDictDO = yearDictDAO.selectById(courseDictDO.getYearId());
if ("1".equals(yearDictDO.getStatus())){
List<CourseDictDO> courseDictDOS = this.baseMapper.selectList(new QueryWrapper<CourseDictDO>()
.lambda()
.eq(CourseDictDO::getYearId,courseDictDO.getYearId()));
for (CourseDictDO cdd : courseDictDOS) {
CourseVodsVO courseVodsVO = new CourseVodsVO();
BeanUtils.copyProperties(cdd, courseVodsVO);
List<VodDictDO> vodDictDOS = vodDictMapper.selectList(new QueryWrapper<VodDictDO>()
.lambda()
.eq(VodDictDO::getCourseId,cdd.getId())
.orderByAsc(VodDictDO::getOrderNo));
courseVodsVO.setVodDictDOS(vodDictDOS);
courseVodsVOS.add(courseVodsVO);
}
}
return courseVodsVOS;
}
}