From 87921b27d57a8bc4a3a6bc30ed8b1061235db108 Mon Sep 17 00:00:00 2001 From: wangjiahao <1522128093@qq.com> Date: Fri, 22 Dec 2023 14:51:31 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=20=E4=BC=98=E5=8C=96=E6=A8=A1?= =?UTF-8?q?=E7=89=88=E7=AE=A1=E7=90=86=E6=89=B9=E9=87=8F=E6=93=8D=E4=BD=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/TemplateManageService.java | 36 ++++++++ core/core-frontend/src/api/template.ts | 14 +++ .../template/component/DeCategoryChange.vue | 86 +++++++++++++++++++ .../src/views/template/index.vue | 78 +++++++++++++++-- .../api/template/TemplateManageApi.java | 7 ++ .../request/TemplateManageBatchRequest.java | 21 +++++ 6 files changed, 237 insertions(+), 5 deletions(-) create mode 100644 core/core-frontend/src/views/template/component/DeCategoryChange.vue create mode 100644 sdk/api/api-base/src/main/java/io/dataease/api/template/request/TemplateManageBatchRequest.java 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 d499c33c0b..b679119b93 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 @@ -3,6 +3,7 @@ package io.dataease.template.service; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import io.dataease.api.template.TemplateManageApi; import io.dataease.api.template.dto.TemplateManageDTO; +import io.dataease.api.template.request.TemplateManageBatchRequest; import io.dataease.api.template.request.TemplateManageRequest; import io.dataease.api.template.vo.VisualizationTemplateVO; import io.dataease.constant.CommonConstants; @@ -262,4 +263,39 @@ public class TemplateManageService implements TemplateManageApi { public List findCategories(TemplateManageRequest request) { return extTemplateMapper.findCategories(request); } + @Override + public void batchUpdate(TemplateManageBatchRequest request) { + request.getTemplateIds().forEach(templateId ->{ + // 分类映射删除 + extTemplateMapper.deleteCategoryMapByTemplate(null,templateId); + // 插入分类关系 + request.getCategories().forEach(categoryId -> { + VisualizationTemplateCategoryMap categoryMap = new VisualizationTemplateCategoryMap(); + categoryMap.setId(UUID.randomUUID().toString()); + categoryMap.setCategoryId(categoryId); + categoryMap.setTemplateId(templateId); + categoryMapMapper.insert(categoryMap); + }); + }); + } + + @Override + public void batchDelete(TemplateManageBatchRequest request) { + request.getTemplateIds().forEach(templateId ->{ + request.getCategories().forEach(categoryId -> { + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.eq("template_id", templateId); + queryWrapper.eq("category_id", categoryId); + categoryMapMapper.delete(queryWrapper); + // 如何是最后一个 则实际模版需要删除 + Long result = extTemplateMapper.checkRepeatTemplateId(categoryId, templateId); + if (result == 0) { + templateMapper.deleteById(templateId); + } + }); + + }); + } } + + diff --git a/core/core-frontend/src/api/template.ts b/core/core-frontend/src/api/template.ts index d1b0033400..7905059df2 100644 --- a/core/core-frontend/src/api/template.ts +++ b/core/core-frontend/src/api/template.ts @@ -61,3 +61,17 @@ export function categoryTemplateNameCheck(data) { data: data }) } + +export function batchDelete(data) { + return request.post({ + url: '/templateManage/batchDelete', + data: data + }) +} + +export function batchUpdate(data) { + return request.post({ + url: '/templateManage/batchUpdate', + data: data + }) +} diff --git a/core/core-frontend/src/views/template/component/DeCategoryChange.vue b/core/core-frontend/src/views/template/component/DeCategoryChange.vue new file mode 100644 index 0000000000..23264445a0 --- /dev/null +++ b/core/core-frontend/src/views/template/component/DeCategoryChange.vue @@ -0,0 +1,86 @@ + + + + + diff --git a/core/core-frontend/src/views/template/index.vue b/core/core-frontend/src/views/template/index.vue index e96d401951..9710cdedde 100644 --- a/core/core-frontend/src/views/template/index.vue +++ b/core/core-frontend/src/views/template/index.vue @@ -71,7 +71,7 @@ 修改分类 - 批量删除 + 批量删除 已选 {{ batchState }} 项 全选 {{ currentTemplateShowListComputed.length }} 项 + + + + + + + + + +