【实训修改背景时,同步修改仿真中实训信息】
This commit is contained in:
parent
3cb7afea89
commit
258b8199e2
@ -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());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -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<DraftTraining2> 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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -19,4 +19,7 @@ public class ResetTraining2BackgroudReqVo {
|
||||
@NotBlank(message = "实训草稿id不能为空")
|
||||
@JsonSerialize(using = ToStringSerializer.class)
|
||||
private Long id;
|
||||
|
||||
@NotBlank(message = "仿真id不能为空")
|
||||
private String groupId;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user