diff --git a/src/main/java/club/joylink/rtss/controller/RunPlanDraftController.java b/src/main/java/club/joylink/rtss/controller/RunPlanDraftController.java index 6c1b02a8c..7099cad99 100644 --- a/src/main/java/club/joylink/rtss/controller/RunPlanDraftController.java +++ b/src/main/java/club/joylink/rtss/controller/RunPlanDraftController.java @@ -3,15 +3,13 @@ package club.joylink.rtss.controller; import club.joylink.rtss.constants.RoleEnum; import club.joylink.rtss.controller.advice.AuthenticateInterceptor; import club.joylink.rtss.controller.advice.Role; +import club.joylink.rtss.runplan.newdraw.RunPlanInput; import club.joylink.rtss.services.IRunPlanDraftService; import club.joylink.rtss.vo.LoginUserInfoVO; import club.joylink.rtss.vo.UserVO; -import club.joylink.rtss.vo.client.map.MapRoutingSectionVO; -import club.joylink.rtss.vo.client.map.MapRoutingVO; import club.joylink.rtss.vo.client.map.newmap.MapStationParkingTimeVO; import club.joylink.rtss.vo.client.map.newmap.MapStationRunLevelVO; import club.joylink.rtss.vo.client.runplan.*; -import club.joylink.rtss.runplan.newdraw.RunPlanInput; import club.joylink.rtss.vo.client.validGroup.RunPlanCreateCheck; import club.joylink.rtss.vo.client.validGroup.RunPlanNameCheck; import club.joylink.rtss.vo.client.validGroup.ValidList; diff --git a/src/main/java/club/joylink/rtss/controller/ScriptController.java b/src/main/java/club/joylink/rtss/controller/ScriptController.java index d99f68d3f..c72677966 100644 --- a/src/main/java/club/joylink/rtss/controller/ScriptController.java +++ b/src/main/java/club/joylink/rtss/controller/ScriptController.java @@ -3,7 +3,6 @@ package club.joylink.rtss.controller; import club.joylink.rtss.services.IScriptService; import club.joylink.rtss.vo.client.PageVO; import club.joylink.rtss.vo.client.script.ScriptQueryVO; -import club.joylink.rtss.vo.client.script.ScriptVO; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.springframework.beans.factory.annotation.Autowired; diff --git a/src/main/java/club/joylink/rtss/controller/ScriptDraftController.java b/src/main/java/club/joylink/rtss/controller/ScriptDraftController.java index 1ed78bf1c..36fc57116 100644 --- a/src/main/java/club/joylink/rtss/controller/ScriptDraftController.java +++ b/src/main/java/club/joylink/rtss/controller/ScriptDraftController.java @@ -6,7 +6,6 @@ import club.joylink.rtss.services.IScriptDraftService; import club.joylink.rtss.vo.UserVO; import club.joylink.rtss.vo.client.PageQueryVO; import club.joylink.rtss.vo.client.PageVO; -import club.joylink.rtss.vo.client.script.ScriptNewVO; import club.joylink.rtss.vo.client.script.ScriptVO; import club.joylink.rtss.vo.client.validGroup.ScriptCreateCheck; import io.swagger.annotations.Api; @@ -40,7 +39,7 @@ public class ScriptDraftController { @ApiOperation(value = "通过id查询剧本基础信息") @GetMapping(path = "/{id}") - public ScriptNewVO getBasicInfoById(@PathVariable Long id) { + public ScriptVO getBasicInfoById(@PathVariable Long id) { return iScriptDraftService.getBasicInfo(id); } diff --git a/src/main/java/club/joylink/rtss/controller/script/ScriptController2.java b/src/main/java/club/joylink/rtss/controller/script/ScriptController2.java index c861807ff..554eb9e76 100644 --- a/src/main/java/club/joylink/rtss/controller/script/ScriptController2.java +++ b/src/main/java/club/joylink/rtss/controller/script/ScriptController2.java @@ -2,7 +2,7 @@ package club.joylink.rtss.controller.script; import club.joylink.rtss.services.script.IScriptService2; import club.joylink.rtss.vo.client.PageVO; -import club.joylink.rtss.vo.client.script.ScriptNewVO; +import club.joylink.rtss.vo.client.script.ScriptVO; import club.joylink.rtss.vo.client.script.ScriptQueryVO; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; @@ -23,13 +23,13 @@ public class ScriptController2 { @ApiOperation(value = "分页查询上线的剧本") @GetMapping(path = "/paging/online") - public PageVO pagingQueryOnlineScript(ScriptQueryVO scriptQueryVO) { + public PageVO pagingQueryOnlineScript(ScriptQueryVO scriptQueryVO) { return iScriptService2.pagingQueryOnlineScript(scriptQueryVO); } @ApiOperation(value = "通过id查询剧本详细信息") @GetMapping(path = "/{id}/detail") - public ScriptNewVO getDetailInfoById(@PathVariable @NotNull Long id) { + public ScriptVO getDetailInfoById(@PathVariable @NotNull Long id) { return iScriptService2.getDetailForClientById(id); } } diff --git a/src/main/java/club/joylink/rtss/controller/simulation/ScriptSimulationController.java b/src/main/java/club/joylink/rtss/controller/simulation/ScriptSimulationController.java index efb6e8673..a5c78d990 100644 --- a/src/main/java/club/joylink/rtss/controller/simulation/ScriptSimulationController.java +++ b/src/main/java/club/joylink/rtss/controller/simulation/ScriptSimulationController.java @@ -9,7 +9,7 @@ import club.joylink.rtss.vo.UserVO; import club.joylink.rtss.vo.client.script.MapLocationVO; import club.joylink.rtss.vo.client.script.ScriptActionNewUpdateVO; import club.joylink.rtss.vo.client.script.ScriptActionNewVO; -import club.joylink.rtss.vo.client.script.ScriptNewVO; +import club.joylink.rtss.vo.client.script.ScriptVO; import club.joylink.rtss.vo.client.simulationv1.SimulationMemberVO; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; @@ -156,7 +156,7 @@ public class ScriptSimulationController { @ApiOperation(value = "获取仿真中加载的剧本详情") @GetMapping("/{group}/scriptDetail") - public ScriptNewVO getScriptDetail(@PathVariable String group) { + public ScriptVO getScriptDetail(@PathVariable String group) { return iScriptSimulationService.getScriptDetail(group); } diff --git a/src/main/java/club/joylink/rtss/services/IScriptDraftService.java b/src/main/java/club/joylink/rtss/services/IScriptDraftService.java index f5d2721d5..8cc98e3ea 100644 --- a/src/main/java/club/joylink/rtss/services/IScriptDraftService.java +++ b/src/main/java/club/joylink/rtss/services/IScriptDraftService.java @@ -7,9 +7,8 @@ import club.joylink.rtss.entity.ScriptDraftWithBLOBs; import club.joylink.rtss.vo.UserVO; import club.joylink.rtss.vo.client.PageQueryVO; import club.joylink.rtss.vo.client.PageVO; -import club.joylink.rtss.vo.client.script.ScriptNewVO; -import club.joylink.rtss.vo.client.script.ScriptQueryVO; import club.joylink.rtss.vo.client.script.ScriptVO; +import club.joylink.rtss.vo.client.script.ScriptQueryVO; public interface IScriptDraftService { @@ -34,7 +33,7 @@ public interface IScriptDraftService { * @param id * @return */ - ScriptNewVO getBasicInfo(Long id); + ScriptVO getBasicInfo(Long id); /** * 更新剧本基本信息 @@ -60,13 +59,6 @@ public interface IScriptDraftService { ScriptBO getScriptBO(Long id, Simulation simulation); - /** - * 更新地图详细数据 - * @param id - * @param scriptVO - */ - void updateScriptDetailData(Long id, ScriptVO scriptVO); - /** * 更新新版剧本详细数据 */ diff --git a/src/main/java/club/joylink/rtss/services/IScriptService.java b/src/main/java/club/joylink/rtss/services/IScriptService.java index 179a04273..724f62019 100644 --- a/src/main/java/club/joylink/rtss/services/IScriptService.java +++ b/src/main/java/club/joylink/rtss/services/IScriptService.java @@ -6,7 +6,6 @@ import club.joylink.rtss.entity.ScriptDraftWithBLOBs; import club.joylink.rtss.vo.UserVO; import club.joylink.rtss.vo.client.PageVO; import club.joylink.rtss.vo.client.script.ScriptQueryVO; -import club.joylink.rtss.vo.client.script.ScriptVO; public interface IScriptService { diff --git a/src/main/java/club/joylink/rtss/services/ReleaseReviewService.java b/src/main/java/club/joylink/rtss/services/ReleaseReviewService.java index 2f84449af..58c73e796 100644 --- a/src/main/java/club/joylink/rtss/services/ReleaseReviewService.java +++ b/src/main/java/club/joylink/rtss/services/ReleaseReviewService.java @@ -1,11 +1,11 @@ package club.joylink.rtss.services; +import club.joylink.rtss.vo.client.script.ScriptVO; import com.github.pagehelper.Page; import com.github.pagehelper.PageHelper; import club.joylink.rtss.constants.BusinessConsts; import club.joylink.rtss.dao.*; import club.joylink.rtss.entity.*; -import club.joylink.rtss.util.ConvertUtil; import club.joylink.rtss.vo.LoginUserInfoVO; import club.joylink.rtss.vo.UserVO; import club.joylink.rtss.vo.client.*; @@ -13,7 +13,7 @@ import club.joylink.rtss.vo.client.map.MapVO; import club.joylink.rtss.vo.client.runplan.RunPlanQueryVO; import club.joylink.rtss.vo.client.runplan.RunPlanVO; import club.joylink.rtss.vo.client.script.ScriptQueryVO; -import club.joylink.rtss.vo.client.script.ScriptVO; +import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -23,7 +23,9 @@ import org.springframework.util.ObjectUtils; import java.time.LocalDateTime; import java.util.ArrayList; import java.util.List; +import java.util.Optional; +@Slf4j @Service public class ReleaseReviewService implements IReleaseReviewService { @Autowired @@ -78,7 +80,7 @@ public class ReleaseReviewService implements IReleaseReviewService { LsDraftLessonExample example = new LsDraftLessonExample(); LsDraftLessonExample.Criteria criteria = example.createCriteria().andStatusEqualTo(BusinessConsts.ReleaseReview.RELEASE_STATUS_02); if (!ObjectUtils.isEmpty(queryVO.getMapId())){ - MapVO mapVO = iMapService.getMapInfoById(ConvertUtil.str2Long(queryVO.getMapId())); + MapVO mapVO = iMapService.getMapInfoById(queryVO.getMapId()); criteria.andMapIdEqualTo(mapVO.getId()); } if (!ObjectUtils.isEmpty(queryVO.getLessonName())) { @@ -99,7 +101,7 @@ public class ReleaseReviewService implements IReleaseReviewService { Page lessonPage = (Page) lsDraftLessonDAO.selectByExample(example); List lessonVOList = LessonVO.convert2VO(lessonPage.getResult()); for (LessonVO lessonVO : lessonVOList) { - UserVO userVO = iSysUserService.findUserById(ConvertUtil.str2Long(lessonVO.getCreatorId())); + UserVO userVO = iSysUserService.findUserById(lessonVO.getCreatorId()); lessonVO.setUserName(userVO.getName()); MapVO mapVO = iMapService.getMapInfoById(lessonVO.getMapId()); lessonVO.setCityCode(mapVO.getCityCode()); @@ -171,10 +173,93 @@ public class ReleaseReviewService implements IReleaseReviewService { lessonVOS.add(new LessonVO(lsDraftLesson)); List chapterVos = this.draftLessonChapterDAO.selectChapterTrainingByLessonId(id); // 构建课程树 - List treeNodes = ConvertUtil.buildLessonTreeList(lessonVOS, chapterVos); + List treeNodes = buildLessonTreeList(lessonVOS, chapterVos); return treeNodes; } + private List buildLessonTreeList(List lessonVOS, List chapterVos) { + List tree = new ArrayList<>(); + List chapterTreeList = constructTree(chapterVos); + // 构造树节点 + lessonVOS.forEach(lesson -> { + for (LessonChapterVO lessonChapterVO : chapterTreeList) { + if (lesson.getId().equals(lessonChapterVO.getLessonId())) { + lesson.addChapter(lessonChapterVO); + } + } + tree.add(buildTree(lesson)); + }); + sortTree(tree); + return tree; + } + + /** + * 将章节列表构建成章节列表树 + */ + private static List constructTree(List chapterVoList) { + List tree = new ArrayList<>(); + if (!CollectionUtils.isEmpty(chapterVoList)) { + chapterVoList.forEach(chapterVo -> { + if (chapterVo.getParentId() == 0) { + tree.add(chapterVo); + } else { + Optional first = chapterVoList.stream() + .filter(chapterVO -> chapterVO.getId().equals(chapterVo.getParentId())).findFirst(); + if (first.isPresent()) { + first.get().addChild(chapterVo); + } else { + log.warn(String.format("获取父级章节为null,父id为‘%s’", chapterVo.getParentId())); + } + } + }); + } + return tree; + } + + /** + * 构造课程节点 + * @param lesson + * @return + */ + private TreeNode buildTree(LessonVO lesson) { + TreeNode node = TreeNode.buildLessonNode(lesson); + if(!CollectionUtils.isEmpty(lesson.getChapters())) { + lesson.getChapters().forEach(chapter -> node.addChild(buildTree(chapter))); + } + return node; + } + + /** + * 构造章节节点 + * @param chapter + * @return + */ + private static TreeNode buildTree(LessonChapterVO chapter) { + TreeNode node = TreeNode.buildChapterNode(chapter); + if(!CollectionUtils.isEmpty(chapter.getTrainingVos())) { + chapter.getTrainingVos().forEach(training -> node.addChild(TreeNode.buildTrainingNode(training))); + } + if(!CollectionUtils.isEmpty(chapter.getChildren())) { + chapter.getChildren().forEach(child -> node.addChild(buildTree(child))); + } + return node; + } + + /** + * 树排序 + */ + private void sortTree(List list) { + if(!CollectionUtils.isEmpty(list)) { + list.sort((o1, o2) -> { + if (null == o1.getOrder() || null == o2.getOrder()) { + return 0; + } + return o1.getOrder().compareTo(o2.getOrder()); + }); + list.forEach(tree -> sortTree(tree.getChildren())); + } + } + //---------------剧本发布审核---------------- /** diff --git a/src/main/java/club/joylink/rtss/services/ScriptDraftService.java b/src/main/java/club/joylink/rtss/services/ScriptDraftService.java index 8c9851c2b..0e25a999b 100644 --- a/src/main/java/club/joylink/rtss/services/ScriptDraftService.java +++ b/src/main/java/club/joylink/rtss/services/ScriptDraftService.java @@ -1,10 +1,8 @@ package club.joylink.rtss.services; +import club.joylink.rtss.exception.BusinessExceptionAssertEnum; import com.github.pagehelper.Page; import com.github.pagehelper.PageHelper; -import com.joylink.base.exception.BusinessException; -import com.joylink.base.exception.DBException; -import com.joylink.base.exception.constant.ExceptionMapping; import club.joylink.rtss.simulation.cbtc.Simulation; import club.joylink.rtss.simulation.cbtc.script.ScriptBO; import club.joylink.rtss.simulation.cbtc.script.ScriptUpdateVO; @@ -13,13 +11,11 @@ import club.joylink.rtss.dao.ScriptDraftDAO; import club.joylink.rtss.entity.ScriptDraft; import club.joylink.rtss.entity.ScriptDraftExample; import club.joylink.rtss.entity.ScriptDraftWithBLOBs; -import club.joylink.rtss.util.ConvertUtil; import club.joylink.rtss.vo.UserVO; import club.joylink.rtss.vo.client.PageQueryVO; import club.joylink.rtss.vo.client.PageVO; -import club.joylink.rtss.vo.client.script.ScriptNewVO; -import club.joylink.rtss.vo.client.script.ScriptQueryVO; import club.joylink.rtss.vo.client.script.ScriptVO; +import club.joylink.rtss.vo.client.script.ScriptQueryVO; import org.springframework.util.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -55,113 +51,79 @@ public class ScriptDraftService implements IScriptDraftService { example.createCriteria().andMapIdEqualTo(mapId) .andCreatorIdEqualTo(user.getId()); Page page = (Page) scriptDraftDAO.selectByExample(example); - List scriptVOList = ScriptVO.convertDraft2VOList(page.getResult()); + List scriptVOList = ScriptVO.convertFromDraftList(page.getResult()); return PageVO.convert(page, scriptVOList); } @Override public String createScript(ScriptVO scriptVO, UserVO user) { checkNameRepeat(null, scriptVO.getName(), scriptVO.getMapId(), user); - ScriptDraftWithBLOBs scriptDraft = scriptVO.convert2Draft(); + ScriptDraftWithBLOBs scriptDraft = scriptVO.convert2CreateDraft(); scriptDraft.setCreatorId(user.getId()); scriptDraft.setCreateTime(LocalDateTime.now()); scriptDraft.setStatus(BusinessConsts.ReleaseReview.RELEASE_STATUS_01); scriptDraftDAO.insert(scriptDraft); - return ConvertUtil.long2Str(scriptDraft.getId()); + return scriptDraft.getId().toString(); } @Override - public ScriptNewVO getBasicInfo(Long id) { - ScriptDraft scriptDraft = scriptDraftDAO.selectByPrimaryKey(id); - if (Objects.isNull(scriptDraft)) { - throw new DBException(ExceptionMapping.DATA_NOT_EXIST); - } - return new ScriptNewVO(scriptDraft); + public ScriptVO getBasicInfo(Long id) { + ScriptDraftWithBLOBs scriptDraftWithBLOBs = getEntityById(id); + return new ScriptVO((ScriptDraft)scriptDraftWithBLOBs); } @Override public void updateScriptInfo(Long id, ScriptUpdateVO updateVO, UserVO user) { checkNameRepeat(id, updateVO.getName(), updateVO.getMapId(), user); - ScriptDraft scriptDraft = scriptDraftDAO.selectByPrimaryKey(id); - if (Objects.isNull(scriptDraft)) { - throw new DBException(ExceptionMapping.DATA_NOT_EXIST); - } + ScriptDraftWithBLOBs scriptDraftWithBLOBs = getEntityById(id); boolean change = false; - if (!Objects.equals(scriptDraft.getName(), updateVO.getName())) { - scriptDraft.setName(updateVO.getName()); + if (!Objects.equals(scriptDraftWithBLOBs.getName(), updateVO.getName())) { + scriptDraftWithBLOBs.setName(updateVO.getName()); change = true; } - if (!Objects.equals(scriptDraft.getDescription(), updateVO.getDescription())) { - scriptDraft.setDescription(updateVO.getDescription()); + if (!Objects.equals(scriptDraftWithBLOBs.getDescription(), updateVO.getDescription())) { + scriptDraftWithBLOBs.setDescription(updateVO.getDescription()); change = true; } - if (!Objects.equals(scriptDraft.getFullMarksDuration(), updateVO.getFullMarksDuration())) { - scriptDraft.setFullMarksDuration(updateVO.getFullMarksDuration()); + if (!Objects.equals(scriptDraftWithBLOBs.getFullMarksDuration(), updateVO.getFullMarksDuration())) { + scriptDraftWithBLOBs.setFullMarksDuration(updateVO.getFullMarksDuration()); change = true; } - if (!Objects.equals(scriptDraft.getPassingGradeDuration(), updateVO.getPassingGradeDuration())) { - scriptDraft.setPassingGradeDuration(updateVO.getPassingGradeDuration()); + if (!Objects.equals(scriptDraftWithBLOBs.getPassingGradeDuration(), updateVO.getPassingGradeDuration())) { + scriptDraftWithBLOBs.setPassingGradeDuration(updateVO.getPassingGradeDuration()); change = true; } - if (!Objects.equals(scriptDraft.getZeroDuration(), updateVO.getZeroDuration())) { - scriptDraft.setZeroDuration(updateVO.getZeroDuration()); + if (!Objects.equals(scriptDraftWithBLOBs.getZeroDuration(), updateVO.getZeroDuration())) { + scriptDraftWithBLOBs.setZeroDuration(updateVO.getZeroDuration()); change = true; } if (change) { - scriptDraft.setStatus(BusinessConsts.ReleaseReview.RELEASE_STATUS_01); - scriptDraftDAO.updateByPrimaryKey(scriptDraft); + scriptDraftWithBLOBs.setStatus(BusinessConsts.ReleaseReview.RELEASE_STATUS_01); + scriptDraftDAO.updateByPrimaryKey(scriptDraftWithBLOBs); } } @Override public void deleteScript(Long id, UserVO user) { - ScriptDraft scriptDraft = scriptDraftDAO.selectByPrimaryKey(id); - if (!scriptDraft.getCreatorId().equals(user.getId())) { - throw new BusinessException(ExceptionMapping.ILLEGAL_OPERATION); - } + ScriptDraftWithBLOBs entity = getEntityById(id); + BusinessExceptionAssertEnum.INVALID_OPERATION.assertTrue(entity.getCreatorId().equals(user.getId()), + String.format("用户[%s]尝试删除用户[%s]的剧本[%s]", user.getId(), entity.getCreatorId(), id)); scriptDraftDAO.deleteByPrimaryKey(id); } @Override public ScriptVO getScriptDetail(Long id) { - ScriptDraftWithBLOBs scriptDraftWithBLOBs = scriptDraftDAO.selectByPrimaryKey(id); - if (Objects.isNull(scriptDraftWithBLOBs)) { - throw new DBException(ExceptionMapping.DATA_NOT_EXIST); - } - return new ScriptVO(scriptDraftWithBLOBs); + return new ScriptVO(getEntityById(id)); } @Override public ScriptBO getScriptBO(Long id, Simulation simulation) { - ScriptDraftWithBLOBs scriptDraftWithBLOBs = scriptDraftDAO.selectByPrimaryKey(id); - if (Objects.isNull(scriptDraftWithBLOBs)) { - throw new DBException(ExceptionMapping.DATA_NOT_EXIST); - } - return new ScriptBO(scriptDraftWithBLOBs, simulation); - } - - @Override - public void updateScriptDetailData(Long id, ScriptVO scriptVO) { - ScriptDraftWithBLOBs scriptDraftWithBLOBs = scriptDraftDAO.selectByPrimaryKey(id); - if (Objects.isNull(scriptDraftWithBLOBs)) { - throw new DBException(ExceptionMapping.DATA_NOT_EXIST); - } - scriptDraftWithBLOBs.setBgScenesJson(scriptVO.getBgScenesJson()); - scriptDraftWithBLOBs.setFinalScenesJson(scriptVO.getFinalScenesJson()); - scriptDraftWithBLOBs.setMapLocationJson(scriptVO.getMapLocationJson()); - scriptDraftWithBLOBs.setMembersJson(scriptVO.getMembersJson()); - scriptDraftWithBLOBs.setPlayersJson(scriptVO.getPlayersJson()); - scriptDraftWithBLOBs.setActionsJson(scriptVO.getActionsJson()); - scriptDraftWithBLOBs.setStatus(BusinessConsts.ReleaseReview.RELEASE_STATUS_01); - scriptDraftDAO.updateByPrimaryKeyWithBLOBs(scriptDraftWithBLOBs); + return new ScriptBO(getEntityById(id), simulation); } @Override public void updateScriptDetailData(Long id, ScriptBO scriptBO) { - ScriptDraftWithBLOBs script = scriptDraftDAO.selectByPrimaryKey(id); - if (Objects.isNull(script)) { - throw new DBException(ExceptionMapping.DATA_NOT_EXIST); - } + ScriptDraftWithBLOBs script = getEntityById(id); script.setBgScenesJson(scriptBO.getBgScenesJson()); script.setFinalScenesJson(scriptBO.getFinalScenesJson()); script.setMapLocationJson(scriptBO.getMapLocationJson()); @@ -174,17 +136,14 @@ public class ScriptDraftService implements IScriptDraftService { @Override public void publish(Long id, String name, UserVO user) { - ScriptDraftWithBLOBs scriptDraftWithBLOBs = scriptDraftDAO.selectByPrimaryKey(id); - if (Objects.isNull(scriptDraftWithBLOBs)) { - throw new DBException(ExceptionMapping.DATA_NOT_EXIST); - } + ScriptDraftWithBLOBs entity = getEntityById(id); if (iSysUserService.isAdmin(user)) { - iScriptService.publish(scriptDraftWithBLOBs, user); - scriptDraftWithBLOBs.setStatus(BusinessConsts.ReleaseReview.RELEASE_STATUS_03); + iScriptService.publish(entity, user); + entity.setStatus(BusinessConsts.ReleaseReview.RELEASE_STATUS_03); } else { - scriptDraftWithBLOBs.setStatus(BusinessConsts.ReleaseReview.RELEASE_STATUS_02); + entity.setStatus(BusinessConsts.ReleaseReview.RELEASE_STATUS_02); } - scriptDraftDAO.updateByPrimaryKey(scriptDraftWithBLOBs); + scriptDraftDAO.updateByPrimaryKey(entity); } @Override @@ -247,9 +206,8 @@ public class ScriptDraftService implements IScriptDraftService { @Override public ScriptDraftWithBLOBs getEntityById(Long scriptId) { ScriptDraftWithBLOBs scriptDraftWithBLOBs = scriptDraftDAO.selectByPrimaryKey(scriptId); - if (Objects.isNull(scriptDraftWithBLOBs)) { - throw new DBException(ExceptionMapping.DATA_NOT_EXIST); - } + BusinessExceptionAssertEnum.DATA_NOT_EXIST.assertNotNull(scriptDraftWithBLOBs, + String.format("id为[%s]的草稿剧本不存在", scriptId)); return scriptDraftWithBLOBs; } @@ -279,8 +237,7 @@ public class ScriptDraftService implements IScriptDraftService { criteria.andMapIdEqualTo(mapId) .andNameEqualTo(name) .andCreatorIdEqualTo(userVO.getId()); - if (scriptDraftDAO.countByExample(draftExample) > 0) { - throw new DBException(ExceptionMapping.NAME_REPEAT); - } + BusinessExceptionAssertEnum.DATA_UNIQUE_PROPERTY_REPEAT.assertTrue(scriptDraftDAO.countByExample(draftExample) == 0, + String.format("剧本名称[%s]重复", name)); } } diff --git a/src/main/java/club/joylink/rtss/services/ScriptService.java b/src/main/java/club/joylink/rtss/services/ScriptService.java index fa7075a98..f22b4af09 100644 --- a/src/main/java/club/joylink/rtss/services/ScriptService.java +++ b/src/main/java/club/joylink/rtss/services/ScriptService.java @@ -16,7 +16,6 @@ import club.joylink.rtss.entity.ScriptWithBLOBs; import club.joylink.rtss.vo.UserVO; import club.joylink.rtss.vo.client.PageVO; import club.joylink.rtss.vo.client.script.ScriptQueryVO; -import club.joylink.rtss.vo.client.script.ScriptVO; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; diff --git a/src/main/java/club/joylink/rtss/services/completition/CompetitionPracticalService.java b/src/main/java/club/joylink/rtss/services/completition/CompetitionPracticalService.java index f39a56a89..4ab7615a2 100644 --- a/src/main/java/club/joylink/rtss/services/completition/CompetitionPracticalService.java +++ b/src/main/java/club/joylink/rtss/services/completition/CompetitionPracticalService.java @@ -27,10 +27,9 @@ import club.joylink.rtss.vo.UserVO; import club.joylink.rtss.vo.client.PageVO; import club.joylink.rtss.vo.client.competition.*; import club.joylink.rtss.vo.client.script.ScriptActionNewVO; -import club.joylink.rtss.vo.client.script.ScriptNewVO; +import club.joylink.rtss.vo.client.script.ScriptVO; import com.github.pagehelper.Page; import com.github.pagehelper.PageHelper; -import lombok.extern.log4j.Log4j; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -129,7 +128,7 @@ public class CompetitionPracticalService implements ICompetitionPracticalService * 检查数据是否正确 */ private void checkData(CompetitionVO competitionVO) { - ScriptNewVO scriptDetail = iScriptService2.getDetailById(competitionVO.getScriptId()); + ScriptVO scriptDetail = iScriptService2.getDetailById(competitionVO.getScriptId()); Map actionMap = scriptDetail.getActionList() .stream().collect(Collectors.toMap(ScriptActionNewVO::getId, Function.identity())); for (CommandPublishStatisticVO rule : competitionVO.getCommandEvaluationRuleVOs()) { diff --git a/src/main/java/club/joylink/rtss/services/script/IScriptService2.java b/src/main/java/club/joylink/rtss/services/script/IScriptService2.java index e9a44062b..133efb132 100644 --- a/src/main/java/club/joylink/rtss/services/script/IScriptService2.java +++ b/src/main/java/club/joylink/rtss/services/script/IScriptService2.java @@ -1,7 +1,7 @@ package club.joylink.rtss.services.script; import club.joylink.rtss.vo.client.PageVO; -import club.joylink.rtss.vo.client.script.ScriptNewVO; +import club.joylink.rtss.vo.client.script.ScriptVO; import club.joylink.rtss.vo.client.script.ScriptQueryVO; public interface IScriptService2 { @@ -11,15 +11,15 @@ public interface IScriptService2 { * @return * @param queryVO */ - PageVO pagingQueryOnlineScript(ScriptQueryVO queryVO); + PageVO pagingQueryOnlineScript(ScriptQueryVO queryVO); /** * 根据id查询剧本详细信息 */ - ScriptNewVO getDetailForClientById(Long id); + ScriptVO getDetailForClientById(Long id); /** * 根据id获取剧本基础BO对象 */ - ScriptNewVO getDetailById(Long id); + ScriptVO getDetailById(Long id); } diff --git a/src/main/java/club/joylink/rtss/services/script/ScriptService2.java b/src/main/java/club/joylink/rtss/services/script/ScriptService2.java index 193f76191..63206b8cf 100644 --- a/src/main/java/club/joylink/rtss/services/script/ScriptService2.java +++ b/src/main/java/club/joylink/rtss/services/script/ScriptService2.java @@ -10,7 +10,7 @@ import club.joylink.rtss.entity.Script; import club.joylink.rtss.entity.ScriptExample; import club.joylink.rtss.entity.ScriptWithBLOBs; import club.joylink.rtss.vo.client.PageVO; -import club.joylink.rtss.vo.client.script.ScriptNewVO; +import club.joylink.rtss.vo.client.script.ScriptVO; import club.joylink.rtss.vo.client.script.ScriptQueryVO; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -25,7 +25,7 @@ public class ScriptService2 implements IScriptService2 { private ScriptDAO scriptDAO; @Override - public PageVO pagingQueryOnlineScript(ScriptQueryVO queryVO) { + public PageVO pagingQueryOnlineScript(ScriptQueryVO queryVO) { PageHelper.startPage(queryVO.getPageNum(), queryVO.getPageSize()); ScriptExample example = new ScriptExample(); example.setOrderByClause("id desc"); @@ -35,13 +35,13 @@ public class ScriptService2 implements IScriptService2 { criteria.andMapIdEqualTo(queryVO.getMapId()); } Page