修改教学管理课程删除后创建同名课程依然报错bug;修改创建试卷报错bug
This commit is contained in:
parent
038f3b3ecd
commit
ad71bfb0df
@ -198,8 +198,8 @@ public class TrainingV1Controller {
|
||||
}
|
||||
|
||||
@ApiOperation("查询实训、操作类型及数量")
|
||||
@GetMapping("/trainingTypeAndQuantity/{mapId}")
|
||||
public Map<String, Map<String, Long>> queryTrainingTypeAndQuantity(@PathVariable Long mapId, String prdType) {
|
||||
@GetMapping("/trainingTypeAndQuantity")
|
||||
public Map<String, Map<String, Long>> queryTrainingTypeAndQuantity(Long mapId, String prdType) {
|
||||
return iTrainingService.queryTrainingTypeAndQuantity(mapId, prdType);
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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<OrgLesson> departmentLessonRefs = this.departmentLessonDAO.selectByExample(departmentLessonExample);
|
||||
if (!CollectionUtils.isEmpty(publishVO.getClassIdList())) {
|
||||
if (!CollectionUtils.isEmpty(departmentLessonRefs)) {
|
||||
List<Long> 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<LsLesson> 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());
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user