Skip to content

Commit

Permalink
refactor: 优化代码生成相关代码及初始菜单脚本
Browse files Browse the repository at this point in the history
更新接口权限
  • Loading branch information
Charles7c committed Nov 17, 2024
1 parent 5717d03 commit 7870de2
Show file tree
Hide file tree
Showing 10 changed files with 34 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -128,3 +128,5 @@ const onUpdate = async (id: string) => {
defineExpose({ onAdd, onUpdate })
</script>
<style scoped lang="scss></style>
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,4 @@ const onOpen = async (id: string) => {
defineExpose({ onOpen })
</script>

<style lang="scss" scoped></style>
<style scoped lang="scss></style>
Original file line number Diff line number Diff line change
Expand Up @@ -194,4 +194,4 @@ const onDetail = (record: ${classNamePrefix}Resp) => {
}
</script>
<style lang="scss" scoped></style>
<style scoped lang="scss></style>
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

package top.continew.admin.controller.tool;
package top.continew.admin.controller.code;

import cn.dev33.satoken.annotation.SaCheckPermission;
import io.swagger.v3.oas.annotations.Operation;
Expand Down Expand Up @@ -49,22 +49,22 @@
@Validated
@RestController
@RequiredArgsConstructor
@RequestMapping("/generator")
@RequestMapping("/code/generator")
public class GeneratorController {

private final GeneratorService baseService;
private final DictService dictService;

@Operation(summary = "分页查询生成配置", description = "分页查询生成配置列表")
@SaCheckPermission("tool:generator:list")
@SaCheckPermission("code:generator:list")
@GetMapping("/config")
public PageResp<GenConfigDO> pageGenConfig(GenConfigQuery query, @Validated PageQuery pageQuery) {
return baseService.pageGenConfig(query, pageQuery);
}

@Operation(summary = "查询生成配置信息", description = "查询生成配置信息")
@Parameter(name = "tableName", description = "表名称", required = true, example = "sys_user", in = ParameterIn.PATH)
@SaCheckPermission("tool:generator:list")
@SaCheckPermission("code:generator:list")
@GetMapping("/config/{tableName}")
public GenConfigDO getGenConfig(@PathVariable String tableName) throws SQLException {
return baseService.getGenConfig(tableName);
Expand All @@ -73,7 +73,7 @@ public GenConfigDO getGenConfig(@PathVariable String tableName) throws SQLExcept
@Operation(summary = "查询字段配置列表", description = "查询字段配置列表")
@Parameter(name = "tableName", description = "表名称", required = true, example = "sys_user", in = ParameterIn.PATH)
@Parameter(name = "requireSync", description = "是否需要同步", example = "false", in = ParameterIn.QUERY)
@SaCheckPermission("tool:generator:list")
@SaCheckPermission("code:generator:config")
@GetMapping("/field/{tableName}")
public List<FieldConfigDO> listFieldConfig(@PathVariable String tableName,
@RequestParam(required = false, defaultValue = "false") Boolean requireSync) {
Expand All @@ -82,30 +82,30 @@ public List<FieldConfigDO> listFieldConfig(@PathVariable String tableName,

@Operation(summary = "保存配置信息", description = "保存配置信息")
@Parameter(name = "tableName", description = "表名称", required = true, example = "sys_user", in = ParameterIn.PATH)
@SaCheckPermission("tool:generator:list")
@SaCheckPermission("code:generator:config")
@PostMapping("/config/{tableName}")
public void saveConfig(@Validated @RequestBody GenConfigReq req, @PathVariable String tableName) {
baseService.saveConfig(req, tableName);
}

@Operation(summary = "生成预览", description = "预览生成代码")
@Parameter(name = "tableName", description = "表名称", required = true, example = "sys_user", in = ParameterIn.PATH)
@SaCheckPermission("tool:generator:list")
@SaCheckPermission("code:generator:preview")
@GetMapping("/preview/{tableName}")
public List<GeneratePreviewResp> preview(@PathVariable String tableName) {
return baseService.preview(tableName);
}

@Operation(summary = "生成代码", description = "生成代码")
@Parameter(name = "tableName", description = "表名称", required = true, example = "sys_user", in = ParameterIn.PATH)
@SaCheckPermission("tool:generator:list")
@SaCheckPermission("code:generator:generate")
@PostMapping("/{tableNames}")
public void generate(@PathVariable List<String> tableNames, HttpServletResponse response) {
baseService.generate(tableNames, response);
}

@Operation(summary = "查询字典", description = "查询字典列表")
@SaCheckPermission("tool:generator:list")
@SaCheckPermission("code:generator:config")
@GetMapping("/dict")
public List<LabelValueResp> listDict() {
List<LabelValueResp> dictList = dictService.listDict(null, null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public PageResp<LogResp> page(LogQuery query, @Validated PageQuery pageQuery) {

@Operation(summary = "查询详情", description = "查询详情")
@Parameter(name = "id", description = "ID", example = "1", in = ParameterIn.PATH)
@SaCheckPermission("monitor:log:list")
@SaCheckPermission("monitor:log:detail")
@GetMapping("/{id}")
public LogDetailResp get(@PathVariable Long id) {
return baseService.get(id);
Expand Down
6 changes: 6 additions & 0 deletions continew-webapi/src/main/resources/config/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,12 @@ springdoc:
- group: monitor
display-name: 系统监控
packages-to-scan: ${project.base-package}.controller.monitor
- group: code
display-name: 代码生成
packages-to-scan: ${project.base-package}.controller.code
- group: schedule
display-name: 任务调度
packages-to-scan: ${project.base-package}.controller.schedule
## 组件配置
components:
# 鉴权配置
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ INSERT INTO `sys_user`
(`id`, `username`, `nickname`, `password`, `gender`, `email`, `phone`, `avatar`, `description`, `status`, `is_system`, `pwd_reset_time`, `dept_id`, `create_user`, `create_time`, `update_user`, `update_time`)
VALUES
(1, 'admin', '系统管理员', '{bcrypt}$2a$10$4jGwK2BMJ7FgVR.mgwGodey8.xR8FLoU1XSXpxJ9nZQt.pufhasSa', 1, '42190c6c5639d2ca4edb4150a35e058559ccf8270361a23745a2fd285a273c28', '5bda89a4609a65546422ea56bfe5eab4', NULL, '系统初始用户', 1, b'1', NOW(), 1, 1, NOW(), NULL, NULL),
(547889293968801831, 'test', '测试员', '{bcrypt}$2a$10$xAsoeMJ.jc/kSxhviLAg7.j2iFrhi6yYAdniNdjLiIUWU/BRZl2Ti', 2, NULL, NULL, NULL, NULL, 2, b'0', NOW(), 547888483713155087, 1, NOW(), NULL, NULL);
(547889293968801831, 'test', '测试员', '{bcrypt}$2a$10$xAsoeMJ.jc/kSxhviLAg7.j2iFrhi6yYAdniNdjLiIUWU/BRZl2Ti', 2, NULL, NULL, NULL, NULL, 1, b'0', NOW(), 547888483713155087, 1, NOW(), NULL, NULL);

-- 初始化默认参数
INSERT INTO `sys_option`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@ CREATE TABLE IF NOT EXISTS `gen_field_config` (
INSERT INTO `sys_menu`
(`id`, `title`, `parent_id`, `type`, `path`, `name`, `component`, `redirect`, `icon`, `is_external`, `is_cache`, `is_hidden`, `permission`, `sort`, `status`, `create_user`, `create_time`, `update_user`, `update_time`)
VALUES
(9000, '代码生成', 0, 1, '/tool', 'Tool', 'Layout', '/tool/generator', 'tool', b'0', b'0', b'0', NULL, 9, 1, 1, NOW(), NULL, NULL),
(9010, '代码生成', 9000, 2, '/tool/generator', 'ToolGenerator', 'tool/generator/index', NULL, 'code', b'0', b'0', b'0', NULL, 1, 1, 1, NOW(), NULL, NULL),
(9011, '列表', 9010, 3, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 'tool:generator:list', 1, 1, 1, NOW(), NULL, NULL),
(9012, '配置', 9010, 3, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 'tool:generator:config', 2, 1, 1, NOW(), NULL, NULL),
(9013, '预览', 9010, 3, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 'tool:generator:preview', 3, 1, 1, NOW(), NULL, NULL),
(9014, '生成', 9010, 3, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 'tool:generator:generate', 4, 1, 1, NOW(), NULL, NULL);
(9000, '代码生成', 0, 1, '/code', 'Code', 'Layout', '/code/generator', 'tool', b'0', b'0', b'0', NULL, 9, 1, 1, NOW(), NULL, NULL),
(9010, '代码生成', 9000, 2, '/code/generator', 'CodeGenerator', 'code/generator/index', NULL, 'code', b'0', b'0', b'0', NULL, 1, 1, 1, NOW(), NULL, NULL),
(9011, '列表', 9010, 3, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 'code:generator:list', 1, 1, 1, NOW(), NULL, NULL),
(9012, '配置', 9010, 3, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 'code:generator:config', 2, 1, 1, NOW(), NULL, NULL),
(9013, '预览', 9010, 3, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 'code:generator:preview', 3, 1, 1, NOW(), NULL, NULL),
(9014, '生成', 9010, 3, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 'code:generator:generate', 4, 1, 1, NOW(), NULL, NULL);
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ INSERT INTO "sys_user"
("id", "username", "nickname", "password", "gender", "email", "phone", "avatar", "description", "status", "is_system", "pwd_reset_time", "dept_id", "create_user", "create_time", "update_user", "update_time")
VALUES
(1, 'admin', '系统管理员', '{bcrypt}$2a$10$4jGwK2BMJ7FgVR.mgwGodey8.xR8FLoU1XSXpxJ9nZQt.pufhasSa', 1, '42190c6c5639d2ca4edb4150a35e058559ccf8270361a23745a2fd285a273c28', '5bda89a4609a65546422ea56bfe5eab4', NULL, '系统初始用户', 1, true, NOW(), 1, 1, NOW(), NULL, NULL),
(547889293968801831, 'test', '测试员', '{bcrypt}$2a$10$xAsoeMJ.jc/kSxhviLAg7.j2iFrhi6yYAdniNdjLiIUWU/BRZl2Ti', 2, NULL, NULL, NULL, NULL, 2, false, NOW(), 547888483713155087, 1, NOW(), NULL, NULL);
(547889293968801831, 'test', '测试员', '{bcrypt}$2a$10$xAsoeMJ.jc/kSxhviLAg7.j2iFrhi6yYAdniNdjLiIUWU/BRZl2Ti', 2, NULL, NULL, NULL, NULL, 1, false, NOW(), 547888483713155087, 1, NOW(), NULL, NULL);

-- 初始化默认参数
INSERT INTO "sys_option"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,9 @@ COMMENT ON TABLE "gen_field_config" IS '字段配置表';
INSERT INTO "sys_menu"
("id", "title", "parent_id", "type", "path", "name", "component", "redirect", "icon", "is_external", "is_cache", "is_hidden", "permission", "sort", "status", "create_user", "create_time", "update_user", "update_time")
VALUES
(9000, '代码生成', 0, 1, '/tool', 'Tool', 'Layout', '/tool/generator', 'tool', false, false, false, NULL, 9, 1, 1, NOW(), NULL, NULL),
(9010, '代码生成', 9000, 2, '/tool/generator', 'ToolGenerator', 'tool/generator/index', NULL, 'code', false, false, false, NULL, 1, 1, 1, NOW(), NULL, NULL),
(9011, '列表', 9010, 3, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 'tool:generator:list', 1, 1, 1, NOW(), NULL, NULL),
(9012, '配置', 9010, 3, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 'tool:generator:config', 2, 1, 1, NOW(), NULL, NULL),
(9013, '预览', 9010, 3, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 'tool:generator:preview', 3, 1, 1, NOW(), NULL, NULL),
(9014, '生成', 9010, 3, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 'tool:generator:generate', 4, 1, 1, NOW(), NULL, NULL);
(9000, '代码生成', 0, 1, '/code', 'Code', 'Layout', '/code/generator', 'tool', false, false, false, NULL, 9, 1, 1, NOW(), NULL, NULL),
(9010, '代码生成', 9000, 2, '/code/generator', 'CodeGenerator', 'code/generator/index', NULL, 'code', false, false, false, NULL, 1, 1, 1, NOW(), NULL, NULL),
(9011, '列表', 9010, 3, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 'code:generator:list', 1, 1, 1, NOW(), NULL, NULL),
(9012, '配置', 9010, 3, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 'code:generator:config', 2, 1, 1, NOW(), NULL, NULL),
(9013, '预览', 9010, 3, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 'code:generator:preview', 3, 1, 1, NOW(), NULL, NULL),
(9014, '生成', 9010, 3, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 'code:generator:generate', 4, 1, 1, NOW(), NULL, NULL);

0 comments on commit 7870de2

Please sign in to comment.