From ad71bfb0df201d1b9b79b1bffe86a57e67775d83 Mon Sep 17 00:00:00 2001 From: joylink_zhangsai <1021828630@qq.com> Date: Mon, 29 Mar 2021 17:14:17 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=95=99=E5=AD=A6=E7=AE=A1?= =?UTF-8?q?=E7=90=86=E8=AF=BE=E7=A8=8B=E5=88=A0=E9=99=A4=E5=90=8E=E5=88=9B?= =?UTF-8?q?=E5=BB=BA=E5=90=8C=E5=90=8D=E8=AF=BE=E7=A8=8B=E4=BE=9D=E7=84=B6?= =?UTF-8?q?=E6=8A=A5=E9=94=99bug=EF=BC=9B=E4=BF=AE=E6=94=B9=E5=88=9B?= =?UTF-8?q?=E5=BB=BA=E8=AF=95=E5=8D=B7=E6=8A=A5=E9=94=99bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../training/TrainingV1Controller.java | 4 +- .../joylink/rtss/services/ExamService.java | 1 + .../joylink/rtss/services/ILessonService.java | 3 +- .../joylink/rtss/services/LessonService.java | 54 +++---------------- 4 files changed, 12 insertions(+), 50 deletions(-) diff --git a/src/main/java/club/joylink/rtss/controller/training/TrainingV1Controller.java b/src/main/java/club/joylink/rtss/controller/training/TrainingV1Controller.java index 654c8312a..f76da4e34 100644 --- a/src/main/java/club/joylink/rtss/controller/training/TrainingV1Controller.java +++ b/src/main/java/club/joylink/rtss/controller/training/TrainingV1Controller.java @@ -198,8 +198,8 @@ public class TrainingV1Controller { } @ApiOperation("查询实训、操作类型及数量") - @GetMapping("/trainingTypeAndQuantity/{mapId}") - public Map> queryTrainingTypeAndQuantity(@PathVariable Long mapId, String prdType) { + @GetMapping("/trainingTypeAndQuantity") + public Map> queryTrainingTypeAndQuantity(Long mapId, String prdType) { return iTrainingService.queryTrainingTypeAndQuantity(mapId, prdType); } } diff --git a/src/main/java/club/joylink/rtss/services/ExamService.java b/src/main/java/club/joylink/rtss/services/ExamService.java index 3b6a271af..47856d0fc 100644 --- a/src/main/java/club/joylink/rtss/services/ExamService.java +++ b/src/main/java/club/joylink/rtss/services/ExamService.java @@ -297,6 +297,7 @@ public class ExamService implements IExamService { } BusinessExceptionAssertEnum.INSUFFICIENT_PERMISSIONS.assertEquals(userVO.getId(), examDefinition.getCreatorId(), String.format("你不是试卷[%s]的创建者", examDefinition.getId())); + ExamDefinitionRulesExample example = new ExamDefinitionRulesExample(); example.createCriteria().andExamIdEqualTo(id); definitionRulesDAO.deleteByExample(example); diff --git a/src/main/java/club/joylink/rtss/services/ILessonService.java b/src/main/java/club/joylink/rtss/services/ILessonService.java index 3d68bff14..6afed4480 100644 --- a/src/main/java/club/joylink/rtss/services/ILessonService.java +++ b/src/main/java/club/joylink/rtss/services/ILessonService.java @@ -1,6 +1,7 @@ package club.joylink.rtss.services; import club.joylink.rtss.constants.Project; +import club.joylink.rtss.entity.LsLesson; import club.joylink.rtss.vo.LoginUserInfoVO; import club.joylink.rtss.vo.UserVO; import club.joylink.rtss.vo.client.*; @@ -42,7 +43,7 @@ public interface ILessonService { */ LessonVO getLessonInfo(Long id); - LessonVO findByMapAndNameAndPrdType(Long mapId, String name, String prdType); + LsLesson findEntity(long mapId, String name, String prdType, String status); LessonVO findSysFaultByMapAndPrdType(Long mapId, String prdType); diff --git a/src/main/java/club/joylink/rtss/services/LessonService.java b/src/main/java/club/joylink/rtss/services/LessonService.java index 4d7e02880..e793153a5 100644 --- a/src/main/java/club/joylink/rtss/services/LessonService.java +++ b/src/main/java/club/joylink/rtss/services/LessonService.java @@ -200,7 +200,7 @@ public class LessonService implements ILessonService { @Override @Transactional public void publish(LessonVO lessonVo, LessonPublishVO publishVO) { - LessonVO publishedLesson = this.findByMapAndNameAndPrdType(publishVO.getMapId(), publishVO.getName(), publishVO.getPrdType()); + LsLesson publishedLesson = this.findEntity(publishVO.getMapId(), publishVO.getName(), publishVO.getPrdType(), BusinessConsts.STATUS_USE); lessonVo.apply(publishVO); LsLesson newLesson = lessonVo.toPublic(); newLesson.setUpdateTime(LocalDateTime.now()); @@ -210,67 +210,29 @@ public class LessonService implements ILessonService { // 新发布 newLesson.setId(null); this.lessonDAO.insert(newLesson); - //存在班级条件就创建课程班级关系 - if (!CollectionUtils.isEmpty(publishVO.getClassIdList())) { - addRelLessonClass(publishVO, newLesson.getId()); - } - -// // 自动创建商品 -// iGoodsService.autoCreateTeachAndExamGoods(newLesson); } else { - //默认课程 -// MapVO mapVO = iMapService.findMapBaseInfoById(publishVO.getMapId()); -// BusinessConsts.Lesson.PrdInfo prdInfo = BusinessConsts.Lesson.PrdInfo.getBy(publishVO.getPrdType()); -// String defaultLessonName = String.join("-", mapVO.getName(), prdInfo.getName()); BusinessExceptionAssertEnum.DATA_UNIQUE_PROPERTY_REPEAT.assertTrue(publishVO.isCoverSameNameLesson(), "与已有课程同名,请修改名称"); - LessonVO sysFaultLesson = findSysFaultByMapAndPrdType(publishVO.getMapId(), publishVO.getPrdType()); - if (sysFaultLesson != null) { - BusinessExceptionAssertEnum.INVALID_OPERATION.assertNotTrue(Objects.equals(publishVO.getName(), sysFaultLesson.getName()), "与系统默认课程重名,请修改名称"); - } // 更新 newLesson.setId(publishedLesson.getId()); this.lessonDAO.updateByPrimaryKey(newLesson); - //课程存在,预备检查与班级的关系 - OrgLessonExample departmentLessonExample = new OrgLessonExample(); - departmentLessonExample.createCriteria().andLessonIdEqualTo(publishedLesson.getId()); - List departmentLessonRefs = this.departmentLessonDAO.selectByExample(departmentLessonExample); - if (!CollectionUtils.isEmpty(publishVO.getClassIdList())) { - if (!CollectionUtils.isEmpty(departmentLessonRefs)) { - List existedClassIds = departmentLessonRefs.stream().map(OrgLesson::getOrgId).collect(Collectors.toList()); - Collections.sort(existedClassIds); - Collections.sort(publishVO.getClassIdList()); - if (!existedClassIds.equals(publishVO.getClassIdList())) { - //清除现有课程班级关系 - this.departmentLessonDAO.deleteByExample(departmentLessonExample); - addRelLessonClass(publishVO, publishedLesson.getId()); - } - } else { - addRelLessonClass(publishVO, publishedLesson.getId()); - } - } else { - if (!CollectionUtils.isEmpty(departmentLessonRefs)) { - this.departmentLessonDAO.deleteByExample(departmentLessonExample); - } - } -// if(!lessonVo.getName().equals(publishedLesson.getName())) { -// // 自动创建商品 -// iGoodsService.autoUpdateTeachAndExamGoods(newLesson); -// } } this.buildAndInsertLessonVersion(newLesson); this.saveChapterDetail(newLesson, lessonVo); } @Override - public LessonVO findByMapAndNameAndPrdType(Long mapId, String name, String prdType) { + public LsLesson findEntity(long mapId, @NonNull String name, @NonNull String prdType, String status) { LsLessonExample lessonExample = new LsLessonExample(); - lessonExample.createCriteria().andMapIdEqualTo(mapId).andNameEqualTo(name).andPrdTypeEqualTo(prdType); + Criteria criteria = lessonExample.createCriteria().andMapIdEqualTo(mapId).andNameEqualTo(name).andPrdTypeEqualTo(prdType); + if (StringUtils.hasText(status)) { + criteria.andStatusEqualTo(status); + } List lessonList = this.lessonDAO.selectByExample(lessonExample); if (CollectionUtils.isEmpty(lessonList)) { return null; } - return new LessonVO(lessonList.get(0)); + return lessonList.get(0); } @Override @@ -358,8 +320,6 @@ public class LessonService implements ILessonService { this.userTrainingStatsMapper.deleteByExample(userTrainingExample); lessonDAO.deleteByPrimaryKey(lessonId); -// // 自动删除关联商品 -// this.iGoodsService.autoDeleteTeachAndExamGoods(lsLesson.getCode()); } /**