From 0b7ccabb16f4fa6ecdedff93b29b1d5c1e7751e9 Mon Sep 17 00:00:00 2001 From: weizhihong Date: Fri, 5 May 2023 11:03:22 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90=E4=BF=AE=E6=94=B9=E5=B7=B2=E5=8F=91?= =?UTF-8?q?=E5=B8=83=E5=AE=9E=E8=AE=ADlabel=E4=BF=A1=E6=81=AF=E3=80=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../TrainingV2PublishController.java | 17 +++++++++++++++ .../rtss/dao/PublishedTraining2DAO.java | 2 ++ .../training2/Training2PublishService.java | 21 +++++++++++++++++++ .../mybatis/mapper/PublishedTraining2DAO.xml | 9 ++++++++ 4 files changed, 49 insertions(+) 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 +