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 @@