Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

代码生成器-生成新代码初始化菜单sql #827

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ private static List<String> getAdminTemplateNames() {
templateNames.add("Service");
templateNames.add("ServiceImpl");
templateNames.add("Repository");
templateNames.add("Sql");
return templateNames;
}

Expand Down Expand Up @@ -341,6 +342,8 @@ private static Map<String, Object> getGenMap(List<ColumnInfo> columnInfos, GenCo
genMap.put("betweens", betweens);
// 保存非空字段信息
genMap.put("isNotNullColumns", isNotNullColumns);
// 添加前端组件路径
genMap.put("apiPath", genConfig.getApiPath());
return genMap;
}

Expand Down Expand Up @@ -386,6 +389,10 @@ private static String getAdminFilePath(String templateName, GenConfig genConfig,
return packagePath + "repository" + File.separator + className + "Repository.java";
}

if ("Sql".equals(templateName)) {
return packagePath + "sql" + File.separator + className + ".sql";
}

return null;
}

Expand Down
5 changes: 5 additions & 0 deletions eladmin-generator/src/main/resources/template/admin/Sql.ftl
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
INSERT INTO `eladmin`.`sys_menu` (`pid`, `sub_count`, `type`, `title`, `name`, `component`, `menu_sort`, `icon`, `path`, `i_frame`, `cache`, `hidden`, `permission`, `create_by`, `update_by`, `create_time`, `update_time`) VALUES (NULL, 3, 1, '${apiAlias}管理', '${className}', '${apiPath}index', 1, 'menu', '${changeClassName}', b'0', b'0', b'0', '${changeClassName}:list', NULL, NULL, NOW(), NULL);
SET @last_id_in_table1 = LAST_INSERT_ID();
INSERT INTO `eladmin`.`sys_menu` (`pid`, `sub_count`, `type`, `title`, `name`, `component`, `menu_sort`, `icon`, `path`, `i_frame`, `cache`, `hidden`, `permission`, `create_by`, `update_by`, `create_time`, `update_time`) VALUES (@last_id_in_table1, 0, 2, '${apiAlias}新增', NULL, NULL, 1, NULL, NULL, b'0', b'0', b'0', '${changeClassName}:add', NULL, NULL, NOW(), NULL);
INSERT INTO `eladmin`.`sys_menu` (`pid`, `sub_count`, `type`, `title`, `name`, `component`, `menu_sort`, `icon`, `path`, `i_frame`, `cache`, `hidden`, `permission`, `create_by`, `update_by`, `create_time`, `update_time`) VALUES (@last_id_in_table1, 0, 2, '${apiAlias}编辑', NULL, NULL, 1, NULL, NULL, b'0', b'0', b'0', '${changeClassName}:edit', NULL, NULL, NOW(), NULL);
INSERT INTO `eladmin`.`sys_menu` (`pid`, `sub_count`, `type`, `title`, `name`, `component`, `menu_sort`, `icon`, `path`, `i_frame`, `cache`, `hidden`, `permission`, `create_by`, `update_by`, `create_time`, `update_time`) VALUES (@last_id_in_table1, 0, 2, '${apiAlias}删除', NULL, NULL, 1, NULL, NULL, b'0', b'0', b'0', '${changeClassName}:del', NULL, NULL, NOW(), NULL);
1 change: 0 additions & 1 deletion sql/eladmin.sql
Original file line number Diff line number Diff line change
Expand Up @@ -615,7 +615,6 @@ INSERT INTO `sys_roles_menus` VALUES (112, 1);
INSERT INTO `sys_roles_menus` VALUES (113, 1);
INSERT INTO `sys_roles_menus` VALUES (114, 1);
INSERT INTO `sys_roles_menus` VALUES (116, 1);
INSERT INTO `sys_roles_menus` VALUES (120, 1);
INSERT INTO `sys_roles_menus` VALUES (1, 2);
INSERT INTO `sys_roles_menus` VALUES (2, 2);
INSERT INTO `sys_roles_menus` VALUES (6, 2);
Expand Down