diff --git a/continew-plugin/continew-plugin-generator/src/main/java/top/continew/admin/generator/model/entity/InnerGenConfigDO.java b/continew-plugin/continew-plugin-generator/src/main/java/top/continew/admin/generator/model/entity/InnerGenConfigDO.java index 746531ec1..5b866cae9 100644 --- a/continew-plugin/continew-plugin-generator/src/main/java/top/continew/admin/generator/model/entity/InnerGenConfigDO.java +++ b/continew-plugin/continew-plugin-generator/src/main/java/top/continew/admin/generator/model/entity/InnerGenConfigDO.java @@ -101,6 +101,26 @@ public class InnerGenConfigDO extends GenConfigDO { */ private boolean hasTimeField; + /** + * Menu icon + */ + private String icon = "list"; + + /** + * Menu sort order + */ + private Integer sort = 1; + + /** + * Parent menu ID placeholder + */ + private String parentMenuId = "#{parentMenuId}"; + + /** + * Menu type (2 for menu) + */ + private Integer menuType = 2; + public InnerGenConfigDO() { } diff --git a/continew-plugin/continew-plugin-generator/src/main/java/top/continew/admin/generator/service/impl/GeneratorServiceImpl.java b/continew-plugin/continew-plugin-generator/src/main/java/top/continew/admin/generator/service/impl/GeneratorServiceImpl.java index 0ba36fd2a..8c0b8cdc5 100644 --- a/continew-plugin/continew-plugin-generator/src/main/java/top/continew/admin/generator/service/impl/GeneratorServiceImpl.java +++ b/continew-plugin/continew-plugin-generator/src/main/java/top/continew/admin/generator/service/impl/GeneratorServiceImpl.java @@ -92,8 +92,8 @@ public PageResp pageTable(TableQuery query, PageQuery pageQuery) thro tableList.removeIf(table -> StrUtil.equalsAnyIgnoreCase(table.getTableName(), generatorProperties .getExcludeTables())); CollUtil.sort(tableList, Comparator.comparing(Table::getCreateTime) - .thenComparing(table -> Optional.ofNullable(table.getUpdateTime()).orElse(table.getCreateTime())) - .reversed()); + .thenComparing(table -> Optional.ofNullable(table.getUpdateTime()).orElse(table.getCreateTime())) + .reversed()); List tableRespList = BeanUtil.copyToList(tableList, TableResp.class); PageResp pageResp = PageResp.build(pageQuery.getPage(), pageQuery.getSize(), tableRespList); pageResp.getList().parallelStream().forEach(tableResp -> { diff --git a/continew-plugin/continew-plugin-generator/src/main/resources/templates/backend/menu.sql.ftl b/continew-plugin/continew-plugin-generator/src/main/resources/templates/backend/menu.sql.ftl new file mode 100644 index 000000000..7ce13dd9a --- /dev/null +++ b/continew-plugin/continew-plugin-generator/src/main/resources/templates/backend/menu.sql.ftl @@ -0,0 +1,50 @@ +-- MYSQL +-- ${businessName}管理菜单 +INSERT INTO sys_menu ( + title, parent_id, type, path, name, component, icon, + is_external, is_cache, is_hidden, permission, sort, status, create_time, update_time +) VALUES ( + '${businessName}管理', 1000, ${menuType}, '/${apiModuleName}/${apiName}', + '${classNamePrefix}', '${apiModuleName}/${apiName}/index', '${icon!"list"}', + 0, 1, 0, null, ${sort!1}, 1, now(), now() +); + +SET @parentId = LAST_INSERT_ID(); + +-- ${businessName}管理按钮 +INSERT INTO sys_menu ( + title, parent_id, type, permission, sort, status, create_time, update_time +) VALUES +('查询${businessName}', @parentId, 3, '${apiModuleName}:${apiName}:list', 1, 1, now(), now()), +('详情${businessName}', @parentId, 3, '${apiModuleName}:${apiName}:detail', 2, 1, now(), now()), +('新增${businessName}', @parentId, 3, '${apiModuleName}:${apiName}:add', 3, 1, now(), now()), +('修改${businessName}', @parentId, 3, '${apiModuleName}:${apiName}:update', 4, 1, now(), now()), +('删除${businessName}', @parentId, 3, '${apiModuleName}:${apiName}:delete', 5, 1, now(), now()), +('导出${businessName}', @parentId, 3, '${apiModuleName}:${apiName}:export', 6, 1, now(), now()), +('导入${businessName}', @parentId, 3, '${apiModuleName}:${apiName}:import', 7, 1, now(), now()); + + +<#-- +-- PG_SQL +-- ${businessName}管理菜单 +INSERT INTO sys_menu ( + title, parent_id, type, path, name, component, icon, + is_external, is_cache, is_hidden, permission, sort, status, create_time, update_time +) VALUES ( + '${businessName}管理', 1000, ${menuType}, '/${apiModuleName}/${apiName}', + '${classNamePrefix}', '${apiModuleName}/${apiName}/index', '${icon!"list"}', + 0, 1, 0, null, ${sort!1}, 1, now(), now() +) RETURNING id INTO parentId; + +-- ${businessName}管理按钮 +INSERT INTO sys_menu ( + title, parent_id, type, permission, sort, status, create_time, update_time +) VALUES +('查询${businessName}', parentId, 3, '${apiModuleName}:${apiName}:list', 1, 1, now(), now()), +('详情${businessName}', parentId, 3, '${apiModuleName}:${apiName}:detail', 2, 1, now(), now()), +('新增${businessName}', parentId, 3, '${apiModuleName}:${apiName}:add', 3, 1, now(), now()), +('修改${businessName}', parentId, 3, '${apiModuleName}:${apiName}:update', 4, 1, now(), now()), +('删除${businessName}', parentId, 3, '${apiModuleName}:${apiName}:delete', 5, 1, now(), now()), +('导出${businessName}', parentId, 3, '${apiModuleName}:${apiName}:export', 6, 1, now(), now()), +('导入${businessName}', parentId, 3, '${apiModuleName}:${apiName}:import', 7, 1, now(), now()); +--> diff --git a/continew-webapi/src/main/resources/config/application-generator.yml b/continew-webapi/src/main/resources/config/application-generator.yml index 46cc562a7..6b6554e68 100644 --- a/continew-webapi/src/main/resources/config/application-generator.yml +++ b/continew-webapi/src/main/resources/config/application-generator.yml @@ -63,6 +63,11 @@ generator: - timestamp ## 模板配置 templateConfigs: + MenuSql: + template-path: backend/menu.sql.ftl + package-name: sql + extension: .sql + backend: true DO: # 模板路径 templatePath: backend/Entity.ftl