实训草稿发布优化

This commit is contained in:
xzb 2022-09-16 10:24:47 +08:00
parent 6293a2a54b
commit 1741d5ed12
2 changed files with 27 additions and 19 deletions

View File

@ -31,23 +31,23 @@ public class Training2Convertor {
//
pub.setState(PublishedTraining2StateEnum.PutOn.getState());
//
pub.setMemberJson(from.getMemberJson());
pub.setBgSceneJson(from.getBgSceneJson());
pub.setFinalScenesJson(from.getFinalScenesJson());
pub.setOperaJson(from.getOperaJson());
pub.setDescription(from.getDescription());
pub.setMemberJson(null==from.getMemberJson()?"":from.getMemberJson());
pub.setBgSceneJson(null==from.getBgSceneJson()?"":from.getBgSceneJson());
pub.setFinalScenesJson(null==from.getFinalScenesJson()?"":from.getFinalScenesJson());
pub.setOperaJson(null==from.getOperaJson()?"":from.getOperaJson());
pub.setDescription(null==from.getDescription()?"":from.getDescription());
pub.setCreateTime(LocalDateTime.now());
pub.setUpdateTime(LocalDateTime.now());
pub.setCreatorId(from.getCreatorId());
pub.setName(from.getName());
pub.setPlayerIdJson(from.getPlayerIdJson());
pub.setScoringRuleJson(from.getScoringRuleJson());
pub.setStepJson(from.getStepJson());
pub.setFailureConditionJson(from.getFailureConditionJson());
pub.setLabelJson(from.getLabelJson());
pub.setName(null==from.getName()?"":from.getName());
pub.setPlayerIdJson(null==from.getPlayerIdJson()?"":from.getPlayerIdJson());
pub.setScoringRuleJson(null==from.getScoringRuleJson()?"":from.getScoringRuleJson());
pub.setStepJson(null==from.getStepJson()?"":from.getStepJson());
pub.setFailureConditionJson(null==from.getFailureConditionJson()?"":from.getFailureConditionJson());
pub.setLabelJson(null==from.getLabelJson()?"":from.getLabelJson());
pub.setMapId(from.getMapId());
pub.setMapLocationJson(from.getMapLocationJson());
pub.setType(from.getType());
pub.setMapLocationJson(null==from.getMapLocationJson()?"":from.getMapLocationJson());
pub.setType(null==from.getType()?"":from.getType());
pub.setRunPlanId(from.getRunPlanId());
//
return pub;

View File

@ -41,19 +41,27 @@ public class Training2DraftPublishService {
if(null!=req.getReName()&&req.getReName().trim().length()>0){
pub.setName(req.getReName());
}
// 该字段废弃数据库对应字段后续删除
pub.setFinalScenesJson("");
//根据要发布的草稿名称来查找已发布的实训
//如果以有同名的则会被覆盖
PublishedTraining2Example ptExample = new PublishedTraining2Example();
ptExample.createCriteria().andNameEqualTo(pub.getName()).andMapIdEqualTo(pub.getMapId());
List<PublishedTraining2> ptFinds = this.publishedDao.selectByExample(ptExample);
//
if (null != ptFinds && !ptFinds.isEmpty()) {//已发布实训存在时则直接删除
this.publishedDao.deleteByExample(ptExample);
}
// 该字段废弃数据库对应字段后续删除
pub.setFinalScenesJson(null);
if(null==ptFinds||ptFinds.isEmpty()){//同地图同名已发布实训不存在则直接存入
//发布
this.publishedDao.insertSelective(pub);
}else{//同地图同名已发布实训存在
if(ptFinds.size()>1){//当有多个存在时则全部删除再存入
this.publishedDao.deleteByExample(ptExample);
this.publishedDao.insertSelective(pub);
}else{//当有且仅有一个时直接更新
PublishedTraining2 old = ptFinds.get(0);
pub.setId(old.getId());
this.publishedDao.updateByPrimaryKeySelective(pub);
}
}
//记录发布轨迹
final PublishedTraining2 tracePub = this.findByNameAndMapId(pub.getName(),pub.getMapId());
final DraftTraining2 traceDraft = draft;