From fbc7ad6e0fce8466f106a6a8641cec8f502f8fa8 Mon Sep 17 00:00:00 2001 From: wangjiahao <1522128093@qq.com> Date: Thu, 21 Mar 2024 11:49:57 +0800 Subject: [PATCH] =?UTF-8?q?refactor(=E7=B3=BB=E7=BB=9F=E8=AE=BE=E7=BD=AE):?= =?UTF-8?q?=20=E6=A8=A1=E7=89=88=E7=AE=A1=E7=90=86=E6=89=B9=E9=87=8F?= =?UTF-8?q?=E6=93=8D=E4=BD=9C=E4=BF=AE=E6=94=B9=E5=88=86=E7=B1=BB=E6=98=AF?= =?UTF-8?q?=E5=BD=93=E5=88=86=E7=B1=BB=E5=AE=8C=E5=85=A8=E7=9B=B8=E5=90=8C?= =?UTF-8?q?=E9=BB=98=E8=AE=A4=E6=98=BE=E7=A4=BA=E5=88=86=E7=B1=BB=E6=A0=87?= =?UTF-8?q?=E7=AD=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ext/ExtVisualizationTemplateMapper.java | 1 + .../service/TemplateManageService.java | 26 +++++++++++++------ .../ExtVisualizationTemplateMapper.xml | 14 ++++++++++ core/core-frontend/src/api/template.ts | 7 +++++ .../template/component/DeCategoryChange.vue | 11 ++++++-- .../api/template/TemplateManageApi.java | 5 ++++ .../request/TemplateManageRequest.java | 2 ++ 7 files changed, 56 insertions(+), 10 deletions(-) diff --git a/core/core-backend/src/main/java/io/dataease/template/dao/ext/ExtVisualizationTemplateMapper.java b/core/core-backend/src/main/java/io/dataease/template/dao/ext/ExtVisualizationTemplateMapper.java index 2aaf531330..d7f73f1e30 100644 --- a/core/core-backend/src/main/java/io/dataease/template/dao/ext/ExtVisualizationTemplateMapper.java +++ b/core/core-backend/src/main/java/io/dataease/template/dao/ext/ExtVisualizationTemplateMapper.java @@ -26,5 +26,6 @@ public interface ExtVisualizationTemplateMapper{ Long checkCategoryTemplateName(@Param("templateName") String templateName,@Param("categories") List categories); List findTemplateCategories(@Param("templateId") String templateId); + List findTemplateArrayCategories(@Param("templateArray") List templateArray); } diff --git a/core/core-backend/src/main/java/io/dataease/template/service/TemplateManageService.java b/core/core-backend/src/main/java/io/dataease/template/service/TemplateManageService.java index 1c33765e08..6969a32f96 100644 --- a/core/core-backend/src/main/java/io/dataease/template/service/TemplateManageService.java +++ b/core/core-backend/src/main/java/io/dataease/template/service/TemplateManageService.java @@ -26,9 +26,7 @@ import org.springframework.util.CollectionUtils; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; -import java.util.List; -import java.util.Optional; -import java.util.UUID; +import java.util.*; import static io.dataease.constant.StaticResourceConstants.UPLOAD_URL_PREFIX; @@ -101,7 +99,7 @@ public class TemplateManageService implements TemplateManageApi { templateCategoryMapper.insert(templateCategory); } else {//模板插入 同名的模板进行覆盖(先删除) // 分类映射删除 - extTemplateMapper.deleteCategoryMapByTemplate(request.getName(),null); + extTemplateMapper.deleteCategoryMapByTemplate(request.getName(), null); // 模板删除 QueryWrapper wrapper = new QueryWrapper<>(); wrapper.eq("name", request.getName()); @@ -139,7 +137,7 @@ public class TemplateManageService implements TemplateManageApi { templateMapper.updateById(template); //更新分类 // 分类映射删除 - extTemplateMapper.deleteCategoryMapByTemplate(null,request.getId()); + extTemplateMapper.deleteCategoryMapByTemplate(null, request.getId()); // 插入分类关系 request.getCategories().forEach(categoryId -> { VisualizationTemplateCategoryMap categoryMap = new VisualizationTemplateCategoryMap(); @@ -254,6 +252,17 @@ public class TemplateManageService implements TemplateManageApi { } } + @Override + public List findCategoriesByTemplateIds(TemplateManageRequest request) throws Exception { + if (!CollectionUtils.isEmpty(request.getTemplateArray())) { + List result = extTemplateMapper.findTemplateArrayCategories(request.getTemplateArray()); + if(!CollectionUtils.isEmpty(result) &&result.size() == 1 ){ + return Arrays.stream(result.get(0).split(",")).toList(); + } + } + return new ArrayList<>(); + } + @Override public List find(TemplateManageRequest request) { return extTemplateMapper.findTemplateList(request); @@ -263,11 +272,12 @@ public class TemplateManageService implements TemplateManageApi { public List findCategories(TemplateManageRequest request) { return extTemplateMapper.findCategories(request); } + @Override public void batchUpdate(TemplateManageBatchRequest request) { - request.getTemplateIds().forEach(templateId ->{ + request.getTemplateIds().forEach(templateId -> { // 分类映射删除 - extTemplateMapper.deleteCategoryMapByTemplate(null,templateId); + extTemplateMapper.deleteCategoryMapByTemplate(null, templateId); // 插入分类关系 request.getCategories().forEach(categoryId -> { VisualizationTemplateCategoryMap categoryMap = new VisualizationTemplateCategoryMap(); @@ -281,7 +291,7 @@ public class TemplateManageService implements TemplateManageApi { @Override public void batchDelete(TemplateManageBatchRequest request) { - request.getTemplateIds().forEach(templateId ->{ + request.getTemplateIds().forEach(templateId -> { request.getCategories().forEach(categoryId -> { QueryWrapper queryWrapper = new QueryWrapper<>(); queryWrapper.eq("template_id", templateId); diff --git a/core/core-backend/src/main/resources/mybatis/ExtVisualizationTemplateMapper.xml b/core/core-backend/src/main/resources/mybatis/ExtVisualizationTemplateMapper.xml index c4598a13ad..89873f9728 100644 --- a/core/core-backend/src/main/resources/mybatis/ExtVisualizationTemplateMapper.xml +++ b/core/core-backend/src/main/resources/mybatis/ExtVisualizationTemplateMapper.xml @@ -137,4 +137,18 @@ from visualization_template_category_map where template_id = #{templateId} + + diff --git a/core/core-frontend/src/api/template.ts b/core/core-frontend/src/api/template.ts index 7905059df2..75302e7d32 100644 --- a/core/core-frontend/src/api/template.ts +++ b/core/core-frontend/src/api/template.ts @@ -75,3 +75,10 @@ export function batchUpdate(data) { data: data }) } + +export function findCategoriesByTemplateIds(data) { + return request.post({ + url: '/templateManage/findCategoriesByTemplateIds', + data: data + }) +} diff --git a/core/core-frontend/src/views/template/component/DeCategoryChange.vue b/core/core-frontend/src/views/template/component/DeCategoryChange.vue index ca850a0b50..c55110331b 100644 --- a/core/core-frontend/src/views/template/component/DeCategoryChange.vue +++ b/core/core-frontend/src/views/template/component/DeCategoryChange.vue @@ -34,7 +34,7 @@