diff --git a/core/core-backend/src/main/java/io/dataease/MybatisPlusGenerator.java b/core/core-backend/src/main/java/io/dataease/MybatisPlusGenerator.java index 3007bbcb9c..e518a888f6 100644 --- a/core/core-backend/src/main/java/io/dataease/MybatisPlusGenerator.java +++ b/core/core-backend/src/main/java/io/dataease/MybatisPlusGenerator.java @@ -21,11 +21,11 @@ public class MybatisPlusGenerator { /** * 业务模块例如datasource,dataset,panel等 */ - private static final String busi = "operation"; + private static final String busi = "template"; /** * 这是要生成代码的表名称 */ - private static final String TABLE_NAME = "core_opt_recent"; + private static final String TABLE_NAME = "visualization_template_category_map"; /** * 下面两个配置基本上不用动 diff --git a/core/core-backend/src/main/java/io/dataease/template/dao/auto/entity/VisualizationTemplateCategory.java b/core/core-backend/src/main/java/io/dataease/template/dao/auto/entity/VisualizationTemplateCategory.java new file mode 100644 index 0000000000..e7b5ceb0b2 --- /dev/null +++ b/core/core-backend/src/main/java/io/dataease/template/dao/auto/entity/VisualizationTemplateCategory.java @@ -0,0 +1,161 @@ +package io.dataease.template.dao.auto.entity; + +import com.baomidou.mybatisplus.annotation.TableName; +import java.io.Serializable; + +/** + *

+ * 模板表 + *

+ * + * @author fit2cloud + * @since 2023-12-04 + */ +@TableName("visualization_template_category") +public class VisualizationTemplateCategory implements Serializable { + + private static final long serialVersionUID = 1L; + + /** + * 主键 + */ + private String id; + + /** + * 名称 + */ + private String name; + + /** + * 父级id + */ + private String pid; + + /** + * 层级 + */ + private Integer level; + + /** + * 模版种类 dataV or dashboard 目录或者文件夹 + */ + private String dvType; + + /** + * 节点类型 folder or panel 目录或者文件夹 + */ + private String nodeType; + + /** + * 创建人 + */ + private String createBy; + + /** + * 创建时间 + */ + private Long createTime; + + /** + * 缩略图 + */ + private String snapshot; + + private String templateType; + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getPid() { + return pid; + } + + public void setPid(String pid) { + this.pid = pid; + } + + public Integer getLevel() { + return level; + } + + public void setLevel(Integer level) { + this.level = level; + } + + public String getDvType() { + return dvType; + } + + public void setDvType(String dvType) { + this.dvType = dvType; + } + + public String getNodeType() { + return nodeType; + } + + public void setNodeType(String nodeType) { + this.nodeType = nodeType; + } + + public String getCreateBy() { + return createBy; + } + + public void setCreateBy(String createBy) { + this.createBy = createBy; + } + + public Long getCreateTime() { + return createTime; + } + + public void setCreateTime(Long createTime) { + this.createTime = createTime; + } + + public String getSnapshot() { + return snapshot; + } + + public void setSnapshot(String snapshot) { + this.snapshot = snapshot; + } + + public String getTemplateType() { + return templateType; + } + + public void setTemplateType(String templateType) { + this.templateType = templateType; + } + + @Override + public String toString() { + return "VisualizationTemplateCategory{" + + "id = " + id + + ", name = " + name + + ", pid = " + pid + + ", level = " + level + + ", dvType = " + dvType + + ", nodeType = " + nodeType + + ", createBy = " + createBy + + ", createTime = " + createTime + + ", snapshot = " + snapshot + + ", templateType = " + templateType + + "}"; + } +} diff --git a/core/core-backend/src/main/java/io/dataease/template/dao/auto/entity/VisualizationTemplateCategoryMap.java b/core/core-backend/src/main/java/io/dataease/template/dao/auto/entity/VisualizationTemplateCategoryMap.java new file mode 100644 index 0000000000..2bb17c81d8 --- /dev/null +++ b/core/core-backend/src/main/java/io/dataease/template/dao/auto/entity/VisualizationTemplateCategoryMap.java @@ -0,0 +1,66 @@ +package io.dataease.template.dao.auto.entity; + +import com.baomidou.mybatisplus.annotation.TableName; +import java.io.Serializable; + +/** + *

+ * 模板表 + *

+ * + * @author fit2cloud + * @since 2023-12-04 + */ +@TableName("visualization_template_category_map") +public class VisualizationTemplateCategoryMap implements Serializable { + + private static final long serialVersionUID = 1L; + + /** + * 主键 + */ + private String id; + + /** + * 名称 + */ + private String categoryId; + + /** + * 父级id + */ + private String templateId; + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getCategoryId() { + return categoryId; + } + + public void setCategoryId(String categoryId) { + this.categoryId = categoryId; + } + + public String getTemplateId() { + return templateId; + } + + public void setTemplateId(String templateId) { + this.templateId = templateId; + } + + @Override + public String toString() { + return "VisualizationTemplateCategoryMap{" + + "id = " + id + + ", categoryId = " + categoryId + + ", templateId = " + templateId + + "}"; + } +} diff --git a/core/core-backend/src/main/java/io/dataease/template/dao/auto/mapper/VisualizationTemplateCategoryMapMapper.java b/core/core-backend/src/main/java/io/dataease/template/dao/auto/mapper/VisualizationTemplateCategoryMapMapper.java new file mode 100644 index 0000000000..bf8c10b2d9 --- /dev/null +++ b/core/core-backend/src/main/java/io/dataease/template/dao/auto/mapper/VisualizationTemplateCategoryMapMapper.java @@ -0,0 +1,18 @@ +package io.dataease.template.dao.auto.mapper; + +import io.dataease.template.dao.auto.entity.VisualizationTemplateCategoryMap; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import org.apache.ibatis.annotations.Mapper; + +/** + *

+ * 模板表 Mapper 接口 + *

+ * + * @author fit2cloud + * @since 2023-12-04 + */ +@Mapper +public interface VisualizationTemplateCategoryMapMapper extends BaseMapper { + +} diff --git a/core/core-backend/src/main/java/io/dataease/template/dao/auto/mapper/VisualizationTemplateCategoryMapper.java b/core/core-backend/src/main/java/io/dataease/template/dao/auto/mapper/VisualizationTemplateCategoryMapper.java new file mode 100644 index 0000000000..939345a4c7 --- /dev/null +++ b/core/core-backend/src/main/java/io/dataease/template/dao/auto/mapper/VisualizationTemplateCategoryMapper.java @@ -0,0 +1,18 @@ +package io.dataease.template.dao.auto.mapper; + +import io.dataease.template.dao.auto.entity.VisualizationTemplateCategory; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import org.apache.ibatis.annotations.Mapper; + +/** + *

+ * 模板表 Mapper 接口 + *

+ * + * @author fit2cloud + * @since 2023-12-04 + */ +@Mapper +public interface VisualizationTemplateCategoryMapper extends BaseMapper { + +} 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 51021a4388..aab0d1be59 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 @@ -12,6 +12,9 @@ import java.util.List; public interface ExtVisualizationTemplateMapper{ List findTemplateList(TemplateManageRequest request); - List findBaseTemplateList(@Param("nodeType") String nodeType); + + List findCategories(TemplateManageRequest request); + + List findBaseTemplateList(); } diff --git a/core/core-backend/src/main/java/io/dataease/template/manage/TemplateCenterManage.java b/core/core-backend/src/main/java/io/dataease/template/manage/TemplateCenterManage.java index f446ff2c24..85d631dfca 100644 --- a/core/core-backend/src/main/java/io/dataease/template/manage/TemplateCenterManage.java +++ b/core/core-backend/src/main/java/io/dataease/template/manage/TemplateCenterManage.java @@ -11,6 +11,8 @@ import io.dataease.constant.CommonConstants; import io.dataease.exception.DEException; import io.dataease.operation.manage.CoreOptRecentManage; import io.dataease.system.manage.SysParameterManage; +import io.dataease.template.dao.auto.entity.VisualizationTemplateCategoryMap; +import io.dataease.template.dao.auto.mapper.VisualizationTemplateCategoryMapMapper; import io.dataease.template.dao.ext.ExtVisualizationTemplateMapper; import io.dataease.utils.HttpClientConfig; import io.dataease.utils.HttpClientUtil; @@ -19,6 +21,7 @@ import io.dataease.utils.LogUtil; import jakarta.annotation.Resource; import org.apache.commons.lang3.StringUtils; import org.springframework.stereotype.Service; +import org.springframework.util.CollectionUtils; import java.util.*; import java.util.function.Function; @@ -40,6 +43,9 @@ public class TemplateCenterManage { @Resource private ExtVisualizationTemplateMapper templateManageMapper; + @Resource + private VisualizationTemplateCategoryMapMapper categoryMapMapper; + /** * @param templateUrl template url * @Description Get template file from template market @@ -88,8 +94,8 @@ public class TemplateCenterManage { private List searchTemplateFromManage() { try { - List manageResult = templateManageMapper.findBaseTemplateList("template"); - List categories = templateManageMapper.findBaseTemplateList("folder"); + List manageResult = templateManageMapper.findBaseTemplateList(); + List categories = templateManageMapper.findCategories(null); Map categoryMap = categories.stream() .collect(Collectors.toMap(TemplateManageDTO::getId, TemplateManageDTO::getName)); return baseManage2MarketTrans(manageResult, categoryMap); @@ -103,7 +109,12 @@ public class TemplateCenterManage { List result = new ArrayList<>(); manageResult.stream().forEach(templateManageDTO -> { templateManageDTO.setCategoryName(categoryMap.get(templateManageDTO.getPid())); - result.add(new TemplateMarketDTO(templateManageDTO)); + List categories = templateManageDTO.getCategories(); + if(!CollectionUtils.isEmpty(categories)){ + List categoryNames = categories.stream().map(categoryId ->categoryMap.get(categoryId)).collect(Collectors.toList()); + templateManageDTO.setCategoryNames(categoryNames); + result.add(new TemplateMarketDTO(templateManageDTO)); + } }); return result; } @@ -178,7 +189,7 @@ public class TemplateCenterManage { contents.stream().forEach(templateMarketDTO -> { Long recentUseTime = useTime.get(templateMarketDTO.getId()); templateMarketDTO.setRecentUseTime(recentUseTime == null ? 0 : recentUseTime); - activeCategoriesName.add(templateMarketDTO.getMainCategory()); + activeCategoriesName.addAll(templateMarketDTO.getCategoryNames()); }); if (v2BaseResponse != null) { v2BaseResponse.getItems().stream().forEach(marketTemplateV2ItemResult -> { @@ -214,7 +225,7 @@ public class TemplateCenterManage { public List getCategoriesV2() { List allCategories = new ArrayList<>(); - List manageCategories = templateManageMapper.findBaseTemplateList("folder"); + List manageCategories = templateManageMapper.findCategories(null); List manageCategoriesTrans = manageCategories.stream() .map(templateCategory -> new MarketMetaDataVO(templateCategory.getId(), templateCategory.getName(), CommonConstants.TEMPLATE_SOURCE.MANAGE)) .collect(Collectors.toList()); 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 bc70d8d4f6..295f0ff262 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 @@ -8,6 +8,10 @@ import io.dataease.api.template.vo.VisualizationTemplateVO; import io.dataease.constant.CommonConstants; import io.dataease.exception.DEException; import io.dataease.template.dao.auto.entity.VisualizationTemplate; +import io.dataease.template.dao.auto.entity.VisualizationTemplateCategory; +import io.dataease.template.dao.auto.entity.VisualizationTemplateCategoryMap; +import io.dataease.template.dao.auto.mapper.VisualizationTemplateCategoryMapMapper; +import io.dataease.template.dao.auto.mapper.VisualizationTemplateCategoryMapper; import io.dataease.template.dao.auto.mapper.VisualizationTemplateMapper; import io.dataease.template.dao.ext.ExtVisualizationTemplateMapper; import io.dataease.utils.AuthUtils; @@ -37,6 +41,11 @@ public class TemplateManageService implements TemplateManageApi { @Resource private VisualizationTemplateMapper templateMapper; + + @Resource + private VisualizationTemplateCategoryMapper templateCategoryMapper; + @Resource + private VisualizationTemplateCategoryMapMapper categoryMapMapper; @Resource private ExtVisualizationTemplateMapper extTemplateMapper; @Resource @@ -72,19 +81,6 @@ public class TemplateManageService implements TemplateManageApi { request.setId(UUID.randomUUID().toString()); request.setCreateTime(System.currentTimeMillis()); request.setCreateBy(AuthUtils.getUser().getUserId().toString()); - //如果level 是0(第一级)指的是分类目录 设置父级为对应的templateType - if (request.getLevel() == 0) { - request.setPid(request.getTemplateType()); - String nameCheckResult = this.nameCheck(CommonConstants.OPT_TYPE.INSERT, request.getName(), request.getPid(), null); - if (CommonConstants.CHECK_RESULT.EXIST_ALL.equals(nameCheckResult)) { - DEException.throwException("名称已存在"); - } - } else {//模板插入 相同文件夹同名的模板进行覆盖(先删除) - QueryWrapper wrapper = new QueryWrapper<>(); - wrapper.eq("pid",request.getPid()); - wrapper.eq("name",request.getName()); - templateMapper.delete(wrapper); - } if ("template".equals(request.getNodeType())) { //Store static resource into the server staticResourceServer.saveFilesToServe(request.getStaticResource()); @@ -92,18 +88,52 @@ public class TemplateManageService implements TemplateManageApi { staticResourceServer.saveSingleFileToServe(snapshotName, request.getSnapshot().replace("data:image/jpeg;base64,", "")); request.setSnapshot("/" + UPLOAD_URL_PREFIX + '/' + snapshotName); } + //如果level 是0(第一级)指的是分类目录 设置父级为对应的templateType + if (request.getLevel() == 0) { + request.setPid(request.getTemplateType()); + String nameCheckResult = this.categoryNameCheck(CommonConstants.OPT_TYPE.INSERT, request.getName(), null); + if (CommonConstants.CHECK_RESULT.EXIST_ALL.equals(nameCheckResult)) { + DEException.throwException("名称已存在"); + } + VisualizationTemplateCategory templateCategory = new VisualizationTemplateCategory(); + BeanUtils.copyBean(templateCategory,request); + templateCategoryMapper.insert(templateCategory); + } else {//模板插入 同名的模板进行覆盖(先删除) + QueryWrapper wrapper = new QueryWrapper<>(); + wrapper.eq("name",request.getName()); + templateMapper.delete(wrapper); + VisualizationTemplate template = new VisualizationTemplate(); + BeanUtils.copyBean(template,request); + templateMapper.insert(template); + // 插入分类关系 + request.getCategories().forEach(categoryId ->{ + VisualizationTemplateCategoryMap categoryMap = new VisualizationTemplateCategoryMap(); + categoryMap.setId(UUID.randomUUID().toString()); + categoryMap.setCategoryId(categoryId); + categoryMap.setTemplateId(template.getId()); + categoryMapMapper.insert(categoryMap); + }); - VisualizationTemplate template = new VisualizationTemplate(); - BeanUtils.copyBean(template,request); - templateMapper.insert(template); - } else { - String nameCheckResult = this.nameCheck(CommonConstants.OPT_TYPE.UPDATE, request.getName(), request.getPid(), request.getId()); - if (CommonConstants.CHECK_RESULT.EXIST_ALL.equals(nameCheckResult)) { - DEException.throwException("名称已存在"); } - VisualizationTemplate template = new VisualizationTemplate(); - BeanUtils.copyBean(template,request); - templateMapper.updateById(template); + } else { + if (request.getLevel() == 0) { + String nameCheckResult = this.categoryNameCheck(CommonConstants.OPT_TYPE.UPDATE, request.getName(), request.getId()); + if (CommonConstants.CHECK_RESULT.EXIST_ALL.equals(nameCheckResult)) { + DEException.throwException("名称已存在"); + } + VisualizationTemplateCategory templateCategory = new VisualizationTemplateCategory(); + BeanUtils.copyBean(templateCategory,request); + templateCategoryMapper.updateById(templateCategory); + }else{ + String nameCheckResult = this.nameCheck(CommonConstants.OPT_TYPE.UPDATE, request.getName(), request.getId()); + if (CommonConstants.CHECK_RESULT.EXIST_ALL.equals(nameCheckResult)) { + DEException.throwException("名称已存在"); + } + VisualizationTemplate template = new VisualizationTemplate(); + BeanUtils.copyBean(template,request); + templateMapper.updateById(template); + } + } TemplateManageDTO templateManageDTO = new TemplateManageDTO(); BeanUtils.copyBean(templateManageDTO, request); @@ -112,13 +142,11 @@ public class TemplateManageService implements TemplateManageApi { } //名称检查 - public String nameCheck(String optType, String name, String pid, String id) { + public String nameCheck(String optType, String name,String id) { QueryWrapper wrapper = new QueryWrapper<>(); if (CommonConstants.OPT_TYPE.INSERT.equals(optType)) { - wrapper.eq("pid",pid); wrapper.eq("name",name); } else if (CommonConstants.OPT_TYPE.UPDATE.equals(optType)) { - wrapper.eq("pid",pid); wrapper.eq("name",name); wrapper.ne("id",id); } @@ -129,10 +157,26 @@ public class TemplateManageService implements TemplateManageApi { return CommonConstants.CHECK_RESULT.EXIST_ALL; } } + + //名称检查 + public String categoryNameCheck(String optType, String name, String id) { + QueryWrapper wrapper = new QueryWrapper<>(); + if (CommonConstants.OPT_TYPE.INSERT.equals(optType)) { + wrapper.eq("name",name); + } else if (CommonConstants.OPT_TYPE.UPDATE.equals(optType)) { + wrapper.eq("name",name); + wrapper.ne("id",id); + } + List templateList = templateCategoryMapper.selectList(wrapper); + if (CollectionUtils.isEmpty(templateList)) { + return CommonConstants.CHECK_RESULT.NONE; + } else { + return CommonConstants.CHECK_RESULT.EXIST_ALL; + } + } @Override public String nameCheck(TemplateManageRequest request) { - return nameCheck(request.getOptType(), request.getName(), request.getPid(), request.getId()); - + return nameCheck(request.getOptType(), request.getName(), request.getId()); } @Override public void delete(String id) { @@ -140,6 +184,11 @@ public class TemplateManageService implements TemplateManageApi { templateMapper.deleteById(id); } @Override + public void deleteCategory(String id) { + Assert.notNull(id, "id cannot be null"); + templateCategoryMapper.deleteById(id); + } + @Override public VisualizationTemplateVO findOne(String templateId) { VisualizationTemplate template = templateMapper.selectById(templateId); if(template != null){ @@ -155,4 +204,8 @@ public class TemplateManageService implements TemplateManageApi { return extTemplateMapper.findTemplateList(request); } + @Override + public List findCategories(TemplateManageRequest request) { + return extTemplateMapper.findCategories(request); + } } diff --git a/core/core-backend/src/main/resources/db/desktop/V2.1__ddl.sql b/core/core-backend/src/main/resources/db/desktop/V2.1__ddl.sql index 7407153084..987569eb3d 100644 --- a/core/core-backend/src/main/resources/db/desktop/V2.1__ddl.sql +++ b/core/core-backend/src/main/resources/db/desktop/V2.1__ddl.sql @@ -1,38 +1,73 @@ DROP TABLE IF EXISTS `visualization_template`; CREATE TABLE `visualization_template` ( - `id` varchar(50) NOT NULL COMMENT '主键', - `name` varchar(255) DEFAULT NULL COMMENT '名称', - `pid` varchar(255) DEFAULT NULL COMMENT '父级id', - `level` int(10) DEFAULT NULL COMMENT '层级', - `dv_type` varchar(255) DEFAULT NULL COMMENT '模板种类 dataV or dashboard 目录或者文件夹', - `node_type` varchar(255) DEFAULT NULL COMMENT '节点类型 folder or panel 目录或者文件夹', - `create_by` varchar(255) DEFAULT NULL COMMENT '创建人', - `create_time` bigint(13) DEFAULT NULL COMMENT '创建时间', - `snapshot` longtext COMMENT '缩略图', - `template_type` varchar(255) DEFAULT NULL COMMENT '模板类型 system 系统内置 self 用户自建 ', - `template_style` longtext COMMENT 'template 样式', - `template_data` longtext COMMENT 'template 数据', - `dynamic_data` longtext COMMENT '预存数据', - PRIMARY KEY (`id`) -); + `id` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '主键', + `name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT '名称', + `pid` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT '父级id', + `level` int DEFAULT NULL COMMENT '层级', + `dv_type` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT '模版种类 dataV or dashboard 目录或者文件夹', + `node_type` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT '节点类型 folder or panel 目录或者文件夹', + `create_by` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT '创建人', + `create_time` bigint DEFAULT NULL COMMENT '创建时间', + `snapshot` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci COMMENT '缩略图', + `template_type` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT '模版类型 system 系统内置 self 用户自建 ', + `template_style` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci COMMENT 'template 样式', + `template_data` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci COMMENT 'template 数据', + `dynamic_data` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci COMMENT '预存数据', + PRIMARY KEY (`id`) USING BTREE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='模板表'; -BEGIN; -INSERT INTO `core_menu` -VALUES (19, 0, 2, 'template-market', 'template-market', 4, NULL, '/template-market', 1, 1, 0); -INSERT INTO `core_menu` -VALUES (20, 15, 2, 'template-setting', 'system/template-setting', 4, 'icon_template', '/template-setting', 0, 1, 1); -COMMIT; +-- ---------------------------- +-- Table structure for visualization_template_category +-- ---------------------------- +DROP TABLE IF EXISTS `visualization_template_category`; +CREATE TABLE `visualization_template_category` ( + `id` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '主键', + `name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT '名称', + `pid` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT '父级id', + `level` int DEFAULT NULL COMMENT '层级', + `dv_type` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT '模版种类 dataV or dashboard 目录或者文件夹', + `node_type` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT '节点类型 folder or panel 目录或者文件夹', + `create_by` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT '创建人', + `create_time` bigint DEFAULT NULL COMMENT '创建时间', + `snapshot` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci COMMENT '缩略图', + `template_type` varchar(255) DEFAULT NULL, + PRIMARY KEY (`id`) USING BTREE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='模板表'; +-- ---------------------------- +-- Table structure for visualization_template_category_map +-- ---------------------------- +DROP TABLE IF EXISTS `visualization_template_category_map`; +CREATE TABLE `visualization_template_category_map` ( + `id` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '主键', + `category_id` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT '名称', + `template_id` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT '父级id', + PRIMARY KEY (`id`) USING BTREE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='模板表'; + +-- ---------------------------- +-- Table structure for visualization_template_extend_data +-- ---------------------------- DROP TABLE IF EXISTS `visualization_template_extend_data`; CREATE TABLE `visualization_template_extend_data` ( `id` bigint NOT NULL, `dv_id` bigint DEFAULT NULL, `view_id` bigint DEFAULT NULL, - `view_details` longtext, - `copy_from` varchar(255) DEFAULT NULL, - `copy_id` varchar(255) DEFAULT NULL, - PRIMARY KEY (`id`) -); + `view_details` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci, + `copy_from` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL, + `copy_id` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL, + PRIMARY KEY (`id`) USING BTREE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci; + +BEGIN; +INSERT INTO `core_menu` +VALUES (19, 0, 2, 'template-market', 'template-market', 4, NULL, '/template-market', 1, 1, 0); +INSERT INTO `core_menu` +VALUES (30, 0, 1, 'toolbox', null, 7, 'icon_template', '/toolbox', 1, 1, 0); +INSERT INTO `core_menu` +VALUES (31, 30, 2, 'template-setting', 'toolbox/template-setting', 1, 'icon_template', '/template-setting', 0, 1, 1); +COMMIT; + ALTER TABLE `core_opt_recent` MODIFY COLUMN `resource_id` bigint NULL COMMENT '资源ID' AFTER `id`, diff --git a/core/core-backend/src/main/resources/db/migration/V2.1__ddl.sql b/core/core-backend/src/main/resources/db/migration/V2.1__ddl.sql index 5567701ebf..350529c7bb 100644 --- a/core/core-backend/src/main/resources/db/migration/V2.1__ddl.sql +++ b/core/core-backend/src/main/resources/db/migration/V2.1__ddl.sql @@ -1,22 +1,63 @@ DROP TABLE IF EXISTS `visualization_template`; -CREATE TABLE `visualization_template` -( - `id` varchar(50) NOT NULL COMMENT '主键', - `name` varchar(255) DEFAULT NULL COMMENT '名称', - `pid` varchar(255) DEFAULT NULL COMMENT '父级id', - `level` int(10) DEFAULT NULL COMMENT '层级', - `dv_type` varchar(255) DEFAULT NULL COMMENT '模板种类 dataV or dashboard 目录或者文件夹', - `node_type` varchar(255) DEFAULT NULL COMMENT '节点类型 folder or panel 目录或者文件夹', - `create_by` varchar(255) DEFAULT NULL COMMENT '创建人', - `create_time` bigint(13) DEFAULT NULL COMMENT '创建时间', - `snapshot` longtext COMMENT '缩略图', - `template_type` varchar(255) DEFAULT NULL COMMENT '模板类型 system 系统内置 self 用户自建 ', - `template_style` longtext COMMENT 'template 样式', - `template_data` longtext COMMENT 'template 数据', - `dynamic_data` longtext COMMENT '预存数据', - PRIMARY KEY (`id`) -) ENGINE = InnoDB - DEFAULT CHARSET = utf8mb4 COMMENT ='模板表'; +CREATE TABLE `visualization_template` ( + `id` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '主键', + `name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT '名称', + `pid` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT '父级id', + `level` int DEFAULT NULL COMMENT '层级', + `dv_type` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT '模版种类 dataV or dashboard 目录或者文件夹', + `node_type` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT '节点类型 folder or panel 目录或者文件夹', + `create_by` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT '创建人', + `create_time` bigint DEFAULT NULL COMMENT '创建时间', + `snapshot` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci COMMENT '缩略图', + `template_type` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT '模版类型 system 系统内置 self 用户自建 ', + `template_style` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci COMMENT 'template 样式', + `template_data` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci COMMENT 'template 数据', + `dynamic_data` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci COMMENT '预存数据', + PRIMARY KEY (`id`) USING BTREE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='模板表'; + +-- ---------------------------- +-- Table structure for visualization_template_category +-- ---------------------------- +DROP TABLE IF EXISTS `visualization_template_category`; +CREATE TABLE `visualization_template_category` ( + `id` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '主键', + `name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT '名称', + `pid` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT '父级id', + `level` int DEFAULT NULL COMMENT '层级', + `dv_type` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT '模版种类 dataV or dashboard 目录或者文件夹', + `node_type` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT '节点类型 folder or panel 目录或者文件夹', + `create_by` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT '创建人', + `create_time` bigint DEFAULT NULL COMMENT '创建时间', + `snapshot` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci COMMENT '缩略图', + `template_type` varchar(255) DEFAULT NULL, + PRIMARY KEY (`id`) USING BTREE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='模板表'; + +-- ---------------------------- +-- Table structure for visualization_template_category_map +-- ---------------------------- +DROP TABLE IF EXISTS `visualization_template_category_map`; +CREATE TABLE `visualization_template_category_map` ( + `id` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '主键', + `category_id` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT '名称', + `template_id` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT '父级id', + PRIMARY KEY (`id`) USING BTREE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='模板表'; + +-- ---------------------------- +-- Table structure for visualization_template_extend_data +-- ---------------------------- +DROP TABLE IF EXISTS `visualization_template_extend_data`; +CREATE TABLE `visualization_template_extend_data` ( + `id` bigint NOT NULL, + `dv_id` bigint DEFAULT NULL, + `view_id` bigint DEFAULT NULL, + `view_details` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci, + `copy_from` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL, + `copy_id` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL, + PRIMARY KEY (`id`) USING BTREE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci; BEGIN; INSERT INTO `core_menu` @@ -27,18 +68,6 @@ INSERT INTO `core_menu` VALUES (31, 30, 2, 'template-setting', 'toolbox/template-setting', 1, 'icon_template', '/template-setting', 0, 1, 1); COMMIT; -DROP TABLE IF EXISTS `visualization_template_extend_data`; -CREATE TABLE `visualization_template_extend_data` -( - `id` bigint NOT NULL, - `dv_id` bigint DEFAULT NULL, - `view_id` bigint DEFAULT NULL, - `view_details` longtext, - `copy_from` varchar(255) DEFAULT NULL, - `copy_id` varchar(255) DEFAULT NULL, - PRIMARY KEY (`id`) -); - ALTER TABLE `core_opt_recent` MODIFY COLUMN `resource_id` bigint NULL COMMENT '资源ID' AFTER `id`, diff --git a/core/core-backend/src/main/resources/mybatis/ExtVisualizationTemplateMapper.xml b/core/core-backend/src/main/resources/mybatis/ExtVisualizationTemplateMapper.xml index 05898e3bd6..1971a6d26b 100644 --- a/core/core-backend/src/main/resources/mybatis/ExtVisualizationTemplateMapper.xml +++ b/core/core-backend/src/main/resources/mybatis/ExtVisualizationTemplateMapper.xml @@ -7,6 +7,7 @@ + @@ -23,77 +24,68 @@ + + + + + + - visualization_template.id, visualization_template.`name`, visualization_template.pid, visualization_template.`level`,visualization_template.`dv_type`, visualization_template.node_type, visualization_template.create_by, visualization_template.create_time, visualization_template.template_type, visualization_template.snapshot + vt.id, vt.`name`, vt.pid, vt.`level`,vt.`dv_type`, vt.node_type, vt.create_by, vt.create_time, vt.template_type, vt.snapshot - visualization_template.template_style, visualization_template.template_data, visualization_template.dynamic_data + ,vt.template_style, vt.template_data, vt.dynamic_data - SELECT - + vt.id, + vt.`name`, + vt.pid, + vt.`level`, + vt.`dv_type`, + vt.node_type, + vt.create_by, + vt.create_time, + vt.template_type, + vt.SNAPSHOT, + vtcm.category_id FROM - visualization_template - - - and visualization_template.node_type = #{nodeType} - - - order by visualization_template.create_time desc + visualization_template vt + LEFT JOIN visualization_template_category_map vtcm ON vt.id = vtcm.template_id + ORDER BY + vt.create_time DESC + + + diff --git a/core/core-frontend/src/api/template.ts b/core/core-frontend/src/api/template.ts index 320cc93401..a9f48b0fe9 100644 --- a/core/core-frontend/src/api/template.ts +++ b/core/core-frontend/src/api/template.ts @@ -13,6 +13,12 @@ export function templateDelete(id) { }) } +export function deleteCategory(id) { + return request.post({ + url: '/templateManage/deleteCategory/' + id + }) +} + export function showTemplateList(data) { return request.post({ url: '/templateManage/templateList', @@ -34,6 +40,14 @@ export function find(data) { }) } +export function findCategories(data) { + return request.post({ + url: '/templateManage/findCategories', + data: data, + loading: true + }) +} + export function nameCheck(data) { return request.post({ url: '/templateManage/nameCheck', diff --git a/core/core-frontend/src/assets/preheat.gif b/core/core-frontend/src/assets/preheat.gif deleted file mode 100644 index ea77d9a357..0000000000 Binary files a/core/core-frontend/src/assets/preheat.gif and /dev/null differ diff --git a/core/core-frontend/src/assets/preheat.png b/core/core-frontend/src/assets/preheat.png deleted file mode 100644 index 797e38af29..0000000000 Binary files a/core/core-frontend/src/assets/preheat.png and /dev/null differ diff --git a/core/core-frontend/src/custom-component/picture/Attr.vue b/core/core-frontend/src/custom-component/picture/Attr.vue index 5f79a958a1..ff1c824d1c 100644 --- a/core/core-frontend/src/custom-component/picture/Attr.vue +++ b/core/core-frontend/src/custom-component/picture/Attr.vue @@ -5,7 +5,7 @@ import { snapshotStoreWithOut } from '@/store/modules/data-visualization/snapsho import { storeToRefs } from 'pinia' import { ElIcon, ElMessage } from 'element-plus-secondary' -import { ref, onMounted, onBeforeUnmount } from 'vue' +import { ref, onMounted, onBeforeUnmount, watch } from 'vue' import { beforeUploadCheck, uploadFileResult } from '@/api/staticResource' import { imgUrlTrans } from '@/utils/imgUtils' import eventBus from '@/utils/eventBus' @@ -76,6 +76,14 @@ const init = () => { fileList.value = [] } } + +watch( + () => curComponent.value.propValue.url, + () => { + init() + } +) + onMounted(() => { init() eventBus.on('uploadImg', goFile) diff --git a/core/core-frontend/src/custom-component/picture/Component.vue b/core/core-frontend/src/custom-component/picture/Component.vue index c66942658d..025e37216c 100644 --- a/core/core-frontend/src/custom-component/picture/Component.vue +++ b/core/core-frontend/src/custom-component/picture/Component.vue @@ -1,6 +1,11 @@ @@ -403,7 +398,7 @@ onMounted(() => { background: #fff; width: 269px; border-right: 1px solid rgba(31, 35, 41, 0.15); - padding: 24px; + padding: 12px 8px; } .de-tabs-right { @@ -471,6 +466,5 @@ onMounted(() => { .template-search-class { float: right; width: 320px; - margin-right: 12px; } diff --git a/core/core-frontend/src/views/visualized/data/datasource/form/EditorDetail.vue b/core/core-frontend/src/views/visualized/data/datasource/form/EditorDetail.vue index 5a102dcf47..19ec595009 100644 --- a/core/core-frontend/src/views/visualized/data/datasource/form/EditorDetail.vue +++ b/core/core-frontend/src/views/visualized/data/datasource/form/EditorDetail.vue @@ -121,7 +121,7 @@ const initForm = type => { updateType: 'all_scope', syncRate: 'SIMPLE_CRON', simpleCronValue: '1', - simpleCronType: 'hour', + simpleCronType: 'minute', startTime: '', endTime: '', endLimit: '0', @@ -363,6 +363,7 @@ const onRateChange = () => { } if (form.value.syncSetting.syncRate === 'SIMPLE_CRON') { form.value.syncSetting.cron = '0 0 0/1 * * ? *' + form.value.syncSetting.simpleCronType = 'minute' } if (form.value.syncSetting.syncRate === 'CRON') { form.value.syncSetting.cron = '00 00 * ? * * *' diff --git a/core/core-frontend/src/views/visualized/data/datasource/form/index.vue b/core/core-frontend/src/views/visualized/data/datasource/form/index.vue index ff8f3f98e6..bcb4f3ae31 100644 --- a/core/core-frontend/src/views/visualized/data/datasource/form/index.vue +++ b/core/core-frontend/src/views/visualized/data/datasource/form/index.vue @@ -42,7 +42,7 @@ const { t } = useI18n() const creatDsFolder = ref() const router = useRouter() const { wsCache } = useCache() - +const dsLoading = ref(false) const state = reactive({ datasourceTree: [] }) @@ -394,21 +394,37 @@ const saveDS = () => { if (res) { ElMessageBox.confirm(t('datasource.has_same_ds'), options as ElMessageBoxOptions).then( () => { - save(request).then(res => { - if (res !== undefined) { - handleShowFinishPage({ id: res.id, name: res.name }) - ElMessage.success('保存数据源成功') - } - }) + if (dsLoading.value === true) { + return + } + dsLoading.value = true + save(request) + .then(res => { + if (res !== undefined) { + handleShowFinishPage({ id: res.id, name: res.name }) + ElMessage.success('保存数据源成功') + } + }) + .finally(() => { + dsLoading.value = false + }) } ) } else { - save(request).then(res => { - if (res !== undefined) { - handleShowFinishPage({ id: res.id, name: res.name }) - ElMessage.success('保存数据源成功') - } - }) + if (dsLoading.value === true) { + return + } + dsLoading.value = true + save(request) + .then(res => { + if (res !== undefined) { + handleShowFinishPage({ id: res.id, name: res.name }) + ElMessage.success('保存数据源成功') + } + }) + .finally(() => { + dsLoading.value = false + }) } }) } else { @@ -609,7 +625,7 @@ defineExpose({ -
+
{{ typeTitle }}
@@ -633,7 +649,7 @@ defineExpose({
-