From a658bd73120493e4450899872f27f46f5ca31c23 Mon Sep 17 00:00:00 2001 From: joylink_zhangsai <1021828630@qq.com> Date: Mon, 29 Mar 2021 18:19:23 +0800 Subject: [PATCH] =?UTF-8?q?=E8=AF=BE=E7=A8=8B=E5=90=8D=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=90=8C=E5=90=8D=E6=A0=A1=E9=AA=8C=EF=BC=9B?= =?UTF-8?q?=E8=AF=84=E4=BB=B7=E8=A7=84=E5=88=99=E5=BA=94=E7=94=A8=E5=88=B0?= =?UTF-8?q?sql=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/club/joylink/rtss/services/ExamService.java | 8 ++++---- .../java/club/joylink/rtss/services/LessonService.java | 3 +++ .../java/club/joylink/rtss/services/UserExamService.java | 8 +++++--- .../joylink/rtss/services/org/OrgScoringRuleService.java | 2 +- .../resources/mybatis/mapper/OrgScoringRuleRelDAO.xml | 4 ++-- 5 files changed, 15 insertions(+), 10 deletions(-) diff --git a/src/main/java/club/joylink/rtss/services/ExamService.java b/src/main/java/club/joylink/rtss/services/ExamService.java index 47856d0fc..b1c12bd0d 100644 --- a/src/main/java/club/joylink/rtss/services/ExamService.java +++ b/src/main/java/club/joylink/rtss/services/ExamService.java @@ -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()); diff --git a/src/main/java/club/joylink/rtss/services/LessonService.java b/src/main/java/club/joylink/rtss/services/LessonService.java index e793153a5..2732c345d 100644 --- a/src/main/java/club/joylink/rtss/services/LessonService.java +++ b/src/main/java/club/joylink/rtss/services/LessonService.java @@ -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); diff --git a/src/main/java/club/joylink/rtss/services/UserExamService.java b/src/main/java/club/joylink/rtss/services/UserExamService.java index defe1aaf5..aa61eeb0e 100644 --- a/src/main/java/club/joylink/rtss/services/UserExamService.java +++ b/src/main/java/club/joylink/rtss/services/UserExamService.java @@ -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(); diff --git a/src/main/java/club/joylink/rtss/services/org/OrgScoringRuleService.java b/src/main/java/club/joylink/rtss/services/org/OrgScoringRuleService.java index 33746b7e1..656998b31 100644 --- a/src/main/java/club/joylink/rtss/services/org/OrgScoringRuleService.java +++ b/src/main/java/club/joylink/rtss/services/org/OrgScoringRuleService.java @@ -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()); diff --git a/src/main/resources/mybatis/mapper/OrgScoringRuleRelDAO.xml b/src/main/resources/mybatis/mapper/OrgScoringRuleRelDAO.xml index 06c447a47..c7376e0f5 100644 --- a/src/main/resources/mybatis/mapper/OrgScoringRuleRelDAO.xml +++ b/src/main/resources/mybatis/mapper/OrgScoringRuleRelDAO.xml @@ -195,10 +195,10 @@ - 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 - (#{rel.orgId}, #{rel.ruleId}) + (#{rel.orgId}, #{rel.ruleId}, #{rel.ruleOrgId}, #{rel.ruleSchoolYear}, #{rel.ruleTerm}, #{rel.ruleCreatorId})