zhangf
2024-07-24 790c2ba4a0b46edf191e3bac84931f796bd42b8f
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
88
89
90
package com.gkhy.exam.institutionalaccess.service.serviceImpl;
 
import cn.hutool.core.collection.ListUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gkhy.exam.institutionalaccess.entity.ThBatchCourse;
import com.gkhy.exam.institutionalaccess.mapper.ThBatchCourseMapper;
import com.gkhy.exam.institutionalaccess.model.vo.ThBatchCourseVO;
import com.gkhy.exam.institutionalaccess.service.ThBatchCourseService;
import com.ruoyi.common.enums.coalmineEnums.DeleteStatusEnum;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
 
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;
 
@Service("ThBatchCourseService")
public class ThBatchCourseServiceImpl extends ServiceImpl<ThBatchCourseMapper, ThBatchCourse> implements ThBatchCourseService {
    @Autowired
    private ThBatchCourseMapper batchCourseMapper;
    @Override
    public List<ThBatchCourse> getByBatchUuid(String batchUuid) {
        List<ThBatchCourse> batchCourseList = batchCourseMapper.selectList(new LambdaQueryWrapper<ThBatchCourse>().eq(ThBatchCourse::getBatchUuid,batchUuid)
                .eq(ThBatchCourse::getDelFlag, DeleteStatusEnum.NO.getStatus()));
        return batchCourseList;
    }
    public List<String> getCourseUuisByBatchUuid(String batchUuid){
        List<String> courseUuis = new ArrayList<String>();
        List<ThBatchCourse> list = this.getByBatchUuid(batchUuid);
        if(!CollectionUtils.isEmpty(list)){
           courseUuis = list.stream().map(ThBatchCourse::getCourseUuid).collect(Collectors.toList());
        }
 
        return courseUuis;
    }
 
    @Override
    public void deleteByBatchUuidAndCourseUuid(List<ThBatchCourse> deleteBatchCourseList) {
        batchCourseMapper.deleteByBatchUuidAndCourseUuid(deleteBatchCourseList);
    }
 
    @Override
    public List<ThBatchCourse> getListByBatchUuids(List<String> batchUuids) {
        List<ThBatchCourse> allBatchCourseList = new ArrayList<>();
        List<List<String>> split = ListUtil.split(batchUuids, 900);
        for (List<String> list : split) {
            List<ThBatchCourse> thBatchCourseList = batchCourseMapper.getByBatchUuids(list);
            allBatchCourseList.addAll(thBatchCourseList);
        }
        return allBatchCourseList;
    }
    @Override
    public List<ThBatchCourseVO> getListByBatchUuid(String batchUuid) {
        List<ThBatchCourseVO> thBatchCourseVOS = batchCourseMapper.getListByBatchUuid(batchUuid);
        return thBatchCourseVOS;
    }
 
    @Override
    public boolean isExsit(String courseUuid) {
        Long count = batchCourseMapper.selectCount(new LambdaQueryWrapper<ThBatchCourse>().eq(ThBatchCourse::getCourseUuid,courseUuid).eq(ThBatchCourse::getDelFlag, DeleteStatusEnum.NO.getStatus()));
        if(count > 0){
            return true;
        }
        return false;
    }
 
    @Override
    public List<ThBatchCourse> listByInstitutionId(Long institutionId) {
        return batchCourseMapper.selectList(new LambdaQueryWrapper<ThBatchCourse>()
                .eq(ThBatchCourse::getInstitutionId,institutionId).eq(ThBatchCourse::getDelFlag,DeleteStatusEnum.NO.getStatus()));
    }
 
    @Override
    public void deleteByBatchUuid(String batchUuid) {
        batchCourseMapper.deleteByBatchUuid(batchUuid);
    }
 
    @Override
    public Integer insertBatch(List<ThBatchCourse> courseList) {
        return batchCourseMapper.insertBatch(courseList);
    }
 
    @Override
    public Integer updateBatch(List<ThBatchCourse> courseList) {
        return batchCourseMapper.updateBatch(courseList);
    }
}