mirror of
https://github.com/continew-org/continew-admin.git
synced 2025-09-10 20:57:14 +08:00
feat(generator): 代码生成新增菜单SQL模板 (#95)
This commit is contained in:
@@ -101,6 +101,26 @@ public class InnerGenConfigDO extends GenConfigDO {
|
|||||||
*/
|
*/
|
||||||
private boolean hasTimeField;
|
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() {
|
public InnerGenConfigDO() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -92,8 +92,8 @@ public class GeneratorServiceImpl implements GeneratorService {
|
|||||||
tableList.removeIf(table -> StrUtil.equalsAnyIgnoreCase(table.getTableName(), generatorProperties
|
tableList.removeIf(table -> StrUtil.equalsAnyIgnoreCase(table.getTableName(), generatorProperties
|
||||||
.getExcludeTables()));
|
.getExcludeTables()));
|
||||||
CollUtil.sort(tableList, Comparator.comparing(Table::getCreateTime)
|
CollUtil.sort(tableList, Comparator.comparing(Table::getCreateTime)
|
||||||
.thenComparing(table -> Optional.ofNullable(table.getUpdateTime()).orElse(table.getCreateTime()))
|
.thenComparing(table -> Optional.ofNullable(table.getUpdateTime()).orElse(table.getCreateTime()))
|
||||||
.reversed());
|
.reversed());
|
||||||
List<TableResp> tableRespList = BeanUtil.copyToList(tableList, TableResp.class);
|
List<TableResp> tableRespList = BeanUtil.copyToList(tableList, TableResp.class);
|
||||||
PageResp<TableResp> pageResp = PageResp.build(pageQuery.getPage(), pageQuery.getSize(), tableRespList);
|
PageResp<TableResp> pageResp = PageResp.build(pageQuery.getPage(), pageQuery.getSize(), tableRespList);
|
||||||
pageResp.getList().parallelStream().forEach(tableResp -> {
|
pageResp.getList().parallelStream().forEach(tableResp -> {
|
||||||
|
@@ -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());
|
||||||
|
-->
|
@@ -63,6 +63,11 @@ generator:
|
|||||||
- timestamp
|
- timestamp
|
||||||
## 模板配置
|
## 模板配置
|
||||||
templateConfigs:
|
templateConfigs:
|
||||||
|
MenuSql:
|
||||||
|
template-path: backend/menu.sql.ftl
|
||||||
|
package-name: sql
|
||||||
|
extension: .sql
|
||||||
|
backend: true
|
||||||
DO:
|
DO:
|
||||||
# 模板路径
|
# 模板路径
|
||||||
templatePath: backend/Entity.ftl
|
templatePath: backend/Entity.ftl
|
||||||
|
Reference in New Issue
Block a user