Browse Source

docs(spec): clarify left-tree-right-table design details

PIGCLOUD 3 weeks ago
parent
commit
93709398d1

+ 5 - 5
common/权限菜单.sql

@@ -7,16 +7,16 @@ values (${menuId}, '-1', '/${moduleName}/${functionName}/index', '', '0', 'icon-
 
 
 -- 菜单对应按钮SQL
 -- 菜单对应按钮SQL
 insert into sys_menu ( menu_id,parent_id, permission, menu_type, path, icon, del_flag, create_time, sort_order, update_time, name#if(!$opensource), tenant_id#end)
 insert into sys_menu ( menu_id,parent_id, permission, menu_type, path, icon, del_flag, create_time, sort_order, update_time, name#if(!$opensource), tenant_id#end)
-values (${math.add($menuId,1)},${menuId}, '${moduleName}_${functionName}_view', '1', null, '1',  '0', null, '0', null, '${tableComment}查看'#if(!$opensource), 1#end);
+values (${math.add($menuId,1)},${menuId}, '$str.lowerCase($moduleName)_$str.lowerCase($functionName)_view', '1', null, '1',  '0', null, '0', null, '${tableComment}查看'#if(!$opensource), 1#end);
 
 
 insert into sys_menu ( menu_id,parent_id, permission, menu_type, path, icon, del_flag, create_time, sort_order, update_time, name#if(!$opensource), tenant_id#end)
 insert into sys_menu ( menu_id,parent_id, permission, menu_type, path, icon, del_flag, create_time, sort_order, update_time, name#if(!$opensource), tenant_id#end)
-values (${math.add($menuId,2)},${menuId}, '${moduleName}_${functionName}_add', '1', null, '1',  '0', null, '1', null, '${tableComment}新增'#if(!$opensource), 1#end);
+values (${math.add($menuId,2)},${menuId}, '$str.lowerCase($moduleName)_$str.lowerCase($functionName)_add', '1', null, '1',  '0', null, '1', null, '${tableComment}新增'#if(!$opensource), 1#end);
 
 
 insert into sys_menu (menu_id, parent_id, permission, menu_type, path, icon,  del_flag, create_time, sort_order, update_time, name#if(!$opensource), tenant_id#end)
 insert into sys_menu (menu_id, parent_id, permission, menu_type, path, icon,  del_flag, create_time, sort_order, update_time, name#if(!$opensource), tenant_id#end)
-values (${math.add($menuId,3)},${menuId}, '${moduleName}_${functionName}_edit', '1', null, '1',  '0', null, '2', null, '${tableComment}修改'#if(!$opensource), 1#end);
+values (${math.add($menuId,3)},${menuId}, '$str.lowerCase($moduleName)_$str.lowerCase($functionName)_edit', '1', null, '1',  '0', null, '2', null, '${tableComment}修改'#if(!$opensource), 1#end);
 
 
 insert into sys_menu (menu_id, parent_id, permission, menu_type, path, icon, del_flag, create_time, sort_order, update_time, name#if(!$opensource), tenant_id#end)
 insert into sys_menu (menu_id, parent_id, permission, menu_type, path, icon, del_flag, create_time, sort_order, update_time, name#if(!$opensource), tenant_id#end)
-values (${math.add($menuId,4)},${menuId}, '${moduleName}_${functionName}_del', '1', null, '1',  '0', null, '3', null, '${tableComment}删除'#if(!$opensource), 1#end);
+values (${math.add($menuId,4)},${menuId}, '$str.lowerCase($moduleName)_$str.lowerCase($functionName)_del', '1', null, '1',  '0', null, '3', null, '${tableComment}删除'#if(!$opensource), 1#end);
 
 
 insert into sys_menu ( menu_id,parent_id, permission, menu_type, path, icon, del_flag, create_time, sort_order, update_time, name#if(!$opensource), tenant_id#end)
 insert into sys_menu ( menu_id,parent_id, permission, menu_type, path, icon, del_flag, create_time, sort_order, update_time, name#if(!$opensource), tenant_id#end)
-values (${math.add($menuId,5)},${menuId}, '${moduleName}_${functionName}_export', '1', null, '1',  '0', null, '3', null, '导入导出'#if(!$opensource), 1#end);
+values (${math.add($menuId,5)},${menuId}, '$str.lowerCase($moduleName)_$str.lowerCase($functionName)_export', '1', null, '1',  '0', null, '3', null, '导入导出'#if(!$opensource), 1#end);

+ 55 - 0
docs/superpowers/specs/2026-04-08-left-tree-right-table-design.md

@@ -118,6 +118,24 @@
 
 
 该约定必须在实现中明确,否则实现者可能误把当前场景继续按“子表保存主表外键”处理。
 该约定必须在实现中明确,否则实现者可能误把当前场景继续按“子表保存主表外键”处理。
 
 
+### 5.4 关键元信息来源表
+
+| 字段 | 来源 | 是否新增输入 | 本模板组中的含义 |
+| --- | --- | --- | --- |
+| `mainField` | 复用现有主子表配置 | 否 | 主表中的树节点外键字段 |
+| `childFieldList` | 复用现有主子表配置 | 否 | 左树子表字段列表 |
+| `ChildClassName` / `childClassName` | 复用现有主子表配置 | 否 | 左树子表实体命名 |
+| `childTableName` | 复用现有主子表配置 | 否 | 左树子表表名 |
+| `parentField` | 新增模板配置 | 是 | 左树子表父节点字段 |
+| `nameField` | 新增模板配置 | 是 | 左树节点显示名称字段 |
+| 左树子表主键 | 从 `childFieldList` 推导 | 否 | 通过 `primaryPk = true` 的字段识别 |
+
+结论:
+
+- 本模板组需要在生成器配置层新增两个最小输入:`parentField`、`nameField`
+- `mainField` 沿用现有主子表配置,但语义固定为“主表引用树节点的外键”
+- 不要求新增更复杂的上下文字段体系
+
 ## 6. 模板分组与生成产物
 ## 6. 模板分组与生成产物
 
 
 新增模板组名称:
 新增模板组名称:
@@ -160,6 +178,39 @@
 
 
 不建议将左右两种编辑能力继续合并到一个表单文件中,否则页面职责会过于拥挤。
 不建议将左右两种编辑能力继续合并到一个表单文件中,否则页面职责会过于拥挤。
 
 
+### 6.6 `config.json` 注册要求
+
+该仓库是 registry-driven,新增模板组后必须同步更新 `config.json`,否则模板无法出现在代码生成器里。
+
+建议新增一组根配置:
+
+- 分组名:`左树右表增删改查`
+
+建议的文件映射如下:
+
+| templateName | generatorPath | templateFile |
+| --- | --- | --- |
+| `Controller` | `${backendPath}/src/main/java/${packagePath}/${moduleName}/controller/${ClassName}Controller.java` | `treeTable/Controller.java` |
+| `Service` | `${backendPath}/src/main/java/${packagePath}/${moduleName}/service/${ClassName}Service.java` | `treeTable/Service.java` |
+| `ServiceImpl` | `${backendPath}/src/main/java/${packagePath}/${moduleName}/service/impl/${ClassName}ServiceImpl.java` | `treeTable/ServiceImpl.java` |
+| `实体` | `${backendPath}/src/main/java/${packagePath}/${moduleName}/entity/${ClassName}Entity.java` | `single/实体.java` |
+| `Mapper` | `${backendPath}/src/main/java/${packagePath}/${moduleName}/mapper/${ClassName}Mapper.java` | `single/Mapper.java` |
+| `Mapper.xml` | `${backendPath}/src/main/resources/mapper/${ClassName}Mapper.xml` | `single/Mapper.xml` |
+| `子实体` | `${backendPath}/src/main/java/${packagePath}/${moduleName}/entity/${ChildClassName}Entity.java` | `multiple/子实体.java` |
+| `子Mapper` | `${backendPath}/src/main/java/${packagePath}/${moduleName}/mapper/${ChildClassName}Mapper.java` | `multiple/子Mapper.java` |
+| `权限菜单` | `${backendPath}/menu/${functionName}_menu.sql` | `common/权限菜单.sql` |
+| `api.ts` | `${frontendPath}/src/api/${moduleName}/${functionName}.ts` | `treeTable/api.ts` |
+| `表格` | `${frontendPath}/src/views/${moduleName}/${functionName}/index.vue` | `treeTable/index.vue` |
+| `树表单` | `${frontendPath}/src/views/${moduleName}/${functionName}/tree-form.vue` | `treeTable/tree-form.vue` |
+| `主表单` | `${frontendPath}/src/views/${moduleName}/${functionName}/form.vue` | `treeTable/form.vue` |
+
+说明:
+
+- 新增模板目录建议命名为 `treeTable/`
+- 主表实体、Mapper、Mapper.xml 可以直接复用单表模板
+- 子实体、子 Mapper 可以直接复用主子表模板
+- 需要新建的主要是 `Controller / Service / ServiceImpl / api.ts / index.vue / tree-form.vue / form.vue`
+
 ## 7. 后端接口设计
 ## 7. 后端接口设计
 
 
 ### 7.1 主表接口
 ### 7.1 主表接口
@@ -252,6 +303,10 @@
 - 排除主表外键聚合概念中的无关字段
 - 排除主表外键聚合概念中的无关字段
 - 保留 `parentField` 作为父级节点选择器
 - 保留 `parentField` 作为父级节点选择器
 - 使用 `nameField` 作为默认树节点显示名称来源
 - 使用 `nameField` 作为默认树节点显示名称来源
+- 根节点父级值统一使用 `0`,与现有树模板的根节点构建方式保持一致
+- 编辑节点时禁止选择自己作为父节点
+- 编辑节点时禁止选择自己的任意后代节点作为父节点,避免形成环
+- 父级节点选择列表需要排除当前节点及其后代
 
 
 ### 9.4 右表 CRUD
 ### 9.4 右表 CRUD
 
 

+ 16 - 16
multiple/主子Contoller.java

@@ -61,9 +61,9 @@ public class ${ClassName}Controller {
     @Operation(summary = "分页查询" , description = "分页查询" )
     @Operation(summary = "分页查询" , description = "分页查询" )
     @GetMapping("/page" )
     @GetMapping("/page" )
     #if($isSpringBoot3)
     #if($isSpringBoot3)
-    @HasPermission("$str.toLowerCase(${moduleName}_${functionName}_view)")
+    @HasPermission("$str.lowerCase($moduleName)_$str.lowerCase($functionName)_view")
     #else
     #else
-    @PreAuthorize("@pms.hasPermission('$str.toLowerCase(${moduleName}_${functionName}_view)')" )
+    @PreAuthorize("@pms.hasPermission('$str.lowerCase($moduleName)_$str.lowerCase($functionName)_view')" )
     #end
     #end
     public R get${ClassName}Page(@ParameterObject Page page, @ParameterObject ${ClassName}Entity ${className}) {
     public R get${ClassName}Page(@ParameterObject Page page, @ParameterObject ${ClassName}Entity ${className}) {
         LambdaQueryWrapper<${ClassName}Entity> wrapper = Wrappers.lambdaQuery();
         LambdaQueryWrapper<${ClassName}Entity> wrapper = Wrappers.lambdaQuery();
@@ -111,9 +111,9 @@ public class ${ClassName}Controller {
     @Operation(summary = "通过条件查询" , description = "通过条件查询对象" )
     @Operation(summary = "通过条件查询" , description = "通过条件查询对象" )
     @GetMapping("/details" )
     @GetMapping("/details" )
     #if($isSpringBoot3)
     #if($isSpringBoot3)
-    @HasPermission("$str.toLowerCase(${moduleName}_${functionName}_view)")
+    @HasPermission("$str.lowerCase($moduleName)_$str.lowerCase($functionName)_view")
     #else
     #else
-    @PreAuthorize("@pms.hasPermission('$str.toLowerCase(${moduleName}_${functionName}_view)')" )
+    @PreAuthorize("@pms.hasPermission('$str.lowerCase($moduleName)_$str.lowerCase($functionName)_view')" )
     #end
     #end
     public R getDetails(@ParameterObject ${ClassName}Entity ${className}) {
     public R getDetails(@ParameterObject ${ClassName}Entity ${className}) {
         return R.ok(${className}Service.listDeep(Wrappers.query(${className})));
         return R.ok(${className}Service.listDeep(Wrappers.query(${className})));
@@ -128,9 +128,9 @@ public class ${ClassName}Controller {
     @SysLog("新增${tableComment}" )
     @SysLog("新增${tableComment}" )
     @PostMapping
     @PostMapping
     #if($isSpringBoot3)
     #if($isSpringBoot3)
-    @HasPermission("$str.toLowerCase(${moduleName}_${functionName}_add)")
+    @HasPermission("$str.lowerCase($moduleName)_$str.lowerCase($functionName)_add")
     #else
     #else
-    @PreAuthorize("@pms.hasPermission('$str.toLowerCase(${moduleName}_${functionName}_add)')" )
+    @PreAuthorize("@pms.hasPermission('$str.lowerCase($moduleName)_$str.lowerCase($functionName)_add')" )
     #end
     #end
     public R save(@RequestBody ${ClassName}Entity ${className}) {
     public R save(@RequestBody ${ClassName}Entity ${className}) {
         return R.ok(${className}Service.saveDeep(${className}));
         return R.ok(${className}Service.saveDeep(${className}));
@@ -145,9 +145,9 @@ public class ${ClassName}Controller {
     @SysLog("修改${tableComment}" )
     @SysLog("修改${tableComment}" )
     @PutMapping
     @PutMapping
     #if($isSpringBoot3)
     #if($isSpringBoot3)
-    @HasPermission("$str.toLowerCase(${moduleName}_${functionName}_edit)")
+    @HasPermission("$str.lowerCase($moduleName)_$str.lowerCase($functionName)_edit")
     #else
     #else
-    @PreAuthorize("@pms.hasPermission('$str.toLowerCase(${moduleName}_${functionName}_edit)')" )
+    @PreAuthorize("@pms.hasPermission('$str.lowerCase($moduleName)_$str.lowerCase($functionName)_edit')" )
     #end
     #end
     public R updateById(@RequestBody ${ClassName}Entity ${className}) {
     public R updateById(@RequestBody ${ClassName}Entity ${className}) {
         return R.ok(${className}Service.updateDeep(${className}));
         return R.ok(${className}Service.updateDeep(${className}));
@@ -162,9 +162,9 @@ public class ${ClassName}Controller {
     @SysLog("通过id删除${tableComment}" )
     @SysLog("通过id删除${tableComment}" )
     @DeleteMapping
     @DeleteMapping
     #if($isSpringBoot3)
     #if($isSpringBoot3)
-    @HasPermission("$str.toLowerCase(${moduleName}_${functionName}_del)")
+    @HasPermission("$str.lowerCase($moduleName)_$str.lowerCase($functionName)_del")
     #else
     #else
-    @PreAuthorize("@pms.hasPermission('$str.toLowerCase(${moduleName}_${functionName}_del)')" )
+    @PreAuthorize("@pms.hasPermission('$str.lowerCase($moduleName)_$str.lowerCase($functionName)_del')" )
     #end
     #end
     public R removeById(@RequestBody ${pk.attrType}[] ids) {
     public R removeById(@RequestBody ${pk.attrType}[] ids) {
         return R.ok(${className}Service.removeDeep(ids));
         return R.ok(${className}Service.removeDeep(ids));
@@ -179,9 +179,9 @@ public class ${ClassName}Controller {
     @SysLog("通过id删除${tableComment}子表数据" )
     @SysLog("通过id删除${tableComment}子表数据" )
     @DeleteMapping("/child")
     @DeleteMapping("/child")
     #if($isSpringBoot3)
     #if($isSpringBoot3)
-    @HasPermission("$str.toLowerCase(${moduleName}_${functionName}_del)")
+    @HasPermission("$str.lowerCase($moduleName)_$str.lowerCase($functionName)_del")
     #else
     #else
-    @PreAuthorize("@pms.hasPermission('$str.toLowerCase(${moduleName}_${functionName}_del)')" )
+    @PreAuthorize("@pms.hasPermission('$str.lowerCase($moduleName)_$str.lowerCase($functionName)_del')" )
     #end
     #end
     public R removeChild(@RequestBody ${pk.attrType}[] ids) {
     public R removeChild(@RequestBody ${pk.attrType}[] ids) {
         return R.ok(${className}Service.removeChild(ids));
         return R.ok(${className}Service.removeChild(ids));
@@ -196,9 +196,9 @@ public class ${ClassName}Controller {
     @ResponseExcel
     @ResponseExcel
     @GetMapping("/export")
     @GetMapping("/export")
     #if($isSpringBoot3)
     #if($isSpringBoot3)
-    @HasPermission("$str.toLowerCase(${moduleName}_${functionName}_export)")
+    @HasPermission("$str.lowerCase($moduleName)_$str.lowerCase($functionName)_export")
     #else
     #else
-    @PreAuthorize("@pms.hasPermission('$str.toLowerCase(${moduleName}_${functionName}_export)')" )
+    @PreAuthorize("@pms.hasPermission('$str.lowerCase($moduleName)_$str.lowerCase($functionName)_export')" )
     #end
     #end
     public List<${ClassName}Entity> exportExcel(${ClassName}Entity ${className},${pk.attrType}[] ids) {
     public List<${ClassName}Entity> exportExcel(${ClassName}Entity ${className},${pk.attrType}[] ids) {
         return ${className}Service.list(Wrappers.lambdaQuery(${className}).in(ArrayUtil.isNotEmpty(ids), ${ClassName}Entity::$str.getProperty($pk.attrName), ids));
         return ${className}Service.list(Wrappers.lambdaQuery(${className}).in(ArrayUtil.isNotEmpty(ids), ${ClassName}Entity::$str.getProperty($pk.attrName), ids));
@@ -212,9 +212,9 @@ public class ${ClassName}Controller {
      */
      */
     @PostMapping("/import")
     @PostMapping("/import")
     #if($isSpringBoot3)
     #if($isSpringBoot3)
-    @HasPermission("$str.toLowerCase(${moduleName}_${functionName}_export)")
+    @HasPermission("$str.lowerCase($moduleName)_$str.lowerCase($functionName)_export")
     #else
     #else
-    @PreAuthorize("@pms.hasPermission('$str.toLowerCase(${moduleName}_${functionName}_export)')" )
+    @PreAuthorize("@pms.hasPermission('$str.lowerCase($moduleName)_$str.lowerCase($functionName)_export')" )
     #end
     #end
     public R importExcel(@RequestExcel List<${ClassName}Entity> ${className}List, BindingResult bindingResult) {
     public R importExcel(@RequestExcel List<${ClassName}Entity> ${className}List, BindingResult bindingResult) {
         return R.ok(${className}Service.saveBatch(${className}List));
         return R.ok(${className}Service.saveBatch(${className}List));

+ 6 - 6
multiple/主子表格.vue

@@ -102,7 +102,7 @@
             type="primary" 
             type="primary" 
             class="ml10" 
             class="ml10" 
             @click="formDialogRef.openDialog()"
             @click="formDialogRef.openDialog()"
-            v-auth="'${moduleName}_${functionName}_add'">
+            v-auth="'$str.lowerCase($moduleName)_$str.lowerCase($functionName)_add'">
             新增
             新增
           </el-button>
           </el-button>
           <el-button 
           <el-button 
@@ -110,13 +110,13 @@
             :disabled="multiple" 
             :disabled="multiple" 
             icon="Delete" 
             icon="Delete" 
             type="primary"
             type="primary"
-            v-auth="'${moduleName}_${functionName}_del'" 
+            v-auth="'$str.lowerCase($moduleName)_$str.lowerCase($functionName)_del'" 
             @click="handleDelete(selectObjs.value)">
             @click="handleDelete(selectObjs.value)">
             删除
             删除
           </el-button>
           </el-button>
           <right-toolbar 
           <right-toolbar 
             v-model:showSearch="showSearch" 
             v-model:showSearch="showSearch" 
-            :export="'${moduleName}_${functionName}_export'"
+            :export="'$str.lowerCase($moduleName)_$str.lowerCase($functionName)_export'"
             @exportExcel="exportExcel" 
             @exportExcel="exportExcel" 
             class="ml10 mr20" 
             class="ml10 mr20" 
             style="float: right;"
             style="float: right;"
@@ -165,7 +165,7 @@
               text 
               text 
               type="primary" 
               type="primary" 
               icon="view" 
               icon="view" 
-              v-auth="'${moduleName}_${functionName}_view'" 
+              v-auth="'$str.lowerCase($moduleName)_$str.lowerCase($functionName)_view'" 
               @click="formDialogRef.openDialog(scope.row.${pk.attrName}, true)">
               @click="formDialogRef.openDialog(scope.row.${pk.attrName}, true)">
               详情
               详情
             </el-button>
             </el-button>
@@ -174,7 +174,7 @@
               icon="edit-pen" 
               icon="edit-pen" 
               text 
               text 
               type="primary" 
               type="primary" 
-              v-auth="'${moduleName}_${functionName}_edit'"
+              v-auth="'$str.lowerCase($moduleName)_$str.lowerCase($functionName)_edit'"
               @click="formDialogRef.openDialog(scope.row.${pk.attrName})">
               @click="formDialogRef.openDialog(scope.row.${pk.attrName})">
               编辑
               编辑
             </el-button>
             </el-button>
@@ -182,7 +182,7 @@
               icon="delete" 
               icon="delete" 
               text 
               text 
               type="primary" 
               type="primary" 
-              v-auth="'${moduleName}_${functionName}_del'" 
+              v-auth="'$str.lowerCase($moduleName)_$str.lowerCase($functionName)_del'" 
               @click="handleDelete([scope.row.${pk.attrName}])">
               @click="handleDelete([scope.row.${pk.attrName}])">
               删除
               删除
             </el-button>
             </el-button>

+ 14 - 14
single/Controller.java

@@ -62,9 +62,9 @@ public class ${ClassName}Controller {
     @Operation(summary = "分页查询" , description = "分页查询" )
     @Operation(summary = "分页查询" , description = "分页查询" )
     @GetMapping("/page" )
     @GetMapping("/page" )
     #if($isSpringBoot3)
     #if($isSpringBoot3)
-    @HasPermission("$str.toLowerCase(${moduleName}_${functionName}_view)")
+    @HasPermission("$str.lowerCase($moduleName)_$str.lowerCase($functionName)_view")
     #else
     #else
-    @PreAuthorize("@pms.hasPermission('$str.toLowerCase(${moduleName}_${functionName}_view)')" )
+    @PreAuthorize("@pms.hasPermission('$str.lowerCase($moduleName)_$str.lowerCase($functionName)_view')" )
     #end
     #end
     public R get${ClassName}Page(@ParameterObject Page page, @ParameterObject ${ClassName}Entity ${className}) {
     public R get${ClassName}Page(@ParameterObject Page page, @ParameterObject ${ClassName}Entity ${className}) {
         LambdaQueryWrapper<${ClassName}Entity> wrapper = Wrappers.lambdaQuery();
         LambdaQueryWrapper<${ClassName}Entity> wrapper = Wrappers.lambdaQuery();
@@ -112,9 +112,9 @@ public class ${ClassName}Controller {
     @Operation(summary = "通过条件查询" , description = "通过条件查询对象" )
     @Operation(summary = "通过条件查询" , description = "通过条件查询对象" )
     @GetMapping("/details" )
     @GetMapping("/details" )
     #if($isSpringBoot3)
     #if($isSpringBoot3)
-    @HasPermission("$str.toLowerCase(${moduleName}_${functionName}_view)")
+    @HasPermission("$str.lowerCase($moduleName)_$str.lowerCase($functionName)_view")
     #else
     #else
-    @PreAuthorize("@pms.hasPermission('$str.toLowerCase(${moduleName}_${functionName}_view)')" )
+    @PreAuthorize("@pms.hasPermission('$str.lowerCase($moduleName)_$str.lowerCase($functionName)_view')" )
     #end
     #end
     public R getDetails(@ParameterObject ${ClassName}Entity ${className}) {
     public R getDetails(@ParameterObject ${ClassName}Entity ${className}) {
         return R.ok(${className}Service.list(Wrappers.query(${className})));
         return R.ok(${className}Service.list(Wrappers.query(${className})));
@@ -129,9 +129,9 @@ public class ${ClassName}Controller {
     @SysLog("新增${tableComment}" )
     @SysLog("新增${tableComment}" )
     @PostMapping
     @PostMapping
     #if($isSpringBoot3)
     #if($isSpringBoot3)
-    @HasPermission("$str.toLowerCase(${moduleName}_${functionName}_add)")
+    @HasPermission("$str.lowerCase($moduleName)_$str.lowerCase($functionName)_add")
     #else
     #else
-    @PreAuthorize("@pms.hasPermission('$str.toLowerCase(${moduleName}_${functionName}_add)')" )
+    @PreAuthorize("@pms.hasPermission('$str.lowerCase($moduleName)_$str.lowerCase($functionName)_add')" )
     #end
     #end
     public R save(@RequestBody ${ClassName}Entity ${className}) {
     public R save(@RequestBody ${ClassName}Entity ${className}) {
         return R.ok(${className}Service.save(${className}));
         return R.ok(${className}Service.save(${className}));
@@ -146,9 +146,9 @@ public class ${ClassName}Controller {
     @SysLog("修改${tableComment}" )
     @SysLog("修改${tableComment}" )
     @PutMapping
     @PutMapping
     #if($isSpringBoot3)
     #if($isSpringBoot3)
-    @HasPermission("$str.toLowerCase(${moduleName}_${functionName}_edit)")
+    @HasPermission("$str.lowerCase($moduleName)_$str.lowerCase($functionName)_edit")
     #else
     #else
-    @PreAuthorize("@pms.hasPermission('$str.toLowerCase(${moduleName}_${functionName}_edit)')" )
+    @PreAuthorize("@pms.hasPermission('$str.lowerCase($moduleName)_$str.lowerCase($functionName)_edit')" )
     #end
     #end
     public R updateById(@RequestBody ${ClassName}Entity ${className}) {
     public R updateById(@RequestBody ${ClassName}Entity ${className}) {
         return R.ok(${className}Service.updateById(${className}));
         return R.ok(${className}Service.updateById(${className}));
@@ -163,9 +163,9 @@ public class ${ClassName}Controller {
     @SysLog("通过id删除${tableComment}" )
     @SysLog("通过id删除${tableComment}" )
     @DeleteMapping
     @DeleteMapping
     #if($isSpringBoot3)
     #if($isSpringBoot3)
-    @HasPermission("$str.toLowerCase(${moduleName}_${functionName}_del)")
+    @HasPermission("$str.lowerCase($moduleName)_$str.lowerCase($functionName)_del")
     #else
     #else
-    @PreAuthorize("@pms.hasPermission('$str.toLowerCase(${moduleName}_${functionName}_del)')" )
+    @PreAuthorize("@pms.hasPermission('$str.lowerCase($moduleName)_$str.lowerCase($functionName)_del')" )
     #end
     #end
     public R removeById(@RequestBody ${pk.attrType}[] ids) {
     public R removeById(@RequestBody ${pk.attrType}[] ids) {
         return R.ok(${className}Service.removeBatchByIds(CollUtil.toList(ids)));
         return R.ok(${className}Service.removeBatchByIds(CollUtil.toList(ids)));
@@ -181,9 +181,9 @@ public class ${ClassName}Controller {
     @ResponseExcel
     @ResponseExcel
     @GetMapping("/export")
     @GetMapping("/export")
     #if($isSpringBoot3)
     #if($isSpringBoot3)
-    @HasPermission("$str.toLowerCase(${moduleName}_${functionName}_export)")
+    @HasPermission("$str.lowerCase($moduleName)_$str.lowerCase($functionName)_export")
     #else
     #else
-    @PreAuthorize("@pms.hasPermission('$str.toLowerCase(${moduleName}_${functionName}_export)')" )
+    @PreAuthorize("@pms.hasPermission('$str.lowerCase($moduleName)_$str.lowerCase($functionName)_export')" )
     #end
     #end
     public List<${ClassName}Entity> exportExcel(${ClassName}Entity ${className},${pk.attrType}[] ids) {
     public List<${ClassName}Entity> exportExcel(${ClassName}Entity ${className},${pk.attrType}[] ids) {
         return ${className}Service.list(Wrappers.lambdaQuery(${className}).in(ArrayUtil.isNotEmpty(ids), ${ClassName}Entity::$str.getProperty($pk.attrName), ids));
         return ${className}Service.list(Wrappers.lambdaQuery(${className}).in(ArrayUtil.isNotEmpty(ids), ${ClassName}Entity::$str.getProperty($pk.attrName), ids));
@@ -197,9 +197,9 @@ public class ${ClassName}Controller {
      */
      */
     @PostMapping("/import")
     @PostMapping("/import")
     #if($isSpringBoot3)
     #if($isSpringBoot3)
-    @HasPermission("$str.toLowerCase(${moduleName}_${functionName}_export)")
+    @HasPermission("$str.lowerCase($moduleName)_$str.lowerCase($functionName)_export")
     #else
     #else
-    @PreAuthorize("@pms.hasPermission('$str.toLowerCase(${moduleName}_${functionName}_export)')" )
+    @PreAuthorize("@pms.hasPermission('$str.lowerCase($moduleName)_$str.lowerCase($functionName)_export')" )
     #end
     #end
     public R importExcel(@RequestExcel List<${ClassName}Entity> ${className}List, BindingResult bindingResult) {
     public R importExcel(@RequestExcel List<${ClassName}Entity> ${className}List, BindingResult bindingResult) {
         return R.ok(${className}Service.saveBatch(${className}List));
         return R.ok(${className}Service.saveBatch(${className}List));

+ 6 - 6
single/表格.vue

@@ -107,7 +107,7 @@
             type="primary" 
             type="primary" 
             class="ml10" 
             class="ml10" 
             @click="formDialogRef.openDialog()"
             @click="formDialogRef.openDialog()"
-            v-auth="'${moduleName}_${functionName}_add'"
+            v-auth="'$str.lowerCase($moduleName)_$str.lowerCase($functionName)_add'"
           >
           >
             新增
             新增
           </el-button>
           </el-button>
@@ -117,7 +117,7 @@
             type="primary" 
             type="primary" 
             class="ml10" 
             class="ml10" 
             @click="excelUploadRef.show()" 
             @click="excelUploadRef.show()" 
-            v-auth="'${moduleName}_${functionName}_add'"
+            v-auth="'$str.lowerCase($moduleName)_$str.lowerCase($functionName)_add'"
           >
           >
             导入
             导入
           </el-button>
           </el-button>
@@ -126,14 +126,14 @@
             :disabled="multiple" 
             :disabled="multiple" 
             icon="Delete" 
             icon="Delete" 
             type="primary"
             type="primary"
-            v-auth="'${moduleName}_${functionName}_del'" 
+            v-auth="'$str.lowerCase($moduleName)_$str.lowerCase($functionName)_del'" 
             @click="handleDelete(selectObjs.value)"
             @click="handleDelete(selectObjs.value)"
           >
           >
             删除
             删除
           </el-button>
           </el-button>
           <right-toolbar 
           <right-toolbar 
             v-model:showSearch="showSearch" 
             v-model:showSearch="showSearch" 
-            :export="'${moduleName}_${functionName}_export'"
+            :export="'$str.lowerCase($moduleName)_$str.lowerCase($functionName)_export'"
             @exportExcel="exportExcel" 
             @exportExcel="exportExcel" 
             class="ml10 mr20" 
             class="ml10 mr20" 
             style="float: right;"
             style="float: right;"
@@ -184,7 +184,7 @@
               icon="edit-pen" 
               icon="edit-pen" 
               text 
               text 
               type="primary" 
               type="primary" 
-              v-auth="'${moduleName}_${functionName}_edit'"
+              v-auth="'$str.lowerCase($moduleName)_$str.lowerCase($functionName)_edit'"
               @click="formDialogRef.openDialog(scope.row.${pk.attrName})"
               @click="formDialogRef.openDialog(scope.row.${pk.attrName})"
             >
             >
               编辑
               编辑
@@ -193,7 +193,7 @@
               icon="delete" 
               icon="delete" 
               text 
               text 
               type="primary" 
               type="primary" 
-              v-auth="'${moduleName}_${functionName}_del'" 
+              v-auth="'$str.lowerCase($moduleName)_$str.lowerCase($functionName)_del'" 
               @click="handleDelete([scope.row.${pk.attrName}])"
               @click="handleDelete([scope.row.${pk.attrName}])"
             >
             >
               删除
               删除

+ 15 - 15
tree/树形Controller.java

@@ -60,9 +60,9 @@ public class ${ClassName}Controller {
     @Operation(summary = "获取树形列表" , description = "获取树形列表" )
     @Operation(summary = "获取树形列表" , description = "获取树形列表" )
     @GetMapping("/tree" )
     @GetMapping("/tree" )
     #if($isSpringBoot3)
     #if($isSpringBoot3)
-    @HasPermission("$str.toLowerCase(${moduleName}_${functionName}_view)")
+    @HasPermission("$str.lowerCase($moduleName)_$str.lowerCase($functionName)_view")
     #else
     #else
-    @PreAuthorize("@pms.hasPermission('$str.toLowerCase(${moduleName}_${functionName}_view)')" )
+    @PreAuthorize("@pms.hasPermission('$str.lowerCase($moduleName)_$str.lowerCase($functionName)_view')" )
     #end
     #end
     public R get${ClassName}Tree(@ParameterObject ${ClassName}Entity ${className}) {
     public R get${ClassName}Tree(@ParameterObject ${ClassName}Entity ${className}) {
         LambdaQueryWrapper<${ClassName}Entity> wrapper = Wrappers.lambdaQuery();
         LambdaQueryWrapper<${ClassName}Entity> wrapper = Wrappers.lambdaQuery();
@@ -109,9 +109,9 @@ public class ${ClassName}Controller {
     @Operation(summary = "通过条件查询" , description = "通过条件查询对象" )
     @Operation(summary = "通过条件查询" , description = "通过条件查询对象" )
     @GetMapping("/details" )
     @GetMapping("/details" )
     #if($isSpringBoot3)
     #if($isSpringBoot3)
-    @HasPermission("$str.toLowerCase(${moduleName}_${functionName}_view)")
+    @HasPermission("$str.lowerCase($moduleName)_$str.lowerCase($functionName)_view")
     #else
     #else
-    @PreAuthorize("@pms.hasPermission('$str.toLowerCase(${moduleName}_${functionName}_view)')" )
+    @PreAuthorize("@pms.hasPermission('$str.lowerCase($moduleName)_$str.lowerCase($functionName)_view')" )
     #end
     #end
     public R getDetails(@ParameterObject ${ClassName}Entity ${className}) {
     public R getDetails(@ParameterObject ${ClassName}Entity ${className}) {
         return R.ok(${className}Service.list(Wrappers.query(${className})));
         return R.ok(${className}Service.list(Wrappers.query(${className})));
@@ -126,9 +126,9 @@ public class ${ClassName}Controller {
     @SysLog("新增${tableComment}" )
     @SysLog("新增${tableComment}" )
     @PostMapping
     @PostMapping
     #if($isSpringBoot3)
     #if($isSpringBoot3)
-    @HasPermission("$str.toLowerCase(${moduleName}_${functionName}_add)")
+    @HasPermission("$str.lowerCase($moduleName)_$str.lowerCase($functionName)_add")
     #else
     #else
-    @PreAuthorize("@pms.hasPermission('$str.toLowerCase(${moduleName}_${functionName}_add)')" )
+    @PreAuthorize("@pms.hasPermission('$str.lowerCase($moduleName)_$str.lowerCase($functionName)_add')" )
     #end
     #end
     public R save(@RequestBody ${ClassName}Entity ${className}) {
     public R save(@RequestBody ${ClassName}Entity ${className}) {
         return R.ok(${className}Service.save(${className}));
         return R.ok(${className}Service.save(${className}));
@@ -143,9 +143,9 @@ public class ${ClassName}Controller {
     @SysLog("修改${tableComment}" )
     @SysLog("修改${tableComment}" )
     @PutMapping
     @PutMapping
     #if($isSpringBoot3)
     #if($isSpringBoot3)
-    @HasPermission("$str.toLowerCase(${moduleName}_${functionName}_edit)")
+    @HasPermission("$str.lowerCase($moduleName)_$str.lowerCase($functionName)_edit")
     #else
     #else
-    @PreAuthorize("@pms.hasPermission('$str.toLowerCase(${moduleName}_${functionName}_edit)')" )
+    @PreAuthorize("@pms.hasPermission('$str.lowerCase($moduleName)_$str.lowerCase($functionName)_edit')" )
     #end
     #end
     public R updateById(@RequestBody ${ClassName}Entity ${className}) {
     public R updateById(@RequestBody ${ClassName}Entity ${className}) {
         return R.ok(${className}Service.updateById(${className}));
         return R.ok(${className}Service.updateById(${className}));
@@ -160,9 +160,9 @@ public class ${ClassName}Controller {
     @SysLog("通过id删除${tableComment}" )
     @SysLog("通过id删除${tableComment}" )
     @DeleteMapping
     @DeleteMapping
     #if($isSpringBoot3)
     #if($isSpringBoot3)
-    @HasPermission("$str.toLowerCase(${moduleName}_${functionName}_del)")
+    @HasPermission("$str.lowerCase($moduleName)_$str.lowerCase($functionName)_del")
     #else
     #else
-    @PreAuthorize("@pms.hasPermission('$str.toLowerCase(${moduleName}_${functionName}_del)')" )
+    @PreAuthorize("@pms.hasPermission('$str.lowerCase($moduleName)_$str.lowerCase($functionName)_del')" )
     #end
     #end
     public R removeById(@RequestBody ${pk.attrType}[] ids) {
     public R removeById(@RequestBody ${pk.attrType}[] ids) {
         return R.ok(${className}Service.removeBatchByIds(CollUtil.toList(ids)));
         return R.ok(${className}Service.removeBatchByIds(CollUtil.toList(ids)));
@@ -177,9 +177,9 @@ public class ${ClassName}Controller {
     @ResponseExcel
     @ResponseExcel
     @GetMapping("/export")
     @GetMapping("/export")
     #if($isSpringBoot3)
     #if($isSpringBoot3)
-    @HasPermission("$str.toLowerCase(${moduleName}_${functionName}_export)")
+    @HasPermission("$str.lowerCase($moduleName)_$str.lowerCase($functionName)_export")
     #else
     #else
-    @PreAuthorize("@pms.hasPermission('$str.toLowerCase(${moduleName}_${functionName}_export)')" )
+    @PreAuthorize("@pms.hasPermission('$str.lowerCase($moduleName)_$str.lowerCase($functionName)_export')" )
     #end
     #end
     public List<${ClassName}Entity> exportExcel(${ClassName}Entity ${className},${pk.attrType}[] ids) {
     public List<${ClassName}Entity> exportExcel(${ClassName}Entity ${className},${pk.attrType}[] ids) {
         return ${className}Service.list(Wrappers.lambdaQuery(${className}).in(ArrayUtil.isNotEmpty(ids), ${ClassName}Entity::$str.getProperty($pk.attrName), ids));
         return ${className}Service.list(Wrappers.lambdaQuery(${className}).in(ArrayUtil.isNotEmpty(ids), ${ClassName}Entity::$str.getProperty($pk.attrName), ids));
@@ -193,11 +193,11 @@ public class ${ClassName}Controller {
      */
      */
     @PostMapping("/import")
     @PostMapping("/import")
     #if($isSpringBoot3)
     #if($isSpringBoot3)
-    @HasPermission("$str.toLowerCase(${moduleName}_${functionName}_export)")
+    @HasPermission("$str.lowerCase($moduleName)_$str.lowerCase($functionName)_export")
     #else
     #else
-    @PreAuthorize("@pms.hasPermission('$str.toLowerCase(${moduleName}_${functionName}_export)')" )
+    @PreAuthorize("@pms.hasPermission('$str.lowerCase($moduleName)_$str.lowerCase($functionName)_export')" )
     #end
     #end
     public R importExcel(@RequestExcel List<${ClassName}Entity> ${className}List, BindingResult bindingResult) {
     public R importExcel(@RequestExcel List<${ClassName}Entity> ${className}List, BindingResult bindingResult) {
         return R.ok(${className}Service.saveBatch(${className}List));
         return R.ok(${className}Service.saveBatch(${className}List));
     }
     }
-} 
+} 

+ 5 - 5
tree/树形表单.vue

@@ -152,12 +152,12 @@ interface TreeNode {
   ${pk.attrName}: string | number | null;
   ${pk.attrName}: string | number | null;
 #foreach($field in $formList)
 #foreach($field in $formList)
 #if($field.attrName != ${pk.attrName} && $field.attrName != ${parentField})
 #if($field.attrName != ${pk.attrName} && $field.attrName != ${parentField})
-#set($nameField = $field)
+#set($treeNameField = $field)
 #break
 #break
 #end
 #end
 #end
 #end
-#if($nameField)
-  ${nameField.attrName}: string;
+#if($treeNameField)
+  ${treeNameField.attrName}: string;
 #end
 #end
   children?: TreeNode[];
   children?: TreeNode[];
 }
 }
@@ -310,7 +310,7 @@ const openDialog = async (id?: string, parentId?: string | number) => {
 
 
   // 初始化父级节点数据
   // 初始化父级节点数据
   const { data } = await fetchTreeList();
   const { data } = await fetchTreeList();
-  parentNodes.value = [{ ${pk.attrName}: '0', ${nameField.attrName}: '根节点', children: data }];
+  parentNodes.value = [{ ${pk.attrName}: '0', ${treeNameField.attrName}: '根节点', children: data }];
 
 
   // 重置表单验证
   // 重置表单验证
   nextTick(() => {
   nextTick(() => {
@@ -360,4 +360,4 @@ const onSubmit = async () => {
 defineExpose({
 defineExpose({
   openDialog
   openDialog
 });
 });
-</script> 
+</script> 

+ 6 - 6
tree/树形表格.vue

@@ -107,7 +107,7 @@
             type="primary" 
             type="primary" 
             class="ml10" 
             class="ml10" 
             @click="formDialogRef.openDialog()"
             @click="formDialogRef.openDialog()"
-            v-auth="'${moduleName}_${functionName}_add'"
+            v-auth="'$str.lowerCase($moduleName)_$str.lowerCase($functionName)_add'"
           >
           >
             新增
             新增
           </el-button>
           </el-button>
@@ -117,7 +117,7 @@
             :disabled="multiple" 
             :disabled="multiple" 
             icon="Delete" 
             icon="Delete" 
             type="primary"
             type="primary"
-            v-auth="'${moduleName}_${functionName}_del'" 
+            v-auth="'$str.lowerCase($moduleName)_$str.lowerCase($functionName)_del'" 
             @click="handleDelete(selectObjs)"
             @click="handleDelete(selectObjs)"
           >
           >
             删除
             删除
@@ -187,7 +187,7 @@
               icon="plus" 
               icon="plus" 
               text 
               text 
               type="primary" 
               type="primary" 
-              v-auth="'${moduleName}_${functionName}_add'"
+              v-auth="'$str.lowerCase($moduleName)_$str.lowerCase($functionName)_add'"
               @click="formDialogRef.openDialog(undefined, scope.row.${pk.attrName})"
               @click="formDialogRef.openDialog(undefined, scope.row.${pk.attrName})"
             >
             >
               新增
               新增
@@ -196,7 +196,7 @@
               icon="edit-pen" 
               icon="edit-pen" 
               text 
               text 
               type="primary" 
               type="primary" 
-              v-auth="'${moduleName}_${functionName}_edit'"
+              v-auth="'$str.lowerCase($moduleName)_$str.lowerCase($functionName)_edit'"
               @click="formDialogRef.openDialog(scope.row.${pk.attrName})"
               @click="formDialogRef.openDialog(scope.row.${pk.attrName})"
             >
             >
               编辑
               编辑
@@ -205,7 +205,7 @@
               icon="delete" 
               icon="delete" 
               text 
               text 
               type="primary" 
               type="primary" 
-              v-auth="'${moduleName}_${functionName}_del'" 
+              v-auth="'$str.lowerCase($moduleName)_$str.lowerCase($functionName)_del'" 
               @click="handleDelete([scope.row.${pk.attrName}])"
               @click="handleDelete([scope.row.${pk.attrName}])"
             >
             >
               删除
               删除
@@ -367,4 +367,4 @@ const toggleExpand = (children: any[], unfold = true) => {
 onMounted(() => {
 onMounted(() => {
   getDataList();
   getDataList();
 });
 });
-</script>
+</script>