diff --git a/src/main/java/club/joylink/rtss/controller/training2/TrainingV2PublishController.java b/src/main/java/club/joylink/rtss/controller/training2/TrainingV2PublishController.java index a8a46b2c4..42b92549a 100644 --- a/src/main/java/club/joylink/rtss/controller/training2/TrainingV2PublishController.java +++ b/src/main/java/club/joylink/rtss/controller/training2/TrainingV2PublishController.java @@ -4,6 +4,7 @@ import club.joylink.rtss.constants.BusinessConsts; import club.joylink.rtss.constants.RoleEnum; import club.joylink.rtss.controller.advice.AuthenticateInterceptor; import club.joylink.rtss.controller.advice.Role; +import club.joylink.rtss.entity.training2.PublishedTraining2; import club.joylink.rtss.services.training2.Training2PublishService; import club.joylink.rtss.services.training2.Training2TypeEnum; import club.joylink.rtss.vo.LoginUserInfoVO; @@ -106,4 +107,20 @@ public class TrainingV2PublishController { public PublishedTraining2DetailRspVo findTrainingAllInfo(@PathVariable("trainingId") Long trainingId){ return this.publishService.findTrainingAllInfoById(trainingId); } + + /** + * 更新实训label + */ + @PutMapping("/update/label") + public void updateTrainingLabel(@RequestBody PublishedTraining2 training2) { + publishService.updateTrainingLabel(training2); + } + + /** + * 批量更新实训label + */ + @PutMapping("/update/batch/label") + public void updateTrainingLabelList(@RequestBody List publishedTraining2List) { + publishService.updateTrainingLabelList(publishedTraining2List); + } } diff --git a/src/main/java/club/joylink/rtss/dao/PublishedTraining2DAO.java b/src/main/java/club/joylink/rtss/dao/PublishedTraining2DAO.java index 48313e1e6..6f544746e 100644 --- a/src/main/java/club/joylink/rtss/dao/PublishedTraining2DAO.java +++ b/src/main/java/club/joylink/rtss/dao/PublishedTraining2DAO.java @@ -74,4 +74,6 @@ public interface PublishedTraining2DAO { List selectTrainingIdByRuleNameAndMapId(@Param("ruleNameList") List> ruleNameMapList, @Param("mapId") Long mapId); int updateTrainingOrgByMapIdList(@Param("orgId") Long orgId, @Param("mapIdList") List mapIdList); + + void updateTrainingLabelList(@Param("list") List training2List); } diff --git a/src/main/java/club/joylink/rtss/services/training2/Training2PublishService.java b/src/main/java/club/joylink/rtss/services/training2/Training2PublishService.java index 2b58bb70a..d7ccf9e9c 100644 --- a/src/main/java/club/joylink/rtss/services/training2/Training2PublishService.java +++ b/src/main/java/club/joylink/rtss/services/training2/Training2PublishService.java @@ -430,4 +430,25 @@ public class Training2PublishService { publishedDao.updateTrainingOrgByMapIdList(orgId, mapIdList); } } + + /** + * 批量更新实训label + */ + public void updateTrainingLabelList(List publishedTraining2List) { + List training2List = publishedTraining2List.stream().filter(t -> t.getId() != null).collect(Collectors.toList()); + if (CollectionUtils.isEmpty(training2List)) { + return; + } + publishedDao.updateTrainingLabelList(training2List); + } + + /** + * 更新实训label + */ + public void updateTrainingLabel(PublishedTraining2 training2) { + PublishedTraining2WithBLOBs blobs = new PublishedTraining2WithBLOBs(); + blobs.setId(training2.getId()); + blobs.setLabelJson(training2.getLabelJson()); + publishedDao.updateByPrimaryKeySelective(blobs); + } } diff --git a/src/main/resources/mybatis/mapper/PublishedTraining2DAO.xml b/src/main/resources/mybatis/mapper/PublishedTraining2DAO.xml index c993dbb6f..6ba52e7ce 100644 --- a/src/main/resources/mybatis/mapper/PublishedTraining2DAO.xml +++ b/src/main/resources/mybatis/mapper/PublishedTraining2DAO.xml @@ -630,4 +630,13 @@ where creator_id = 0 and map_id in #{mapId} + + + UPDATE rts_published_training2 t + INNER JOIN ( + + SELECT #{item.id} as id, #{item.labelJson} as label_json + + ) tt ON t.id = tt.id SET t.label_json = tt.label_json +