AcademyCollegeDictServiceImpl.java
3.02 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
88
89
90
package com.subsidy.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.subsidy.common.exception.HttpException;
import com.subsidy.mapper.AcademyDictMapper;
import com.subsidy.mapper.AcademyMajorDictMapper;
import com.subsidy.mapper.MemberMapper;
import com.subsidy.model.AcademyCollegeDictDO;
import com.subsidy.mapper.AcademyCollegeDictMapper;
import com.subsidy.model.AcademyDictDO;
import com.subsidy.model.AcademyMajorDictDO;
import com.subsidy.model.MemberDO;
import com.subsidy.service.AcademyCollegeDictService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.subsidy.util.ConstantUtils;
import com.subsidy.vo.academy.AllAcademyMembersVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* <p>
* 学院字典表 服务实现类
* </p>
*
* @author Tuyp
* @since 2024-04-16
*/
@Service
public class AcademyCollegeDictServiceImpl extends ServiceImpl<AcademyCollegeDictMapper, AcademyCollegeDictDO> implements AcademyCollegeDictService {
@Autowired
private AcademyMajorDictMapper academyMajorDictMapper;
@Autowired
private MemberMapper memberMapper;
@Autowired
private AcademyDictMapper academyDictMapper;
public List<AcademyCollegeDictDO> allCollege(AcademyCollegeDictDO academyCollegeDictDO) {
return this.baseMapper.allCollege(academyCollegeDictDO.getAcademyId(),academyCollegeDictDO.getCollege());
}
public String addCollege(AcademyCollegeDictDO academyCollegeDictDO) {
int count = this.baseMapper.selectCount(new QueryWrapper<AcademyCollegeDictDO>()
.lambda()
.eq(AcademyCollegeDictDO::getAcademyId, academyCollegeDictDO.getCollege()));
if (count > 0) {
throw new HttpException(24001);
}
this.baseMapper.insert(academyCollegeDictDO);
return ConstantUtils.ADD_SUCCESS;
}
public String updateCollege(AcademyCollegeDictDO academyCollegeDictDO) {
int count = this.baseMapper.selectCount(new QueryWrapper<AcademyCollegeDictDO>()
.lambda()
.eq(AcademyCollegeDictDO::getAcademyId, academyCollegeDictDO.getCollege())
.ne(AcademyCollegeDictDO::getId, academyCollegeDictDO.getId()));
if (count > 0) {
throw new HttpException(24001);
}
this.baseMapper.updateById(academyCollegeDictDO);
return ConstantUtils.SUCCESS_UPDATE;
}
public String deleteCollege(AcademyCollegeDictDO academyCollegeDictDO) {
this.baseMapper.deleteById(academyCollegeDictDO.getId());
academyMajorDictMapper.delete(new QueryWrapper<AcademyMajorDictDO>()
.lambda()
.eq(AcademyMajorDictDO::getCollegeId, academyCollegeDictDO.getId()));
memberMapper.delete(new QueryWrapper<MemberDO>()
.lambda()
.eq(MemberDO::getCollegeId, academyCollegeDictDO.getId()));
return ConstantUtils.DELETE_SUCCESS;
}
}