课程名修改添加同名校验;评价规则应用到sql修改

This commit is contained in:
joylink_zhangsai 2021-03-29 18:19:23 +08:00
parent ad71bfb0df
commit a658bd7312
5 changed files with 15 additions and 10 deletions

View File

@ -23,7 +23,6 @@ import org.springframework.util.StringUtils;
import java.time.LocalDateTime;
import java.util.*;
import java.util.Map.Entry;
import java.util.function.Function;
import java.util.stream.Collectors;
@ -83,7 +82,7 @@ public class ExamService implements IExamService {
//检查分数是否合理
BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertTrue(checkScore(examDefinitionVO));
//检查考试名称是否唯一
confirmNameUnique(null, examDefinitionVO.getMapId(), examDefinitionVO.getPrdType(), examDefinitionVO.getName());
confirmNameUnique(null, examDefinitionVO.getMapId(), examDefinitionVO.getPrdType(), examDefinitionVO.getName(), BusinessConsts.STATUS_USE);
//插入考试定义表数据
ExamDefinition examDefinition = examDefinitionVO.toDB();
examDefinition.setCreatorId(userVO.getId());
@ -107,8 +106,9 @@ public class ExamService implements IExamService {
* 确认名称唯一
*
* @param id 试卷的id更新时检查名称重复需要去掉自己
* @param status
*/
private void confirmNameUnique(Long id, long mapId, @NonNull String type, @NonNull String name) {
private void confirmNameUnique(Long id, long mapId, @NonNull String type, @NonNull String name, String status) {
// //一个课程下考试名称查重
// ExamDefinitionExample examDefinitionExample = new ExamDefinitionExample();
// examDefinitionExample.createCriteria().andLessonIdEqualTo(examDefinitionVO.getLessonId()).andNameEqualTo(examDefinitionVO.getName());
@ -387,7 +387,7 @@ public class ExamService implements IExamService {
ExamDefinition examDefinition = this.examDefinitionDAO.selectByPrimaryKey(id);
BusinessExceptionAssertEnum.DATA_NOT_EXIST.assertNotNull(examDefinition);
//考试名称查重
confirmNameUnique(examDefinition.getId(), examDefinition.getMapId(), examDefinition.getType(), examDefinitionVO.getName());
confirmNameUnique(examDefinition.getId(), examDefinition.getMapId(), examDefinition.getType(), examDefinitionVO.getName(), BusinessConsts.STATUS_USE);
examDefinition.setName(examDefinitionVO.getName());
examDefinition.setTrial(examDefinitionVO.getTrial());
examDefinition.setStartTime(examDefinitionVO.getStartTime());

View File

@ -395,6 +395,9 @@ public class LessonService implements ILessonService {
public void updateNameAndRemarks(Long id, String name, String remarks, UserVO user) {
LsLesson lesson = this.lessonDAO.selectByPrimaryKey(id);
if (Objects.nonNull(lesson)) {
LsLesson sameNameLesson = findEntity(lesson.getMapId(), name, lesson.getPrdType(), BusinessConsts.STATUS_USE);
BusinessExceptionAssertEnum.DATA_UNIQUE_PROPERTY_REPEAT.assertTrue(sameNameLesson == null || !sameNameLesson.getId().equals(lesson.getId()),
"名称重复");
lesson.setName(name);
lesson.setRemarks(remarks);
this.lessonDAO.updateByPrimaryKey(lesson);

View File

@ -78,10 +78,12 @@ public class UserExamService implements IUserExamService {
groupSimulationService.confirmHasPermission(userVO, examDef.getMapId(), examDef.getType());
}
// 判断是否在考试时间之内
LocalDateTime now = LocalDateTime.now();
if (examDef.getStartTime() != null) {
LocalDateTime now = LocalDateTime.now();
BusinessExceptionAssertEnum.OPERATION_NOT_SUPPORTED.assertTrue(now.isAfter(examDef.getStartTime()) && now.isBefore(examDef.getEndTime()),
"考试已经结束");
BusinessExceptionAssertEnum.OPERATION_NOT_SUPPORTED.assertTrue(now.isAfter(examDef.getStartTime()), "考试尚未开始");
}
if (examDef.getEndTime() != null) {
BusinessExceptionAssertEnum.OPERATION_NOT_SUPPORTED.assertTrue(now.isBefore(examDef.getEndTime()), "考试已经结束");
}
// 保存用户考试信息
UserExam userExam = new UserExam();

View File

@ -215,7 +215,7 @@ public class OrgScoringRuleService implements IOrgScoringRuleService {
OrgScoringRuleRel rel = new OrgScoringRuleRel();
rel.setOrgId(orgId);
rel.setRuleId(ruleId);
rel.setRuleOrgId(rule.getId());
rel.setRuleOrgId(rule.getOrgId());
rel.setRuleSchoolYear(rule.getSchoolYear());
rel.setRuleTerm(rule.getTerm());
rel.setRuleCreatorId(rule.getCreatorId());

View File

@ -195,10 +195,10 @@
</update>
<!-- 自定义 -->
<insert id="batchInsert">
insert into org_scoring_rule_rel (org_id, rule_id)
insert into org_scoring_rule_rel (org_id, rule_id, rule_org_id, rule_school_year, rule_term, rule_creator_id)
values
<foreach collection="rels" item="rel" separator=",">
(#{rel.orgId}, #{rel.ruleId})
(#{rel.orgId}, #{rel.ruleId}, #{rel.ruleOrgId}, #{rel.ruleSchoolYear}, #{rel.ruleTerm}, #{rel.ruleCreatorId})
</foreach>
</insert>
</mapper>