ClassDictServiceImpl.java
3.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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
package com.subsidy.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.subsidy.dto.classDict.AddClassDTO;
import com.subsidy.dto.classDict.AddMemberToClassDTO;
import com.subsidy.dto.classDict.GetAllClassesDTO;
import com.subsidy.dto.classDict.GetSpareMembersDTO;
import com.subsidy.mapper.AdministerMapper;
import com.subsidy.mapper.ClassMemberMappingMapper;
import com.subsidy.mapper.RoleAdministerMappingMapper;
import com.subsidy.model.*;
import com.subsidy.mapper.ClassDictMapper;
import com.subsidy.service.ClassDictService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.subsidy.util.ConstantUtils;
import com.subsidy.vo.classdict.GetAllClassesVO;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.management.relation.Role;
import java.util.ArrayList;
import java.util.List;
/**
* <p>
* 班级id 服务实现类
* </p>
*
* @author DengMin
* @since 2021-10-12
*/
@Service
public class ClassDictServiceImpl extends ServiceImpl<ClassDictMapper, ClassDictDO> implements ClassDictService {
@Autowired
private ClassMemberMappingMapper classMemberMappingMapper;
@Autowired
private RoleAdministerMappingMapper roleAdministerMappingMapper;
public List<GetAllClassesVO> getAllClasses(ClassDictDO classDictDO) {
return this.baseMapper.getAllClasses(classDictDO);
}
@Transactional
public String deleteClasses(ClassDictDO classDictDO) {
this.baseMapper.deleteById(classDictDO.getId());
classMemberMappingMapper.delete(new QueryWrapper<ClassMemberMappingDO>()
.lambda()
.eq(ClassMemberMappingDO::getClassId, classDictDO.getId()));
return ConstantUtils.DELETE_SUCCESS;
}
public String addClass(AddClassDTO addClassDTO) {
//查看当前登录人的角色
int count = roleAdministerMappingMapper.selectCount(new QueryWrapper<RoleAdministerMappingDO>()
.lambda()
.eq(RoleAdministerMappingDO::getAdministerId,addClassDTO.getUserId())
.eq(RoleAdministerMappingDO::getRoleId,1));
ClassDictDO classDictDO = new ClassDictDO();
BeanUtils.copyProperties(addClassDTO,classDictDO);
if (count>0){
classDictDO.setClassType("平台支持");
}else{
classDictDO.setClassType("企业自荐");
}
this.baseMapper.insert(classDictDO);
return ConstantUtils.ADD_SUCCESS;
}
public String updateClass(ClassDictDO classDictDO) {
this.baseMapper.updateById(classDictDO);
return ConstantUtils.SET_SUCCESS;
}
public ClassDictDO classDetail(ClassDictDO classDictDO) {
return this.baseMapper.selectById(classDictDO.getId());
}
public String removeMember(ClassMemberMappingDO classMemberMappingDO) {
classMemberMappingMapper.delete(new QueryWrapper<ClassMemberMappingDO>()
.lambda()
.eq(ClassMemberMappingDO::getClassId, classMemberMappingDO.getClassId())
.eq(ClassMemberMappingDO::getMemberId, classMemberMappingDO.getMemberId()));
return ConstantUtils.DELETE_SUCCESS;
}
public List<MemberDO> getSpareMembers(GetSpareMembersDTO getSpareMembersDTO){
return this.baseMapper.getSpareMembers(getSpareMembersDTO);
}
public String addMemberToClass(AddMemberToClassDTO addMemberToClassDTO){
List<Long> memberIds = addMemberToClassDTO.getMemberIds();
for (Long lg : memberIds){
ClassMemberMappingDO classMemberMappingDO = new ClassMemberMappingDO();
classMemberMappingDO.setClassId(addMemberToClassDTO.getClassId());
classMemberMappingDO.setMemberId(lg);
classMemberMappingMapper.insert(classMemberMappingDO);
}
return ConstantUtils.ADD_SUCCESS;
}
}