From 258b8199e27a224d60adf870a2f0329dc7530a77 Mon Sep 17 00:00:00 2001 From: weizhihong Date: Wed, 4 Jan 2023 14:33:33 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90=E5=AE=9E=E8=AE=AD=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E8=83=8C=E6=99=AF=E6=97=B6=EF=BC=8C=E5=90=8C=E6=AD=A5=E4=BF=AE?= =?UTF-8?q?=E6=94=B9=E4=BB=BF=E7=9C=9F=E4=B8=AD=E5=AE=9E=E8=AE=AD=E4=BF=A1?= =?UTF-8?q?=E6=81=AF=E3=80=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../training2/TrainingDraftV2Controller.java | 6 ++-- .../training2/Training2DraftService.java | 28 +++++++++++++++---- .../draft/ResetTraining2BackgroudReqVo.java | 3 ++ 3 files changed, 29 insertions(+), 8 deletions(-) diff --git a/src/main/java/club/joylink/rtss/controller/training2/TrainingDraftV2Controller.java b/src/main/java/club/joylink/rtss/controller/training2/TrainingDraftV2Controller.java index a6718c6a8..aa7a48f2c 100644 --- a/src/main/java/club/joylink/rtss/controller/training2/TrainingDraftV2Controller.java +++ b/src/main/java/club/joylink/rtss/controller/training2/TrainingDraftV2Controller.java @@ -81,9 +81,9 @@ public class TrainingDraftV2Controller { /** * 重置当前用户的某个实训草稿的内容 */ - @DeleteMapping("/reset/{trainingId}") - public void resetTraining(@PathVariable("trainingId") Long trainingId, @RequestAttribute AccountVO user) { - this.training2DraftService.resetTraining(trainingId,user.getId()); + @DeleteMapping("{groupId}/reset/{trainingId}") + public void resetTraining(@PathVariable("groupId") String groupId, @PathVariable("trainingId") Long trainingId, @RequestAttribute AccountVO user) { + this.training2DraftService.resetTraining(groupId, trainingId, user.getId()); } /** diff --git a/src/main/java/club/joylink/rtss/services/training2/Training2DraftService.java b/src/main/java/club/joylink/rtss/services/training2/Training2DraftService.java index dc25ac7eb..e941111dd 100644 --- a/src/main/java/club/joylink/rtss/services/training2/Training2DraftService.java +++ b/src/main/java/club/joylink/rtss/services/training2/Training2DraftService.java @@ -7,6 +7,7 @@ import club.joylink.rtss.entity.training2.DraftTraining2WithBLOBs; import club.joylink.rtss.exception.BusinessExceptionAssertEnum; import club.joylink.rtss.simulation.cbtc.GroupSimulationService; import club.joylink.rtss.simulation.cbtc.Simulation; +import club.joylink.rtss.simulation.cbtc.SimulationService; import club.joylink.rtss.simulation.cbtc.data.storage.StorageSimulation; import club.joylink.rtss.simulation.cbtc.exception.SimulationException; import club.joylink.rtss.simulation.cbtc.exception.SimulationExceptionType; @@ -46,6 +47,8 @@ public class Training2DraftService { private DraftTraining2DAO trainingDao; @Autowired private GroupSimulationService groupSimulationService; + @Autowired + private SimulationService simulationService; /** * 根据基本信息创建实训 @@ -136,11 +139,15 @@ public class Training2DraftService { Simulation simulation = this.groupSimulationService.getSimulationByGroup(simulationId); StorageSimulation scenesSaving = new StorageSimulation(simulation, true); //保存背景 - b.setBgSceneJson((JsonUtils.writeValueAsString(scenesSaving))); - b.setMemberJson(JsonUtils.writeValueAsString(SimulationMemberVO.convert2VOList(simulation.getSimulationMembers()))); + String bgSceneJson = JsonUtils.writeValueAsString(scenesSaving); + String memberJson = JsonUtils.writeValueAsString(SimulationMemberVO.convert2VOList(simulation.getSimulationMembers())); + b.setBgSceneJson(bgSceneJson); + b.setMemberJson(memberJson); b.setUpdateTime(LocalDateTime.now()); - // this.trainingDao.updateByExampleSelective(b, example); + //修改仿真中实训信息 + simulation.getTraining2().setBgSceneJson(bgSceneJson); + simulation.getTraining2().setMembersJson(memberJson); } /** @@ -157,15 +164,17 @@ public class Training2DraftService { b.setBgSceneJson(""); b.setFinalScenesJson(""); b.setUpdateTime(LocalDateTime.now()); - // this.trainingDao.updateByExampleSelective(b, example); + // 重置仿真中背景信息 + Simulation simulation = this.groupSimulationService.getSimulationByGroup(req.getGroupId()); + simulation.getTraining2().setBgSceneJson(null); } /** * 重置用户实训草稿 */ @Transactional(rollbackFor = Exception.class) - public void resetTraining(Long trainingId, Long userId) { + public void resetTraining(String groupId, Long trainingId, Long userId) { DraftTraining2Example example = new DraftTraining2Example(); example.createCriteria().andCreatorIdEqualTo(userId).andIdEqualTo(trainingId); List find = this.trainingDao.selectByExample(example); @@ -185,6 +194,15 @@ public class Training2DraftService { b.setStepJson(""); // this.trainingDao.updateByExampleSelective(b, example); + // 重置仿真中背景信息 + Simulation simulation = this.groupSimulationService.getSimulationByGroup(groupId); + simulation.getTraining2().setBgSceneJson(null); + simulation.getTraining2().setMapLocationJson(null); + simulation.getTraining2().setSteps(null); + simulation.getTraining2().setMembersJson(null); + simulation.getTraining2().setPlayerIds(null); + simulation.getTraining2().setScoringRules(null); + simulationService.reset(groupId); } /** diff --git a/src/main/java/club/joylink/rtss/vo/training2/draft/ResetTraining2BackgroudReqVo.java b/src/main/java/club/joylink/rtss/vo/training2/draft/ResetTraining2BackgroudReqVo.java index 1c390d672..484c11353 100644 --- a/src/main/java/club/joylink/rtss/vo/training2/draft/ResetTraining2BackgroudReqVo.java +++ b/src/main/java/club/joylink/rtss/vo/training2/draft/ResetTraining2BackgroudReqVo.java @@ -19,4 +19,7 @@ public class ResetTraining2BackgroudReqVo { @NotBlank(message = "实训草稿id不能为空") @JsonSerialize(using = ToStringSerializer.class) private Long id; + + @NotBlank(message = "仿真id不能为空") + private String groupId; }