From 77749e6c2e523d7a0d20f15253e21b732f2bcc59 Mon Sep 17 00:00:00 2001 From: ruying408 <1877972603@qq.com> Date: Sat, 29 Mar 2025 14:37:20 +0800 Subject: [PATCH] =?UTF-8?q?upgrade=EF=BC=9A=E5=8D=87=E7=BA=A78.0=E9=80=82?= =?UTF-8?q?=E9=85=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/cool/core/init/DBFromJsonInit.java | 16 +- .../sys/impl/BaseCodingServiceImpl.java | 6 +- src/main/resources/cool/data/menu/menu.json | 52 +----- .../resources/cool/data/menu/menu_8.0.json | 158 ++++++++++++++++++ 4 files changed, 178 insertions(+), 54 deletions(-) create mode 100644 src/main/resources/cool/data/menu/menu_8.0.json diff --git a/src/main/java/com/cool/core/init/DBFromJsonInit.java b/src/main/java/com/cool/core/init/DBFromJsonInit.java index 7498ad1..14fc10f 100644 --- a/src/main/java/com/cool/core/init/DBFromJsonInit.java +++ b/src/main/java/com/cool/core/init/DBFromJsonInit.java @@ -1,5 +1,6 @@ package com.cool.core.init; + import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.io.IoUtil; import cn.hutool.core.util.ObjUtil; @@ -14,6 +15,7 @@ import com.cool.modules.base.entity.sys.BaseSysMenuEntity; import com.cool.modules.base.service.sys.BaseSysConfService; import com.cool.modules.base.service.sys.BaseSysMenuService; import com.mybatisflex.core.BaseMapper; +import com.mybatisflex.core.query.QueryWrapper; import java.io.File; import java.io.IOException; import java.lang.reflect.InvocationTargetException; @@ -204,7 +206,19 @@ public class DBFromJsonInit { menuEntity.setParentName(parentMenuEntity.getName()); menuEntity.setParentId(parentMenuEntity.getId()); } - baseSysMenuService.add(menuEntity); + QueryWrapper queryWrapper = QueryWrapper.create() + .eq(BaseSysMenuEntity::getName, menuEntity.getName()); + if (ObjUtil.isNull(menuEntity.getParentId())) { + queryWrapper.isNull(BaseSysMenuEntity::getParentId); + } else { + queryWrapper.eq(BaseSysMenuEntity::getParentId, menuEntity.getParentId()); + } + BaseSysMenuEntity dbBaseSysMenuEntity = baseSysMenuService.getOne(queryWrapper); + if (ObjUtil.isNull(dbBaseSysMenuEntity)) { + baseSysMenuService.add(menuEntity); + } else { + menuEntity = dbBaseSysMenuEntity; + } // 递归处理子菜单 JSONArray childMenus = jsonObj.getJSONArray("childMenus"); if (childMenus != null) { diff --git a/src/main/java/com/cool/modules/base/service/sys/impl/BaseCodingServiceImpl.java b/src/main/java/com/cool/modules/base/service/sys/impl/BaseCodingServiceImpl.java index de438f1..627b35f 100644 --- a/src/main/java/com/cool/modules/base/service/sys/impl/BaseCodingServiceImpl.java +++ b/src/main/java/com/cool/modules/base/service/sys/impl/BaseCodingServiceImpl.java @@ -3,6 +3,7 @@ package com.cool.modules.base.service.sys.impl; import com.cool.core.exception.CoolPreconditions; import com.cool.modules.base.dto.sys.CodeContentDto; import com.cool.modules.base.service.sys.BaseCodingService; +import com.google.common.collect.Lists; import java.io.File; import java.io.FileWriter; import java.io.IOException; @@ -11,11 +12,10 @@ import java.nio.file.Path; import java.nio.file.Paths; import java.util.List; import java.util.stream.Collectors; - -import com.google.common.collect.Lists; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Service; + @Slf4j @Service public class BaseCodingServiceImpl implements BaseCodingService { @@ -69,6 +69,8 @@ public class BaseCodingServiceImpl implements BaseCodingService { } // 写入文件 try (FileWriter writer = new FileWriter(filePath.toFile())) { + formattedContent = formattedContent.replace("com.tangzc.mybatisflex.autotable.annotation.Index;", + "org.dromara.autotable.annotation.Index;"); writer.write(formattedContent); } list.add(filePath.toString()); diff --git a/src/main/resources/cool/data/menu/menu.json b/src/main/resources/cool/data/menu/menu.json index 8a62f75..5da8568 100644 --- a/src/main/resources/cool/data/menu/menu.json +++ b/src/main/resources/cool/data/menu/menu.json @@ -4,7 +4,7 @@ "router": "/sys", "perms": null, "type": 0, - "icon": "icon-system", + "icon": "icon-set", "orderNum": 2, "viewPath": null, "keepAlive": true, @@ -809,55 +809,5 @@ ] } ] - }, - { - "name": "扩展管理", - "router": null, - "perms": null, - "type": 0, - "icon": "icon-favor", - "orderNum": 8, - "viewPath": null, - "keepAlive": true, - "isShow": true, - "childMenus": [ - { - "name": "后端插件", - "router": "/helper/plugins/serve", - "perms": null, - "type": 1, - "icon": "icon-component", - "orderNum": 2, - "viewPath": "modules/helper/views/plugins/serve.vue", - "keepAlive": true, - "isShow": true, - "childMenus": [ - { - "name": "权限", - "router": null, - "perms": "plugin:info:install,plugin:info:delete,plugin:info:update,plugin:info:page,plugin:info:info", - "type": 2, - "icon": null, - "orderNum": 0, - "viewPath": null, - "keepAlive": true, - "isShow": true, - "childMenus": [] - } - ] - }, - { - "name": "前端插件", - "router": "/helper/plugins/vue", - "perms": null, - "type": 1, - "icon": "icon-vue", - "orderNum": 1, - "viewPath": "modules/helper/views/plugins/vue.vue", - "keepAlive": true, - "isShow": true, - "childMenus": [] - } - ] } ] \ No newline at end of file diff --git a/src/main/resources/cool/data/menu/menu_8.0.json b/src/main/resources/cool/data/menu/menu_8.0.json new file mode 100644 index 0000000..4ad1c60 --- /dev/null +++ b/src/main/resources/cool/data/menu/menu_8.0.json @@ -0,0 +1,158 @@ +[ + { + "name": "数据管理", + "router": null, + "perms": null, + "type": 0, + "icon": "icon-data", + "orderNum": 7, + "viewPath": null, + "keepAlive": true, + "isShow": true, + "childMenus": [ + { + "name": "字典管理", + "router": "/dict/list", + "perms": null, + "type": 1, + "icon": "icon-dict", + "orderNum": 3, + "viewPath": "modules/dict/views/list.vue", + "keepAlive": true, + "isShow": true, + "childMenus": [ + { + "name": "字典类型", + "router": null, + "perms": "dict:type:delete,dict:type:update,dict:type:info,dict:type:list,dict:type:page,dict:type:add", + "type": 2, + "icon": null, + "orderNum": 0, + "viewPath": null, + "keepAlive": true, + "isShow": true, + "childMenus": [ + ] + } + ] + }] + }, + { + "name": "扩展管理", + "router": null, + "perms": null, + "type": 0, + "icon": "icon-favor", + "orderNum": 8, + "viewPath": null, + "keepAlive": true, + "isShow": true, + "childMenus": [ + { + "tenantId": null, + "name": "插件列表", + "router": "/helper/plugins", + "perms": null, + "type": 1, + "icon": "icon-list", + "orderNum": 1, + "viewPath": "modules/helper/views/plugins.vue", + "keepAlive": true, + "isShow": true, + "childMenus": [ + { + "tenantId": null, + "name": "删除", + "router": null, + "perms": "plugin:info:delete", + "type": 2, + "icon": null, + "orderNum": 0, + "viewPath": null, + "keepAlive": true, + "isShow": true, + "childMenus": [] + }, + { + "tenantId": null, + "name": "分页查询", + "router": null, + "perms": "plugin:info:page", + "type": 2, + "icon": null, + "orderNum": 0, + "viewPath": null, + "keepAlive": true, + "isShow": true, + "childMenus": [] + }, + { + "tenantId": null, + "name": "单个信息", + "router": null, + "perms": "plugin:info:info", + "type": 2, + "icon": null, + "orderNum": 0, + "viewPath": null, + "keepAlive": true, + "isShow": true, + "childMenus": [] + }, + { + "tenantId": null, + "name": "安装插件", + "router": null, + "perms": "plugin:info:install", + "type": 2, + "icon": null, + "orderNum": 0, + "viewPath": null, + "keepAlive": true, + "isShow": true, + "childMenus": [] + }, + { + "tenantId": null, + "name": "修改", + "router": null, + "perms": "plugin:info:update", + "type": 2, + "icon": null, + "orderNum": 0, + "viewPath": null, + "keepAlive": true, + "isShow": true, + "childMenus": [] + }, + { + "tenantId": null, + "name": "列表查询", + "router": null, + "perms": "plugin:info:list", + "type": 2, + "icon": null, + "orderNum": 0, + "viewPath": null, + "keepAlive": true, + "isShow": true, + "childMenus": [] + }, + { + "tenantId": null, + "name": "新增", + "router": null, + "perms": "plugin:info:add", + "type": 2, + "icon": null, + "orderNum": 0, + "viewPath": null, + "keepAlive": true, + "isShow": true, + "childMenus": [] + } + ] + } + ] + } +] \ No newline at end of file