SubjectTestPublishGradeServiceImpl.java
8.6 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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
package com.meishu.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.meishu.dto.grade.AddGradeDTO;
import com.meishu.mapper.SubjectTestGradeExampleMappingMapper;
import com.meishu.mapper.SubjectTestGradeStarMappingMapper;
import com.meishu.model.SubjectRuleDO;
import com.meishu.model.SubjectTestGradeExampleMappingDO;
import com.meishu.model.SubjectTestGradeStarMappingDO;
import com.meishu.model.SubjectTestPublishGradeDO;
import com.meishu.mapper.SubjectTestPublishGradeMapper;
import com.meishu.service.SubjectTestPublishGradeService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.meishu.util.ConstantUtils;
import com.meishu.vo.grade.DimensionStarVO;
import com.meishu.vo.grade.QueryOneGradeVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.ExecutionException;
/**
* <p>
* 档次表 服务实现类
* </p>
*
* @author Tuyp
* @since 2021-06-21
*/
@Service
public class SubjectTestPublishGradeServiceImpl extends ServiceImpl<SubjectTestPublishGradeMapper, SubjectTestPublishGradeDO> implements SubjectTestPublishGradeService {
@Autowired
private SubjectTestGradeExampleMappingMapper subjectTestGradeExampleMappingMapper;
@Autowired
private SubjectTestGradeStarMappingMapper subjectTestGradeStarMappingMapper;
@Transactional(rollbackFor = Exception.class)
public String addGrade(AddGradeDTO addGradeDTO){
String gradeName = addGradeDTO.getGradeName();
SubjectTestPublishGradeDO subjectTestPublishGradeDO = new SubjectTestPublishGradeDO();
subjectTestPublishGradeDO.setGradeName(gradeName);
subjectTestPublishGradeDO.setPublishId(addGradeDTO.getPublishId());
subjectTestPublishGradeDO.setContent(addGradeDTO.getContent());
this.baseMapper.insert(subjectTestPublishGradeDO);
//样卷
List<String> subjectTestGradeExampleMappingDOS = addGradeDTO.getSubjectTestGradeExampleMappingDOS();
for (String str : subjectTestGradeExampleMappingDOS){
SubjectTestGradeExampleMappingDO subjectTestGradeExampleMappingDO = new SubjectTestGradeExampleMappingDO();
subjectTestGradeExampleMappingDO.setExampleView(str);
subjectTestGradeExampleMappingDO.setGradeId(subjectTestPublishGradeDO.getId());
subjectTestGradeExampleMappingMapper.insert(subjectTestGradeExampleMappingDO);
}
//星级映射
List<Long> subjectTestGradeStarMappingDOS = addGradeDTO.getSubjectTestGradeStarMappingDOS();
for (Long lg : subjectTestGradeStarMappingDOS){
SubjectTestGradeStarMappingDO subjectTestGradeStarMappingDO = new SubjectTestGradeStarMappingDO();
subjectTestGradeStarMappingDO.setStarId(lg);
subjectTestGradeStarMappingDO.setGradeId(subjectTestPublishGradeDO.getId());
subjectTestGradeStarMappingMapper.insert(subjectTestGradeStarMappingDO);
}
return ConstantUtils.ADD_SUCCESS;
}
@Transactional(rollbackFor = Exception.class)
public String deleteGrade(SubjectTestPublishGradeDO subjectTestPublishGradeDO){
this.baseMapper.deleteById(subjectTestPublishGradeDO.getId());
subjectTestGradeStarMappingMapper.delete(new QueryWrapper<SubjectTestGradeStarMappingDO>()
.lambda()
.eq(SubjectTestGradeStarMappingDO::getGradeId,subjectTestPublishGradeDO.getId()));
subjectTestGradeExampleMappingMapper.delete(new QueryWrapper<SubjectTestGradeExampleMappingDO>()
.lambda()
.eq(SubjectTestGradeExampleMappingDO::getGradeId,subjectTestPublishGradeDO.getId()));
return ConstantUtils.DELETE_SUCCESS;
}
public List<QueryOneGradeVO> queryGrade(SubjectTestPublishGradeDO subjectTestPublishGradeDO){
List<QueryOneGradeVO> queryOneGradeVOS = new ArrayList<>();
List<SubjectTestPublishGradeDO> subjectTestPublishGradeDOS = this.baseMapper.selectList(new QueryWrapper<SubjectTestPublishGradeDO>()
.lambda()
.eq(SubjectTestPublishGradeDO::getPublishId,subjectTestPublishGradeDO.getId()));
for (SubjectTestPublishGradeDO subjectTestPublishGradeDO1 : subjectTestPublishGradeDOS){
QueryOneGradeVO queryOneGradeVO = new QueryOneGradeVO();
queryOneGradeVO.setGradeName(subjectTestPublishGradeDO1.getGradeName());
queryOneGradeVO.setId(subjectTestPublishGradeDO1.getId());
queryOneGradeVO.setContent(subjectTestPublishGradeDO1.getContent());
//样卷
List<SubjectTestGradeExampleMappingDO> subjectTestGradeExampleMappingDOS = subjectTestGradeExampleMappingMapper.selectList(new QueryWrapper<SubjectTestGradeExampleMappingDO>()
.lambda()
.eq(SubjectTestGradeExampleMappingDO::getGradeId,subjectTestPublishGradeDO1.getId()));
queryOneGradeVO.setSubjectTestGradeExampleMappingDOS(subjectTestGradeExampleMappingDOS);
//星级
List<DimensionStarVO> dimensionStarVOS = subjectTestGradeStarMappingMapper.getGradeStar(subjectTestPublishGradeDO1.getId());
queryOneGradeVO.setDimensionStarVOS(dimensionStarVOS);
queryOneGradeVOS.add(queryOneGradeVO);
}
return queryOneGradeVOS;
}
public QueryOneGradeVO queryOneGrade(SubjectTestPublishGradeDO subjectTestPublishGradeDO){
QueryOneGradeVO queryOneGradeVO = new QueryOneGradeVO();
//档次
SubjectTestPublishGradeDO subjectTestPublishGradeDO1 = this.baseMapper.selectById(subjectTestPublishGradeDO.getId());
queryOneGradeVO.setGradeName(subjectTestPublishGradeDO1.getGradeName());
//样卷
List<SubjectTestGradeExampleMappingDO> subjectTestGradeExampleMappingDOS = subjectTestGradeExampleMappingMapper.selectList(new QueryWrapper<SubjectTestGradeExampleMappingDO>()
.lambda()
.eq(SubjectTestGradeExampleMappingDO::getGradeId,subjectTestPublishGradeDO.getId()));
queryOneGradeVO.setSubjectTestGradeExampleMappingDOS(subjectTestGradeExampleMappingDOS);
//星级
List<DimensionStarVO> dimensionStarVOS = subjectTestGradeStarMappingMapper.getGradeStar(subjectTestPublishGradeDO.getId());
queryOneGradeVO.setDimensionStarVOS(dimensionStarVOS);
return queryOneGradeVO;
}
public String updateGrade(AddGradeDTO addGradeDTO){
SubjectTestPublishGradeDO subjectTestPublishGradeDO = this.baseMapper.selectById(addGradeDTO.getId());
subjectTestPublishGradeDO.setGradeName(addGradeDTO.getGradeName());
subjectTestPublishGradeDO.setPublishId(addGradeDTO.getPublishId());
subjectTestPublishGradeDO.setContent(addGradeDTO.getContent());
this.baseMapper.updateById(subjectTestPublishGradeDO);
//样卷
subjectTestGradeExampleMappingMapper.delete(new QueryWrapper<SubjectTestGradeExampleMappingDO>()
.lambda()
.eq(SubjectTestGradeExampleMappingDO::getGradeId,addGradeDTO.getId()));
//样卷
List<String> subjectTestGradeExampleMappingDOS = addGradeDTO.getSubjectTestGradeExampleMappingDOS();
for (String str : subjectTestGradeExampleMappingDOS){
SubjectTestGradeExampleMappingDO subjectTestGradeExampleMappingDO = new SubjectTestGradeExampleMappingDO();
subjectTestGradeExampleMappingDO.setExampleView(str);
subjectTestGradeExampleMappingDO.setGradeId(subjectTestPublishGradeDO.getId());
subjectTestGradeExampleMappingMapper.insert(subjectTestGradeExampleMappingDO);
}
//星级映射
subjectTestGradeStarMappingMapper.delete(new QueryWrapper<SubjectTestGradeStarMappingDO>()
.lambda()
.eq(SubjectTestGradeStarMappingDO::getGradeId,addGradeDTO.getId()));
//星级映射
List<Long> subjectTestGradeStarMappingDOS = addGradeDTO.getSubjectTestGradeStarMappingDOS();
for (Long lg : subjectTestGradeStarMappingDOS){
SubjectTestGradeStarMappingDO subjectTestGradeStarMappingDO = new SubjectTestGradeStarMappingDO();
subjectTestGradeStarMappingDO.setStarId(lg);
subjectTestGradeStarMappingDO.setGradeId(subjectTestPublishGradeDO.getId());
subjectTestGradeStarMappingMapper.insert(subjectTestGradeStarMappingDO);
}
return ConstantUtils.SUCCESS_UPDATE;
}
public SubjectRuleDO getRuleIdByPublishId(SubjectTestPublishGradeDO subjectTestPublishGradeDO){
return subjectTestGradeStarMappingMapper.getRuleIdByPublishId(subjectTestPublishGradeDO.getPublishId());
}
}