diff --git a/db/8pigxx_codegen.sql b/db/8pigxx_codegen.sql index 605773bc5..2b3a5ca90 100644 --- a/db/8pigxx_codegen.sql +++ b/db/8pigxx_codegen.sql @@ -234,25 +234,25 @@ CREATE TABLE `gen_template` ( -- Records of gen_template -- ---------------------------- BEGIN; -INSERT INTO `gen_template` VALUES (1, 'vform.json', '/', '表单设计器初始化json模板', '#set($key=${dateTool.getSystemTime()})\n{\n \"widgetList\": [\n {\n \"key\": $key,\n \"type\": \"grid\",\n \"category\": \"container\",\n \"icon\": \"grid\",\n \"cols\": [\n#foreach($field in $formList)\n#if($field.attrName != ${pk.attrName})\n {\n \"type\": \"grid-col\",\n \"category\": \"container\",\n \"icon\": \"grid-col\",\n \"internal\": true,\n \"widgetList\": [\n {\n \"key\": ${math.add($key,${foreach.index})},\n #if($field.formType == \'text\')\n \"type\": \"input\",\n \"icon\": \"text-field\",\n #elseif($field.formType == \'number\')\n \"type\": \"number\",\n \"icon\": \"number-field\",\n #elseif($field.formType == \'textarea\')\n \"type\": \"textarea\",\n \"icon\": \"textarea-field\",\n #elseif($field.formType == \'select\' && ${field.fieldDict})\n \"type\": \"select\",\n \"icon\": \"select-field\",\n #elseif($field.formType == \'radio\' && ${field.fieldDict})\n \"type\": \"radio\",\n \"icon\": \"radio-field\",\n #elseif($field.formType == \'checkbox\' && ${field.fieldDict} )\n \"type\": \"checkbox\",\n \"icon\": \"checkbox-field\",\n #elseif($field.formType == \'date\')\n \"type\": \"date\",\n \"icon\": \"date-field\",\n #elseif($field.formType == \'datetime\')\n \"type\": \"time\",\n \"icon\": \"time-field\",\n #elseif($field.formType == \'upload-file\')\n \"type\": \"file-upload\",\n \"icon\": \"file-upload-field\",\n #elseif($field.formType == \'upload-img\')\n \"type\": \"picture-upload\",\n \"icon\": \"picture-upload-field\",\n #elseif($field.formType == \'editor\')\n \"type\": \"rich-editor\",\n \"icon\": \"rich-editor-field\",\n #else\n \"type\": \"input\",\n \"icon\": \"text-field\",\n #end\n \"formItemFlag\": true,\n \"options\": {\n \"name\": \"${field.attrName}\",\n \"label\": \"#if(${field.fieldComment})${field.fieldComment}#else ${field.attrName}#end\",\n #if(($field.formType == \'select\' || $field.formType == \'radio\' || $field.formType == \'checkbox\') && ${field.fieldDict})\n \"optionItemsDictType\": \"${field.fieldDict}\",\n #end\n \"placeholder\": \"请输入#if(${field.fieldComment})${field.fieldComment}#else ${field.attrName}#end\"\n },\n #if($field.formRequired)\n \"required\": true,\n #end\n \"id\": \"input${math.add($key,${foreach.index})}\"\n }\n ],\n \"options\": {\n \"name\": \"gridCol${math.add($key,${foreach.index})}\",\n \"hidden\": false,\n \"offset\": 0,\n \"push\": 0,\n \"pull\": 0,\n #if($formLayout == 1)\n \"span\": 24,\n #elseif($formLayout == 2)\n \"span\": 12,\n #end\n \"responsive\": false\n },\n \"id\": \"grid-col-${math.add($key,${foreach.index})}\"\n }#if($foreach.hasNext),#end\n#end\n#end\n ],\n \"options\": {\n \"name\": \"grid${functionName}\",\n \"hidden\": false,\n \"gutter\": 12\n },\n \"id\": \"grid${functionName}\"\n }\n ],\n \"formConfig\": {\n \"modelName\": \"form\",\n \"refName\": \"form\",\n \"rulesName\": \"rules\",\n \"labelWidth\": 80,\n \"labelPosition\": \"left\",\n \"labelAlign\": \"label-left-align\",\n \"layoutType\": \"PC\",\n \"jsonVersion\": 3\n }\n}', '2023-02-23 04:33:16', '2023-06-04 10:35:51', '0', 1, ' ', ' '); -INSERT INTO `gen_template` VALUES (2, 'vform.vue', '/', '表单设计器生成sfc模板', '\n\n', '2023-02-23 04:33:52', '2023-08-28 22:08:59', '0', 1, '', 'admin'); -INSERT INTO `gen_template` VALUES (3, 'Controller', '${backendPath}/src/main/java/${packagePath}/${moduleName}/controller/${ClassName}Controller.java', '后台Controller', 'package ${package}.${moduleName}.controller;\n\n#if($queryList)\nimport cn.hutool.core.util.StrUtil;\n#end\nimport cn.hutool.core.util.ArrayUtil;\nimport cn.hutool.core.collection.CollUtil;\nimport com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;\nimport com.baomidou.mybatisplus.core.toolkit.Wrappers;\nimport com.baomidou.mybatisplus.extension.plugins.pagination.Page;\nimport com.pig4cloud.pigx.common.core.util.R;\nimport com.pig4cloud.pigx.common.log.annotation.SysLog;\nimport ${package}.${moduleName}.entity.${ClassName}Entity;\nimport ${package}.${moduleName}.service.${ClassName}Service;\nimport org.springframework.security.access.prepost.PreAuthorize;\nimport com.pig4cloud.pigx.common.excel.annotation.ResponseExcel;\nimport io.swagger.v3.oas.annotations.security.SecurityRequirement;\n#if($isSpringBoot3)\nimport org.springdoc.core.annotations.ParameterObject;\n#else\nimport org.springdoc.api.annotations.ParameterObject;\n#end\nimport org.springframework.http.HttpHeaders;\nimport io.swagger.v3.oas.annotations.tags.Tag;\nimport io.swagger.v3.oas.annotations.Operation;\nimport lombok.RequiredArgsConstructor;\nimport org.springframework.web.bind.annotation.*;\n\nimport java.util.List;\nimport java.util.Objects;\n\n/**\n * ${tableComment}\n *\n * @author ${author}\n * @date ${datetime}\n */\n@RestController\n@RequiredArgsConstructor\n@RequestMapping(\"/${functionName}\" )\n@Tag(description = \"${functionName}\" , name = \"${tableComment}管理\" )\n@SecurityRequirement(name = HttpHeaders.AUTHORIZATION)\npublic class ${ClassName}Controller {\n\n private final ${ClassName}Service ${className}Service;\n\n /**\n * 分页查询\n * @param page 分页对象\n * @param ${className} ${tableComment}\n * @return\n */\n @Operation(summary = \"分页查询\" , description = \"分页查询\" )\n @GetMapping(\"/page\" )\n @PreAuthorize(\"@pms.hasPermission(\'${moduleName}_${functionName}_view\')\" )\n public R get${ClassName}Page(@ParameterObject Page page, @ParameterObject ${ClassName}Entity ${className}) {\n LambdaQueryWrapper<${ClassName}Entity> wrapper = Wrappers.lambdaQuery();\n#foreach ($field in $queryList)\n#set($getAttrName=$str.getProperty($field.attrName))\n#set($var=\"${className}.$getAttrName()\")\n#if($field.attrType == \'String\')\n#set($expression=\"StrUtil.isNotBlank\")\n#else\n#set($expression=\"Objects.nonNull\")\n#end\n#if($field.queryType == \'=\')\n wrapper.eq($expression($var),${ClassName}Entity::$getAttrName,$var);\n#elseif( $field.queryType == \'like\' )\n wrapper.like($expression($var),${ClassName}Entity::$getAttrName,$var);\n#elseif( $field.queryType == \'!-\' )\n wrapper.ne($expression($var),${ClassName}Entity::$getAttrName,$var);\n#elseif( $field.queryType == \'>\' )\n wrapper.gt($expression($var),${ClassName}Entity::$getAttrName,$var);\n#elseif( $field.queryType == \'<\' )\n wrapper.lt($expression($var),${ClassName}Entity::$getAttrName,$var);\n#elseif( $field.queryType == \'>=\' )\n wrapper.ge($expression($var),${ClassName}Entity::$getAttrName,$var);\n#elseif( $field.queryType == \'<=\' )\n wrapper.le($expression($var),${ClassName}Entity::$getAttrName,$var);\n#elseif( $field.queryType == \'left like\' )\n wrapper.likeLeft($expression($var),${ClassName}Entity::$getAttrName,$var);\n#elseif( $field.queryType == \'right like\' )\n wrapper.likeRight($expression($var),${ClassName}Entity::$getAttrName,$var);\n#end\n#end\n return R.ok(${className}Service.page(page, wrapper));\n }\n\n\n /**\n * 通过id查询${tableComment}\n * @param ${pk.attrName} id\n * @return R\n */\n @Operation(summary = \"通过id查询\" , description = \"通过id查询\" )\n @GetMapping(\"/{${pk.attrName}}\" )\n @PreAuthorize(\"@pms.hasPermission(\'${moduleName}_${functionName}_view\')\" )\n public R getById(@PathVariable(\"${pk.attrName}\" ) ${pk.attrType} ${pk.attrName}) {\n return R.ok(${className}Service.getById(${pk.attrName}));\n }\n\n /**\n * 新增${tableComment}\n * @param ${className} ${tableComment}\n * @return R\n */\n @Operation(summary = \"新增${tableComment}\" , description = \"新增${tableComment}\" )\n @SysLog(\"新增${tableComment}\" )\n @PostMapping\n @PreAuthorize(\"@pms.hasPermission(\'${moduleName}_${functionName}_add\')\" )\n public R save(@RequestBody ${ClassName}Entity ${className}) {\n return R.ok(${className}Service.save(${className}));\n }\n\n /**\n * 修改${tableComment}\n * @param ${className} ${tableComment}\n * @return R\n */\n @Operation(summary = \"修改${tableComment}\" , description = \"修改${tableComment}\" )\n @SysLog(\"修改${tableComment}\" )\n @PutMapping\n @PreAuthorize(\"@pms.hasPermission(\'${moduleName}_${functionName}_edit\')\" )\n public R updateById(@RequestBody ${ClassName}Entity ${className}) {\n return R.ok(${className}Service.updateById(${className}));\n }\n\n /**\n * 通过id删除${tableComment}\n * @param ids ${pk.attrName}列表\n * @return R\n */\n @Operation(summary = \"通过id删除${tableComment}\" , description = \"通过id删除${tableComment}\" )\n @SysLog(\"通过id删除${tableComment}\" )\n @DeleteMapping\n @PreAuthorize(\"@pms.hasPermission(\'${moduleName}_${functionName}_del\')\" )\n public R removeById(@RequestBody ${pk.attrType}[] ids) {\n return R.ok(${className}Service.removeBatchByIds(CollUtil.toList(ids)));\n }\n\n\n /**\n * 导出excel 表格\n * @param ${className} 查询条件\n * @param ids 导出指定ID\n * @return excel 文件流\n */\n @ResponseExcel\n @GetMapping(\"/export\")\n @PreAuthorize(\"@pms.hasPermission(\'${moduleName}_${functionName}_export\')\" )\n public List<${ClassName}Entity> export(${ClassName}Entity ${className},${pk.attrType}[] ids) {\n return ${className}Service.list(Wrappers.lambdaQuery(${className}).in(ArrayUtil.isNotEmpty(ids), ${ClassName}Entity::$str.getProperty($pk.attrName), ids));\n }\n}', '2023-02-23 01:16:17', '2023-10-29 12:18:12', '0', 1, '', 'admin'); -INSERT INTO `gen_template` VALUES (4, 'Service', '${backendPath}/src/main/java/${packagePath}/${moduleName}/service/${ClassName}Service.java', 'Service', 'package ${package}.${moduleName}.service;\n\n#if($ChildClassName)\nimport com.github.yulichang.extension.mapping.base.MPJDeepService;\nimport ${package}.${moduleName}.entity.${ChildClassName}Entity;\n#else\nimport com.baomidou.mybatisplus.extension.service.IService;\n#end\nimport ${package}.${moduleName}.entity.${ClassName}Entity;\n\n#if($ChildClassName)\npublic interface ${ClassName}Service extends MPJDeepService<${ClassName}Entity> {\n Boolean saveDeep(${ClassName}Entity ${className});\n\n Boolean updateDeep(${ClassName}Entity ${className});\n\n Boolean removeDeep(Long[] ids);\n\n Boolean removeChild(Long[] ids);\n#else\npublic interface ${ClassName}Service extends IService<${ClassName}Entity> {\n#end\n\n}', '2023-02-23 01:16:53', '2023-06-04 10:35:25', '0', 1, ' ', ' '); -INSERT INTO `gen_template` VALUES (5, 'ServiceImpl', '${backendPath}/src/main/java/${packagePath}/${moduleName}/service/impl/${ClassName}ServiceImpl.java', 'ServiceImpl', 'package ${package}.${moduleName}.service.impl;\n\nimport com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;\nimport ${package}.${moduleName}.entity.${ClassName}Entity;\nimport ${package}.${moduleName}.mapper.${ClassName}Mapper;\nimport ${package}.${moduleName}.service.${ClassName}Service;\nimport org.springframework.stereotype.Service;\n#if($ChildClassName)\nimport cn.hutool.core.collection.CollUtil;\nimport com.baomidou.mybatisplus.core.toolkit.Wrappers;\nimport ${package}.${moduleName}.entity.${ChildClassName}Entity;\nimport ${package}.${moduleName}.mapper.${ChildClassName}Mapper;\nimport org.springframework.transaction.annotation.Transactional;\nimport lombok.RequiredArgsConstructor;\nimport java.util.Objects;\n#end\n/**\n * ${tableComment}\n *\n * @author ${author}\n * @date ${datetime}\n */\n@Service\n#if($ChildClassName)\n@RequiredArgsConstructor\n#end\npublic class ${ClassName}ServiceImpl extends ServiceImpl<${ClassName}Mapper, ${ClassName}Entity> implements ${ClassName}Service {\n#if($ChildClassName)\n private final ${ChildClassName}Mapper ${childClassName}Mapper;\n\n @Override\n @Transactional(rollbackFor = Exception.class)\n public Boolean saveDeep(${ClassName}Entity ${className}) {\n baseMapper.insert(${className});\n for (${ChildClassName}Entity ${childClassName} : ${className}.get${ChildClassName}List()) {\n ${childClassName}.$str.setProperty($childField)(${className}.$str.getProperty($mainField)());\n ${childClassName}Mapper.insert( ${childClassName});\n }\n\n return Boolean.TRUE;\n }\n\n @Override\n @Transactional(rollbackFor = Exception.class)\n public Boolean updateDeep(${ClassName}Entity ${className}) {\n baseMapper.updateById(${className});\n for (${ChildClassName}Entity ${childClassName} : ${className}.get${ChildClassName}List()) {\n#set($getChildPkName=$str.getProperty(${pk.attrName}))\n if (Objects.isNull(${childClassName}.$getChildPkName())) {\n ${childClassName}.$str.setProperty($childField)(${className}.$str.getProperty($mainField)());\n ${childClassName}Mapper.insert(${childClassName});\n } else {\n ${childClassName}Mapper.updateById(${childClassName});\n }\n }\n return Boolean.TRUE;\n }\n\n @Override\n @Transactional(rollbackFor = Exception.class)\n public Boolean removeDeep(Long[] ids) {\n baseMapper.deleteBatchIds(CollUtil.toList(ids));\n ${childClassName}Mapper.delete(Wrappers.<${ChildClassName}Entity>lambdaQuery().in(${ChildClassName}Entity::$str.getProperty($childField), ids));\n return Boolean.TRUE;\n }\n\n @Override\n @Transactional(rollbackFor = Exception.class)\n public Boolean removeChild(Long[] ids) {\n ${childClassName}Mapper.deleteBatchIds(CollUtil.toList(ids));\n return Boolean.TRUE;\n }\n#end\n}', '2023-02-23 01:17:36', '2023-08-27 23:29:58', '0', 1, ' ', ' '); -INSERT INTO `gen_template` VALUES (6, '实体', '${backendPath}/src/main/java/${packagePath}/${moduleName}/entity/${ClassName}Entity.java', 'Entity', 'package ${package}.${moduleName}.entity;\n\nimport com.baomidou.mybatisplus.annotation.*;\nimport com.baomidou.mybatisplus.extension.activerecord.Model;\nimport io.swagger.v3.oas.annotations.media.Schema;\nimport lombok.Data;\nimport lombok.EqualsAndHashCode;\n#foreach($import in $importList)\nimport $import;\n#end\n#if($ChildClassName)\nimport com.alibaba.excel.annotation.ExcelIgnore;\nimport com.github.yulichang.annotation.EntityMapping;\nimport java.util.List;\n#end\n\n/**\n * ${tableComment}\n *\n * @author ${author}\n * @date ${datetime}\n */\n@Data\n@TableName(\"${tableName}\")\n@EqualsAndHashCode(callSuper = true)\n@Schema(description = \"${tableComment}\")\npublic class ${ClassName}Entity extends Model<${ClassName}Entity> {\n\n#foreach ($field in $fieldList)\n#if(${field.fieldComment})#set($comment=${field.fieldComment})#else #set($comment=${field.attrName})#end\n\n /**\n * $comment\n */\n#if($field.primaryPk == \'1\')\n @TableId(type = IdType.ASSIGN_ID)\n#end\n#if($field.autoFill == \'INSERT\')\n @TableField(fill = FieldFill.INSERT)\n#elseif($field.autoFill == \'INSERT_UPDATE\')\n @TableField(fill = FieldFill.INSERT_UPDATE)\n#elseif($field.autoFill == \'UPDATE\')\n @TableField(fill = FieldFill.UPDATE)\n#end\n#if($field.fieldName == \'del_flag\')\n @TableLogic\n @TableField(fill = FieldFill.INSERT)\n#end\n @Schema(description=\"$comment\"#if($field.hidden),hidden=$field.hidden#end)\n#if($field.formType == \'checkbox\')\n private ${field.attrType}[] $field.attrName;\n#else\n private $field.attrType $field.attrName;\n#end \n#end\n#if($ChildClassName)\n @ExcelIgnore\n @TableField(exist = false)\n @EntityMapping(thisField = \"$mainField\", joinField = \"$childField\")\n private List<${ChildClassName}Entity> ${childClassName}List;\n#end\n}', '2023-02-23 01:17:53', '2023-09-12 16:20:57', '0', 1, ' ', ' '); -INSERT INTO `gen_template` VALUES (7, 'Mapper', '${backendPath}/src/main/java/${packagePath}/${moduleName}/mapper/${ClassName}Mapper.java', 'Mapper', 'package ${package}.${moduleName}.mapper;\n\nimport com.pig4cloud.pigx.common.data.datascope.PigxBaseMapper;\nimport ${package}.${moduleName}.entity.${ClassName}Entity;\nimport org.apache.ibatis.annotations.Mapper;\n\n@Mapper\npublic interface ${ClassName}Mapper extends PigxBaseMapper<${ClassName}Entity> {\n\n\n}', '2023-02-23 01:18:18', '2023-08-13 13:52:50', '0', 1, ' ', ' '); -INSERT INTO `gen_template` VALUES (8, 'Mapper.xml', '${backendPath}/src/main/resources/mapper/${ClassName}Mapper.xml', 'Mapper.xml', '\n\n\n\n\n \n#foreach ($field in $fieldList)\n #if($field.primaryPk == \'1\')\n \n #else\n \n #end\n#end\n \n', '2023-02-23 01:18:35', '2023-09-23 21:36:09', '0', 1, ' ', ' '); -INSERT INTO `gen_template` VALUES (9, '权限菜单', '${backendPath}/menu/${functionName}_menu.sql', 'menu.sql', '-- 该脚本不要直接执行, 注意维护菜单的父节点ID 默认 父节点-1 , 默认租户 1\n#set($menuId=${dateTool.getSystemTime()})\n\n-- 菜单SQL\ninsert into sys_menu ( menu_id,parent_id, path, permission, menu_type, icon, del_flag, create_time, sort_order, update_time, name, tenant_id)\nvalues (${menuId}, \'-1\', \'/${moduleName}/${functionName}/index\', \'\', \'0\', \'icon-bangzhushouji\', \'0\', null , \'8\', null , \'${tableComment}管理\', 1);\n\n-- 菜单对应按钮SQL\ninsert into sys_menu ( menu_id,parent_id, permission, menu_type, path, icon, del_flag, create_time, sort_order, update_time, name, tenant_id)\nvalues (${math.add($menuId,1)},${menuId}, \'${moduleName}_${functionName}_view\', \'1\', null, \'1\', \'0\', null, \'0\', null, \'${tableComment}查看\', 1);\n\ninsert into sys_menu ( menu_id,parent_id, permission, menu_type, path, icon, del_flag, create_time, sort_order, update_time, name, tenant_id)\nvalues (${math.add($menuId,2)},${menuId}, \'${moduleName}_${functionName}_add\', \'1\', null, \'1\', \'0\', null, \'1\', null, \'${tableComment}新增\', 1);\n\ninsert into sys_menu (menu_id, parent_id, permission, menu_type, path, icon, del_flag, create_time, sort_order, update_time, name, tenant_id)\nvalues (${math.add($menuId,3)},${menuId}, \'${moduleName}_${functionName}_edit\', \'1\', null, \'1\', \'0\', null, \'2\', null, \'${tableComment}修改\', 1);\n\ninsert into sys_menu (menu_id, parent_id, permission, menu_type, path, icon, del_flag, create_time, sort_order, update_time, name, tenant_id)\nvalues (${math.add($menuId,4)},${menuId}, \'${moduleName}_${functionName}_del\', \'1\', null, \'1\', \'0\', null, \'3\', null, \'${tableComment}删除\', 1);\n\ninsert into sys_menu ( menu_id,parent_id, permission, menu_type, path, icon, del_flag, create_time, sort_order, update_time, name, tenant_id)\nvalues (${math.add($menuId,5)},${menuId}, \'${moduleName}_${functionName}_export\', \'1\', null, \'1\', \'0\', null, \'3\', null, \'导入导出\', 1);', '2023-02-23 01:19:08', '2023-08-27 23:16:31', '0', 1, ' ', ' '); -INSERT INTO `gen_template` VALUES (10, 'api.ts', '${frontendPath}/src/api/${moduleName}/${functionName}.ts', 'api.ts', 'import request from \"/@/utils/request\"\n\nexport function fetchList(query?: Object) {\n return request({\n url: \'/${moduleName}/${functionName}/page\',\n method: \'get\',\n params: query\n })\n}\n\nexport function addObj(obj?: Object) {\n return request({\n url: \'/${moduleName}/${functionName}\',\n method: \'post\',\n data: obj\n })\n}\n\nexport function getObj(id?: string) {\n return request({\n url: \'/${moduleName}/${functionName}/\' + id,\n method: \'get\'\n })\n}\n\nexport function delObjs(ids?: Object) {\n return request({\n url: \'/${moduleName}/${functionName}\',\n method: \'delete\',\n data: ids\n })\n}\n\nexport function putObj(obj?: Object) {\n return request({\n url: \'/${moduleName}/${functionName}\',\n method: \'put\',\n data: obj\n })\n}\n\n#if($ChildClassName)\nexport function delChildObj(ids?: Object) {\n return request({\n url: \'/${moduleName}/${functionName}/child\',\n method: \'delete\',\n data: ids\n })\n}\n#end', '2023-02-23 01:19:23', '2023-06-04 10:34:17', '0', 1, ' ', ' '); -INSERT INTO `gen_template` VALUES (11, '表格', '${frontendPath}/src/views/${moduleName}/${functionName}/index.vue', '表格不含i18n', '\n\n', '2023-02-23 01:19:35', '2023-08-29 14:27:53', '0', 1, '', 'admin'); -INSERT INTO `gen_template` VALUES (12, '表单', '${frontendPath}/src/views/${moduleName}/${functionName}/form.vue', '表单不含i18n', '\n\n', '2023-02-23 01:19:48', '2023-12-07 13:20:22', '0', 1, '', 'admin'); -INSERT INTO `gen_template` VALUES (13, 'i18n英文模板', '${frontendPath}/src/views/${moduleName}/${functionName}/i18n/en.ts', 'i18n英文模板', 'export default {\n ${functionName}: {\n index: \'#\',\n import${className}Tip: \'import ${ClassName}\',\n#foreach($field in $fieldList)\n ${field.attrName}: \'${field.attrName}\',\n#end\n#foreach($field in $fieldList)\n input$str.pascalCase(${field.attrName})Tip: \'input ${field.attrName}\',\n#end\n }\n}', '2023-02-23 01:20:25', '2023-06-04 10:49:25', '0', 1, '', 'admin'); -INSERT INTO `gen_template` VALUES (14, 'i18n中文模板', '${frontendPath}/src/views/${moduleName}/${functionName}/i18n/zh-cn.ts', 'i18n中文模板', 'export default {\n ${functionName}: {\n index: \'#\',\n import${className}Tip: \'导入${tableComment}\',\n#foreach($field in $fieldList)\n ${field.attrName}: \'#if(${field.fieldComment})${field.fieldComment}#else ${field.attrName}#end\',\n#end\n#foreach($field in $fieldList)\n input$str.pascalCase(${field.attrName})Tip: \'请输入#if(${field.fieldComment})${field.fieldComment}#else ${field.attrName}#end\',\n#end\n }\n}', '2023-02-23 01:20:40', '2023-06-04 10:49:28', '0', 1, '', 'admin'); -INSERT INTO `gen_template` VALUES (15, '子实体', '${backendPath}/src/main/java/${packagePath}/${moduleName}/entity/${ChildClassName}Entity.java', '子表实体对象', 'package ${package}.${moduleName}.entity;\n\nimport com.baomidou.mybatisplus.annotation.*;\nimport com.baomidou.mybatisplus.extension.activerecord.Model;\nimport io.swagger.v3.oas.annotations.media.Schema;\nimport lombok.Data;\nimport lombok.EqualsAndHashCode;\n#foreach($import in $importList)\nimport $import;\n#end\n\n/**\n * ${tableComment}\n *\n * @author ${author}\n * @date ${datetime}\n */\n@Data\n@TableName(\"${childTableName}\")\n@EqualsAndHashCode(callSuper = true)\n@Schema(description = \"${childTableName}\")\npublic class ${ChildClassName}Entity extends Model<${ChildClassName}Entity> {\n\n#foreach ($field in $childFieldList)\n#if(${field.fieldComment})#set($comment=${field.fieldComment})#else #set($comment=${field.attrName})#end\n /**\n * $comment\n */\n#if($field.primaryPk == \'1\')\n @TableId(type = IdType.ASSIGN_ID)\n#end\n#if($field.autoFill == \'INSERT\')\n @TableField(fill = FieldFill.INSERT)\n#elseif($field.autoFill == \'INSERT_UPDATE\')\n @TableField(fill = FieldFill.INSERT_UPDATE)\n#elseif($field.autoFill == \'UPDATE\')\n @TableField(fill = FieldFill.UPDATE)\n#end\n#if($field.fieldName == \'del_flag\')\n @TableLogic\n @TableField(fill = FieldFill.INSERT)\n#end\n @Schema(description=\"$comment\"#if($field.hidden),hidden=$field.hidden#end)\n#if($field.formType == \'checkbox\')\n private ${field.attrType}[] $field.attrName;\n#else\n private $field.attrType $field.attrName;\n#end \n#end\n}\n', '2023-06-01 11:07:14', '2023-09-12 16:32:33', '0', 1, ' ', ' '); -INSERT INTO `gen_template` VALUES (16, '主子Contoller', '${backendPath}/src/main/java/${packagePath}/${moduleName}/controller/${ClassName}Controller.java', '子表Controller对象', 'package ${package}.${moduleName}.controller;\n\n#if($queryList)\nimport cn.hutool.core.util.StrUtil;\n#end\nimport cn.hutool.core.util.ArrayUtil;\nimport com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;\nimport com.baomidou.mybatisplus.core.toolkit.Wrappers;\nimport com.baomidou.mybatisplus.extension.plugins.pagination.Page;\nimport com.pig4cloud.pigx.common.core.util.R;\nimport com.pig4cloud.pigx.common.log.annotation.SysLog;\nimport ${package}.${moduleName}.entity.${ClassName}Entity;\nimport ${package}.${moduleName}.entity.${ChildClassName}Entity;\nimport ${package}.${moduleName}.service.${ClassName}Service;\nimport org.springframework.security.access.prepost.PreAuthorize;\nimport com.pig4cloud.pigx.common.excel.annotation.ResponseExcel;\nimport io.swagger.v3.oas.annotations.security.SecurityRequirement;\n#if($isSpringBoot3)\nimport org.springdoc.core.annotations.ParameterObject;\n#else\nimport org.springdoc.api.annotations.ParameterObject;\n#end\nimport org.springframework.http.HttpHeaders;\nimport io.swagger.v3.oas.annotations.tags.Tag;\nimport io.swagger.v3.oas.annotations.Operation;\nimport lombok.RequiredArgsConstructor;\nimport org.springframework.web.bind.annotation.*;\n\nimport java.util.List;\nimport java.util.Objects;\n\n/**\n * ${tableComment}\n *\n * @author ${author}\n * @date ${datetime}\n */\n@RestController\n@RequiredArgsConstructor\n@RequestMapping(\"/${functionName}\" )\n@Tag(description = \"${functionName}\" , name = \"${tableComment}管理\" )\n@SecurityRequirement(name = HttpHeaders.AUTHORIZATION)\npublic class ${ClassName}Controller {\n\n private final ${ClassName}Service ${className}Service;\n\n /**\n * 分页查询\n * @param page 分页对象\n * @param ${className} ${tableComment}\n * @return\n */\n @Operation(summary = \"分页查询\" , description = \"分页查询\" )\n @GetMapping(\"/page\" )\n @PreAuthorize(\"@pms.hasPermission(\'${moduleName}_${functionName}_view\')\" )\n public R get${ClassName}Page(@ParameterObject Page page, @ParameterObject ${ClassName}Entity ${className}) {\n LambdaQueryWrapper<${ClassName}Entity> wrapper = Wrappers.lambdaQuery();\n#foreach ($field in $queryList)\n#set($getAttrName=$str.getProperty($field.attrName))\n#set($var=\"${className}.$getAttrName()\")\n#if($field.attrType == \'String\')\n#set($expression=\"StrUtil.isNotBlank\")\n#else\n#set($expression=\"Objects.nonNull\")\n#end\n#if($field.queryType == \'=\')\n wrapper.eq($expression($var),${ClassName}Entity::$getAttrName,$var);\n#elseif( $field.queryType == \'like\' )\n wrapper.like($expression($var),${ClassName}Entity::$getAttrName,$var);\n#elseif( $field.queryType == \'!-\' )\n wrapper.ne($expression($var),${ClassName}Entity::$getAttrName,$var);\n#elseif( $field.queryType == \'>\' )\n wrapper.gt($expression($var),${ClassName}Entity::$getAttrName,$var);\n#elseif( $field.queryType == \'<\' )\n wrapper.lt($expression($var),${ClassName}Entity::$getAttrName,$var);\n#elseif( $field.queryType == \'>=\' )\n wrapper.ge($expression($var),${ClassName}Entity::$getAttrName,$var);\n#elseif( $field.queryType == \'<=\' )\n wrapper.le($expression($var),${ClassName}Entity::$getAttrName,$var);\n#elseif( $field.queryType == \'left like\' )\n wrapper.likeLeft($expression($var),${ClassName}Entity::$getAttrName,$var);\n#elseif( $field.queryType == \'right like\' )\n wrapper.likeRight($expression($var),${ClassName}Entity::$getAttrName,$var);\n#end\n#end\n return R.ok(${className}Service.page(page, wrapper));\n }\n\n /**\n * 通过id查询${tableComment}\n * @param ${pk.attrName} id\n * @return R\n */\n @Operation(summary = \"通过id查询\" , description = \"通过id查询\" )\n @GetMapping(\"/{${pk.attrName}}\" )\n @PreAuthorize(\"@pms.hasPermission(\'${moduleName}_${functionName}_view\')\" )\n public R getById(@PathVariable(\"${pk.attrName}\" ) ${pk.attrType} ${pk.attrName}) {\n return R.ok(${className}Service.getByIdDeep(${pk.attrName}));\n }\n\n /**\n * 新增${tableComment}\n * @param ${className} ${tableComment}\n * @return R\n */\n @Operation(summary = \"新增${tableComment}\" , description = \"新增${tableComment}\" )\n @SysLog(\"新增${tableComment}\" )\n @PostMapping\n @PreAuthorize(\"@pms.hasPermission(\'${moduleName}_${functionName}_add\')\" )\n public R save(@RequestBody ${ClassName}Entity ${className}) {\n return R.ok(${className}Service.saveDeep(${className}));\n }\n\n /**\n * 修改${tableComment}\n * @param ${className} ${tableComment}\n * @return R\n */\n @Operation(summary = \"修改${tableComment}\" , description = \"修改${tableComment}\" )\n @SysLog(\"修改${tableComment}\" )\n @PutMapping\n @PreAuthorize(\"@pms.hasPermission(\'${moduleName}_${functionName}_edit\')\" )\n public R updateById(@RequestBody ${ClassName}Entity ${className}) {\n return R.ok(${className}Service.updateDeep(${className}));\n }\n\n /**\n * 通过id删除${tableComment}\n * @param ids ${pk.attrName}列表\n * @return R\n */\n @Operation(summary = \"通过id删除${tableComment}\" , description = \"通过id删除${tableComment}\" )\n @SysLog(\"通过id删除${tableComment}\" )\n @DeleteMapping\n @PreAuthorize(\"@pms.hasPermission(\'${moduleName}_${functionName}_del\')\" )\n public R removeById(@RequestBody ${pk.attrType}[] ids) {\n return R.ok(${className}Service.removeDeep(ids));\n }\n\n /**\n * 通过id删除${tableComment}子表数据\n * @param ids ${pk.attrName}列表\n * @return R\n */\n @Operation(summary = \"通过id删除${tableComment}子表数据\" , description = \"通过id删除${tableComment}子表数据\" )\n @SysLog(\"通过id删除${tableComment}子表数据\" )\n @DeleteMapping(\"/child\")\n @PreAuthorize(\"@pms.hasPermission(\'${moduleName}_${functionName}_del\')\" )\n public R removeChild(@RequestBody ${pk.attrType}[] ids) {\n return R.ok(${className}Service.removeChild(ids));\n }\n\n /**\n * 导出excel 表格\n * @param ${className} 查询条件\n * @param ids 导出指定ID\n * @return excel 文件流\n */\n @ResponseExcel\n @GetMapping(\"/export\")\n @PreAuthorize(\"@pms.hasPermission(\'${moduleName}_${functionName}_export\')\" )\n public List<${ClassName}Entity> export(${ClassName}Entity ${className},${pk.attrType}[] ids) {\n return ${className}Service.list(Wrappers.lambdaQuery(${className}).in(ArrayUtil.isNotEmpty(ids), ${ClassName}Entity::$str.getProperty($pk.attrName), ids));\n }\n}', '2023-06-01 11:25:28', '2023-10-29 12:17:52', '0', 1, '', 'admin'); -INSERT INTO `gen_template` VALUES (17, '主子表单', '${frontendPath}/src/views/${moduleName}/${functionName}/form.vue', '子表表单', '\n\n', '2023-06-01 15:42:46', '2023-12-07 13:22:29', '0', 1, '', 'admin'); -INSERT INTO `gen_template` VALUES (18, '主子表格', '${frontendPath}/src/views/${moduleName}/${functionName}/index.vue', '子表单表格', '\n\n', '2023-06-01 15:43:31', '2023-08-29 10:53:23', '0', 1, ' ', ' '); -INSERT INTO `gen_template` VALUES (19, '子Mapper', '${backendPath}/src/main/java/${packagePath}/${moduleName}/mapper/${ChildClassName}Mapper.java', '子Mapper', 'package ${package}.${moduleName}.mapper;\n\nimport com.pig4cloud.pigx.common.data.datascope.PigxBaseMapper;\n#if($ChildClassName)\nimport ${package}.${moduleName}.entity.${ChildClassName}Entity;\n#else\nimport ${package}.${moduleName}.entity.${ClassName}Entity;\n#end\nimport org.apache.ibatis.annotations.Mapper;\n\n@Mapper\n#if($ChildClassName)\npublic interface ${ChildClassName}Mapper extends PigxBaseMapper<${ChildClassName}Entity> {\n#else\npublic interface ${ClassName}Mapper extends PigxBaseMapper<${ClassName}Entity> {\n#end\n\n}', '2023-02-23 01:18:18', '2023-08-07 09:54:36', '0', 1, ' ', ' '); +INSERT INTO `gen_template` (`id`, `template_name`, `generator_path`, `template_desc`, `template_code`, `create_time`, `update_time`, `del_flag`, `tenant_id`, `create_by`, `update_by`) VALUES (1, 'vform.json', '/', '表单设计器初始化json模板', '#set($key=${dateTool.getSystemTime()})\n{\n \"widgetList\": [\n {\n \"key\": $key,\n \"type\": \"grid\",\n \"category\": \"container\",\n \"icon\": \"grid\",\n \"cols\": [\n#foreach($field in $formList)\n#if($field.attrName != ${pk.attrName})\n {\n \"type\": \"grid-col\",\n \"category\": \"container\",\n \"icon\": \"grid-col\",\n \"internal\": true,\n \"widgetList\": [\n {\n \"key\": ${math.add($key,${foreach.index})},\n #if($field.formType == \'text\')\n \"type\": \"input\",\n \"icon\": \"text-field\",\n #elseif($field.formType == \'number\')\n \"type\": \"number\",\n \"icon\": \"number-field\",\n #elseif($field.formType == \'textarea\')\n \"type\": \"textarea\",\n \"icon\": \"textarea-field\",\n #elseif($field.formType == \'select\' && ${field.fieldDict})\n \"type\": \"select\",\n \"icon\": \"select-field\",\n #elseif($field.formType == \'radio\' && ${field.fieldDict})\n \"type\": \"radio\",\n \"icon\": \"radio-field\",\n #elseif($field.formType == \'checkbox\' && ${field.fieldDict} )\n \"type\": \"checkbox\",\n \"icon\": \"checkbox-field\",\n #elseif($field.formType == \'date\')\n \"type\": \"date\",\n \"icon\": \"date-field\",\n #elseif($field.formType == \'datetime\')\n \"type\": \"time\",\n \"icon\": \"time-field\",\n #elseif($field.formType == \'upload-file\')\n \"type\": \"file-upload\",\n \"icon\": \"file-upload-field\",\n #elseif($field.formType == \'upload-img\')\n \"type\": \"picture-upload\",\n \"icon\": \"picture-upload-field\",\n #elseif($field.formType == \'editor\')\n \"type\": \"rich-editor\",\n \"icon\": \"rich-editor-field\",\n #else\n \"type\": \"input\",\n \"icon\": \"text-field\",\n #end\n \"formItemFlag\": true,\n \"options\": {\n \"name\": \"${field.attrName}\",\n \"label\": \"#if(${field.fieldComment})${field.fieldComment}#else ${field.attrName}#end\",\n #if(($field.formType == \'select\' || $field.formType == \'radio\' || $field.formType == \'checkbox\') && ${field.fieldDict})\n \"optionItemsDictType\": \"${field.fieldDict}\",\n #end\n \"placeholder\": \"请输入#if(${field.fieldComment})${field.fieldComment}#else ${field.attrName}#end\"\n },\n #if($field.formRequired)\n \"required\": true,\n #end\n \"id\": \"input${math.add($key,${foreach.index})}\"\n }\n ],\n \"options\": {\n \"name\": \"gridCol${math.add($key,${foreach.index})}\",\n \"hidden\": false,\n \"offset\": 0,\n \"push\": 0,\n \"pull\": 0,\n #if($formLayout == 1)\n \"span\": 24,\n #elseif($formLayout == 2)\n \"span\": 12,\n #end\n \"responsive\": false\n },\n \"id\": \"grid-col-${math.add($key,${foreach.index})}\"\n }#if($foreach.hasNext),#end\n#end\n#end\n ],\n \"options\": {\n \"name\": \"grid${functionName}\",\n \"hidden\": false,\n \"gutter\": 12\n },\n \"id\": \"grid${functionName}\"\n }\n ],\n \"formConfig\": {\n \"modelName\": \"form\",\n \"refName\": \"form\",\n \"rulesName\": \"rules\",\n \"labelWidth\": 80,\n \"labelPosition\": \"left\",\n \"labelAlign\": \"label-left-align\",\n \"layoutType\": \"PC\",\n \"jsonVersion\": 3\n }\n}', '2023-02-23 04:33:16', '2023-06-04 10:35:51', '0', 1, ' ', ' '); +INSERT INTO `gen_template` (`id`, `template_name`, `generator_path`, `template_desc`, `template_code`, `create_time`, `update_time`, `del_flag`, `tenant_id`, `create_by`, `update_by`) VALUES (2, 'vform.vue', '/', '表单设计器生成sfc模板', '\n\n', '2023-02-23 04:33:52', '2023-08-28 22:08:59', '0', 1, '', 'admin'); +INSERT INTO `gen_template` (`id`, `template_name`, `generator_path`, `template_desc`, `template_code`, `create_time`, `update_time`, `del_flag`, `tenant_id`, `create_by`, `update_by`) VALUES (3, 'Controller', '${backendPath}/src/main/java/${packagePath}/${moduleName}/controller/${ClassName}Controller.java', '后台Controller', 'package ${package}.${moduleName}.controller;\n\n#if($queryList)\nimport cn.hutool.core.util.StrUtil;\n#end\nimport cn.hutool.core.util.ArrayUtil;\nimport cn.hutool.core.collection.CollUtil;\nimport com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;\nimport com.baomidou.mybatisplus.core.toolkit.Wrappers;\nimport com.baomidou.mybatisplus.extension.plugins.pagination.Page;\nimport com.pig4cloud.pigx.common.core.util.R;\nimport com.pig4cloud.pigx.common.log.annotation.SysLog;\nimport ${package}.${moduleName}.entity.${ClassName}Entity;\nimport ${package}.${moduleName}.service.${ClassName}Service;\nimport org.springframework.security.access.prepost.PreAuthorize;\nimport com.pig4cloud.pigx.common.excel.annotation.ResponseExcel;\nimport io.swagger.v3.oas.annotations.security.SecurityRequirement;\n#if($isSpringBoot3)\nimport org.springdoc.core.annotations.ParameterObject;\n#else\nimport org.springdoc.api.annotations.ParameterObject;\n#end\nimport org.springframework.http.HttpHeaders;\nimport io.swagger.v3.oas.annotations.tags.Tag;\nimport io.swagger.v3.oas.annotations.Operation;\nimport lombok.RequiredArgsConstructor;\nimport org.springframework.web.bind.annotation.*;\n\nimport java.util.List;\nimport java.util.Objects;\n\n/**\n * ${tableComment}\n *\n * @author ${author}\n * @date ${datetime}\n */\n@RestController\n@RequiredArgsConstructor\n@RequestMapping(\"/${functionName}\" )\n@Tag(description = \"${functionName}\" , name = \"${tableComment}管理\" )\n@SecurityRequirement(name = HttpHeaders.AUTHORIZATION)\npublic class ${ClassName}Controller {\n\n private final ${ClassName}Service ${className}Service;\n\n /**\n * 分页查询\n * @param page 分页对象\n * @param ${className} ${tableComment}\n * @return\n */\n @Operation(summary = \"分页查询\" , description = \"分页查询\" )\n @GetMapping(\"/page\" )\n @PreAuthorize(\"@pms.hasPermission(\'${moduleName}_${functionName}_view\')\" )\n public R get${ClassName}Page(@ParameterObject Page page, @ParameterObject ${ClassName}Entity ${className}) {\n LambdaQueryWrapper<${ClassName}Entity> wrapper = Wrappers.lambdaQuery();\n#foreach ($field in $queryList)\n#set($getAttrName=$str.getProperty($field.attrName))\n#set($var=\"${className}.$getAttrName()\")\n#if($field.attrType == \'String\')\n#set($expression=\"StrUtil.isNotBlank\")\n#else\n#set($expression=\"Objects.nonNull\")\n#end\n#if($field.queryType == \'=\')\n wrapper.eq($expression($var),${ClassName}Entity::$getAttrName,$var);\n#elseif( $field.queryType == \'like\' )\n wrapper.like($expression($var),${ClassName}Entity::$getAttrName,$var);\n#elseif( $field.queryType == \'!-\' )\n wrapper.ne($expression($var),${ClassName}Entity::$getAttrName,$var);\n#elseif( $field.queryType == \'>\' )\n wrapper.gt($expression($var),${ClassName}Entity::$getAttrName,$var);\n#elseif( $field.queryType == \'<\' )\n wrapper.lt($expression($var),${ClassName}Entity::$getAttrName,$var);\n#elseif( $field.queryType == \'>=\' )\n wrapper.ge($expression($var),${ClassName}Entity::$getAttrName,$var);\n#elseif( $field.queryType == \'<=\' )\n wrapper.le($expression($var),${ClassName}Entity::$getAttrName,$var);\n#elseif( $field.queryType == \'left like\' )\n wrapper.likeLeft($expression($var),${ClassName}Entity::$getAttrName,$var);\n#elseif( $field.queryType == \'right like\' )\n wrapper.likeRight($expression($var),${ClassName}Entity::$getAttrName,$var);\n#end\n#end\n return R.ok(${className}Service.page(page, wrapper));\n }\n\n\n /**\n * 通过id查询${tableComment}\n * @param ${pk.attrName} id\n * @return R\n */\n @Operation(summary = \"通过id查询\" , description = \"通过id查询\" )\n @GetMapping(\"/{${pk.attrName}}\" )\n @PreAuthorize(\"@pms.hasPermission(\'${moduleName}_${functionName}_view\')\" )\n public R getById(@PathVariable(\"${pk.attrName}\" ) ${pk.attrType} ${pk.attrName}) {\n return R.ok(${className}Service.getById(${pk.attrName}));\n }\n\n /**\n * 新增${tableComment}\n * @param ${className} ${tableComment}\n * @return R\n */\n @Operation(summary = \"新增${tableComment}\" , description = \"新增${tableComment}\" )\n @SysLog(\"新增${tableComment}\" )\n @PostMapping\n @PreAuthorize(\"@pms.hasPermission(\'${moduleName}_${functionName}_add\')\" )\n public R save(@RequestBody ${ClassName}Entity ${className}) {\n return R.ok(${className}Service.save(${className}));\n }\n\n /**\n * 修改${tableComment}\n * @param ${className} ${tableComment}\n * @return R\n */\n @Operation(summary = \"修改${tableComment}\" , description = \"修改${tableComment}\" )\n @SysLog(\"修改${tableComment}\" )\n @PutMapping\n @PreAuthorize(\"@pms.hasPermission(\'${moduleName}_${functionName}_edit\')\" )\n public R updateById(@RequestBody ${ClassName}Entity ${className}) {\n return R.ok(${className}Service.updateById(${className}));\n }\n\n /**\n * 通过id删除${tableComment}\n * @param ids ${pk.attrName}列表\n * @return R\n */\n @Operation(summary = \"通过id删除${tableComment}\" , description = \"通过id删除${tableComment}\" )\n @SysLog(\"通过id删除${tableComment}\" )\n @DeleteMapping\n @PreAuthorize(\"@pms.hasPermission(\'${moduleName}_${functionName}_del\')\" )\n public R removeById(@RequestBody ${pk.attrType}[] ids) {\n return R.ok(${className}Service.removeBatchByIds(CollUtil.toList(ids)));\n }\n\n\n /**\n * 导出excel 表格\n * @param ${className} 查询条件\n * @param ids 导出指定ID\n * @return excel 文件流\n */\n @ResponseExcel\n @GetMapping(\"/export\")\n @PreAuthorize(\"@pms.hasPermission(\'${moduleName}_${functionName}_export\')\" )\n public List<${ClassName}Entity> export(${ClassName}Entity ${className},${pk.attrType}[] ids) {\n return ${className}Service.list(Wrappers.lambdaQuery(${className}).in(ArrayUtil.isNotEmpty(ids), ${ClassName}Entity::$str.getProperty($pk.attrName), ids));\n }\n}', '2023-02-23 01:16:17', '2023-10-29 12:18:12', '0', 1, '', 'admin'); +INSERT INTO `gen_template` (`id`, `template_name`, `generator_path`, `template_desc`, `template_code`, `create_time`, `update_time`, `del_flag`, `tenant_id`, `create_by`, `update_by`) VALUES (4, 'Service', '${backendPath}/src/main/java/${packagePath}/${moduleName}/service/${ClassName}Service.java', 'Service', 'package ${package}.${moduleName}.service;\n\n#if($ChildClassName)\nimport com.github.yulichang.extension.mapping.base.MPJDeepService;\nimport ${package}.${moduleName}.entity.${ChildClassName}Entity;\n#else\nimport com.baomidou.mybatisplus.extension.service.IService;\n#end\nimport ${package}.${moduleName}.entity.${ClassName}Entity;\n\n#if($ChildClassName)\npublic interface ${ClassName}Service extends MPJDeepService<${ClassName}Entity> {\n Boolean saveDeep(${ClassName}Entity ${className});\n\n Boolean updateDeep(${ClassName}Entity ${className});\n\n Boolean removeDeep(Long[] ids);\n\n Boolean removeChild(Long[] ids);\n#else\npublic interface ${ClassName}Service extends IService<${ClassName}Entity> {\n#end\n\n}', '2023-02-23 01:16:53', '2023-06-04 10:35:25', '0', 1, ' ', ' '); +INSERT INTO `gen_template` (`id`, `template_name`, `generator_path`, `template_desc`, `template_code`, `create_time`, `update_time`, `del_flag`, `tenant_id`, `create_by`, `update_by`) VALUES (5, 'ServiceImpl', '${backendPath}/src/main/java/${packagePath}/${moduleName}/service/impl/${ClassName}ServiceImpl.java', 'ServiceImpl', 'package ${package}.${moduleName}.service.impl;\n\nimport com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;\nimport ${package}.${moduleName}.entity.${ClassName}Entity;\nimport ${package}.${moduleName}.mapper.${ClassName}Mapper;\nimport ${package}.${moduleName}.service.${ClassName}Service;\nimport org.springframework.stereotype.Service;\n#if($ChildClassName)\nimport cn.hutool.core.collection.CollUtil;\nimport com.baomidou.mybatisplus.core.toolkit.Wrappers;\nimport ${package}.${moduleName}.entity.${ChildClassName}Entity;\nimport ${package}.${moduleName}.mapper.${ChildClassName}Mapper;\nimport org.springframework.transaction.annotation.Transactional;\nimport lombok.RequiredArgsConstructor;\nimport java.util.Objects;\n#end\n/**\n * ${tableComment}\n *\n * @author ${author}\n * @date ${datetime}\n */\n@Service\n#if($ChildClassName)\n@RequiredArgsConstructor\n#end\npublic class ${ClassName}ServiceImpl extends ServiceImpl<${ClassName}Mapper, ${ClassName}Entity> implements ${ClassName}Service {\n#if($ChildClassName)\n private final ${ChildClassName}Mapper ${childClassName}Mapper;\n\n @Override\n @Transactional(rollbackFor = Exception.class)\n public Boolean saveDeep(${ClassName}Entity ${className}) {\n baseMapper.insert(${className});\n for (${ChildClassName}Entity ${childClassName} : ${className}.get${ChildClassName}List()) {\n ${childClassName}.$str.setProperty($childField)(${className}.$str.getProperty($mainField)());\n ${childClassName}Mapper.insert( ${childClassName});\n }\n\n return Boolean.TRUE;\n }\n\n @Override\n @Transactional(rollbackFor = Exception.class)\n public Boolean updateDeep(${ClassName}Entity ${className}) {\n baseMapper.updateById(${className});\n for (${ChildClassName}Entity ${childClassName} : ${className}.get${ChildClassName}List()) {\n#set($getChildPkName=$str.getProperty(${pk.attrName}))\n if (Objects.isNull(${childClassName}.$getChildPkName())) {\n ${childClassName}.$str.setProperty($childField)(${className}.$str.getProperty($mainField)());\n ${childClassName}Mapper.insert(${childClassName});\n } else {\n ${childClassName}Mapper.updateById(${childClassName});\n }\n }\n return Boolean.TRUE;\n }\n\n @Override\n @Transactional(rollbackFor = Exception.class)\n public Boolean removeDeep(Long[] ids) {\n baseMapper.deleteBatchIds(CollUtil.toList(ids));\n ${childClassName}Mapper.delete(Wrappers.<${ChildClassName}Entity>lambdaQuery().in(${ChildClassName}Entity::$str.getProperty($childField), ids));\n return Boolean.TRUE;\n }\n\n @Override\n @Transactional(rollbackFor = Exception.class)\n public Boolean removeChild(Long[] ids) {\n ${childClassName}Mapper.deleteBatchIds(CollUtil.toList(ids));\n return Boolean.TRUE;\n }\n#end\n}', '2023-02-23 01:17:36', '2023-08-27 23:29:58', '0', 1, ' ', ' '); +INSERT INTO `gen_template` (`id`, `template_name`, `generator_path`, `template_desc`, `template_code`, `create_time`, `update_time`, `del_flag`, `tenant_id`, `create_by`, `update_by`) VALUES (6, '实体', '${backendPath}/src/main/java/${packagePath}/${moduleName}/entity/${ClassName}Entity.java', 'Entity', 'package ${package}.${moduleName}.entity;\n\nimport com.baomidou.mybatisplus.annotation.*;\nimport com.baomidou.mybatisplus.extension.activerecord.Model;\nimport io.swagger.v3.oas.annotations.media.Schema;\nimport lombok.Data;\nimport lombok.EqualsAndHashCode;\n#if($isTenant)\nimport com.pig4cloud.pigx.common.core.util.TenantTable;\n#end\n#foreach($import in $importList)\nimport $import;\n#end\n#if($ChildClassName)\nimport com.alibaba.excel.annotation.ExcelIgnore;\nimport com.github.yulichang.annotation.EntityMapping;\nimport java.util.List;\n#end\n\n/**\n * ${tableComment}\n *\n * @author ${author}\n * @date ${datetime}\n */\n@Data\n#if($isTenant)\n@TenantTable\n#end\n@TableName(\"${tableName}\")\n@EqualsAndHashCode(callSuper = true)\n@Schema(description = \"${tableComment}\")\npublic class ${ClassName}Entity extends Model<${ClassName}Entity> {\n\n#foreach ($field in $fieldList)\n#if(${field.fieldComment})#set($comment=${field.fieldComment})#else #set($comment=${field.attrName})#end\n\n /**\n * $comment\n */\n#if($field.primaryPk == \'1\')\n @TableId(type = IdType.ASSIGN_ID)\n#end\n#if($field.autoFill == \'INSERT\')\n @TableField(fill = FieldFill.INSERT)\n#elseif($field.autoFill == \'INSERT_UPDATE\')\n @TableField(fill = FieldFill.INSERT_UPDATE)\n#elseif($field.autoFill == \'UPDATE\')\n @TableField(fill = FieldFill.UPDATE)\n#end\n#if($field.fieldName == \'del_flag\')\n @TableLogic\n @TableField(fill = FieldFill.INSERT)\n#end\n @Schema(description=\"$comment\"#if($field.hidden),hidden=$field.hidden#end)\n#if($field.formType == \'checkbox\')\n private ${field.attrType}[] $field.attrName;\n#else\n private $field.attrType $field.attrName;\n#end \n#end\n#if($ChildClassName)\n @ExcelIgnore\n @TableField(exist = false)\n @EntityMapping(thisField = \"$mainField\", joinField = \"$childField\")\n private List<${ChildClassName}Entity> ${childClassName}List;\n#end\n}', '2023-02-23 01:17:53', '2024-05-12 15:15:47', '0', 1, '', 'admin'); +INSERT INTO `gen_template` (`id`, `template_name`, `generator_path`, `template_desc`, `template_code`, `create_time`, `update_time`, `del_flag`, `tenant_id`, `create_by`, `update_by`) VALUES (7, 'Mapper', '${backendPath}/src/main/java/${packagePath}/${moduleName}/mapper/${ClassName}Mapper.java', 'Mapper', 'package ${package}.${moduleName}.mapper;\n\nimport com.pig4cloud.pigx.common.data.datascope.PigxBaseMapper;\nimport ${package}.${moduleName}.entity.${ClassName}Entity;\nimport org.apache.ibatis.annotations.Mapper;\n\n@Mapper\npublic interface ${ClassName}Mapper extends PigxBaseMapper<${ClassName}Entity> {\n\n\n}', '2023-02-23 01:18:18', '2023-08-13 13:52:50', '0', 1, ' ', ' '); +INSERT INTO `gen_template` (`id`, `template_name`, `generator_path`, `template_desc`, `template_code`, `create_time`, `update_time`, `del_flag`, `tenant_id`, `create_by`, `update_by`) VALUES (8, 'Mapper.xml', '${backendPath}/src/main/resources/mapper/${ClassName}Mapper.xml', 'Mapper.xml', '\n\n\n\n\n \n#foreach ($field in $fieldList)\n #if($field.primaryPk == \'1\')\n \n #else\n \n #end\n#end\n \n', '2023-02-23 01:18:35', '2023-09-23 21:36:09', '0', 1, ' ', ' '); +INSERT INTO `gen_template` (`id`, `template_name`, `generator_path`, `template_desc`, `template_code`, `create_time`, `update_time`, `del_flag`, `tenant_id`, `create_by`, `update_by`) VALUES (9, '权限菜单', '${backendPath}/menu/${functionName}_menu.sql', 'menu.sql', '-- 该脚本不要直接执行, 注意维护菜单的父节点ID 默认 父节点-1 , 默认租户 1\n#set($menuId=${dateTool.getSystemTime()})\n\n-- 菜单SQL\ninsert into sys_menu ( menu_id,parent_id, path, permission, menu_type, icon, del_flag, create_time, sort_order, update_time, name, tenant_id)\nvalues (${menuId}, \'-1\', \'/${moduleName}/${functionName}/index\', \'\', \'0\', \'icon-bangzhushouji\', \'0\', null , \'8\', null , \'${tableComment}管理\', 1);\n\n-- 菜单对应按钮SQL\ninsert into sys_menu ( menu_id,parent_id, permission, menu_type, path, icon, del_flag, create_time, sort_order, update_time, name, tenant_id)\nvalues (${math.add($menuId,1)},${menuId}, \'${moduleName}_${functionName}_view\', \'1\', null, \'1\', \'0\', null, \'0\', null, \'${tableComment}查看\', 1);\n\ninsert into sys_menu ( menu_id,parent_id, permission, menu_type, path, icon, del_flag, create_time, sort_order, update_time, name, tenant_id)\nvalues (${math.add($menuId,2)},${menuId}, \'${moduleName}_${functionName}_add\', \'1\', null, \'1\', \'0\', null, \'1\', null, \'${tableComment}新增\', 1);\n\ninsert into sys_menu (menu_id, parent_id, permission, menu_type, path, icon, del_flag, create_time, sort_order, update_time, name, tenant_id)\nvalues (${math.add($menuId,3)},${menuId}, \'${moduleName}_${functionName}_edit\', \'1\', null, \'1\', \'0\', null, \'2\', null, \'${tableComment}修改\', 1);\n\ninsert into sys_menu (menu_id, parent_id, permission, menu_type, path, icon, del_flag, create_time, sort_order, update_time, name, tenant_id)\nvalues (${math.add($menuId,4)},${menuId}, \'${moduleName}_${functionName}_del\', \'1\', null, \'1\', \'0\', null, \'3\', null, \'${tableComment}删除\', 1);\n\ninsert into sys_menu ( menu_id,parent_id, permission, menu_type, path, icon, del_flag, create_time, sort_order, update_time, name, tenant_id)\nvalues (${math.add($menuId,5)},${menuId}, \'${moduleName}_${functionName}_export\', \'1\', null, \'1\', \'0\', null, \'3\', null, \'导入导出\', 1);', '2023-02-23 01:19:08', '2023-08-27 23:16:31', '0', 1, ' ', ' '); +INSERT INTO `gen_template` (`id`, `template_name`, `generator_path`, `template_desc`, `template_code`, `create_time`, `update_time`, `del_flag`, `tenant_id`, `create_by`, `update_by`) VALUES (10, 'api.ts', '${frontendPath}/src/api/${moduleName}/${functionName}.ts', 'api.ts', 'import request from \"/@/utils/request\"\n\nexport function fetchList(query?: Object) {\n return request({\n url: \'/${moduleName}/${functionName}/page\',\n method: \'get\',\n params: query\n })\n}\n\nexport function addObj(obj?: Object) {\n return request({\n url: \'/${moduleName}/${functionName}\',\n method: \'post\',\n data: obj\n })\n}\n\nexport function getObj(id?: string) {\n return request({\n url: \'/${moduleName}/${functionName}/\' + id,\n method: \'get\'\n })\n}\n\nexport function delObjs(ids?: Object) {\n return request({\n url: \'/${moduleName}/${functionName}\',\n method: \'delete\',\n data: ids\n })\n}\n\nexport function putObj(obj?: Object) {\n return request({\n url: \'/${moduleName}/${functionName}\',\n method: \'put\',\n data: obj\n })\n}\n\n#if($ChildClassName)\nexport function delChildObj(ids?: Object) {\n return request({\n url: \'/${moduleName}/${functionName}/child\',\n method: \'delete\',\n data: ids\n })\n}\n#end', '2023-02-23 01:19:23', '2023-06-04 10:34:17', '0', 1, ' ', ' '); +INSERT INTO `gen_template` (`id`, `template_name`, `generator_path`, `template_desc`, `template_code`, `create_time`, `update_time`, `del_flag`, `tenant_id`, `create_by`, `update_by`) VALUES (11, '表格', '${frontendPath}/src/views/${moduleName}/${functionName}/index.vue', '表格不含i18n', '\n\n', '2023-02-23 01:19:35', '2023-08-29 14:27:53', '0', 1, '', 'admin'); +INSERT INTO `gen_template` (`id`, `template_name`, `generator_path`, `template_desc`, `template_code`, `create_time`, `update_time`, `del_flag`, `tenant_id`, `create_by`, `update_by`) VALUES (12, '表单', '${frontendPath}/src/views/${moduleName}/${functionName}/form.vue', '表单不含i18n', '\n\n', '2023-02-23 01:19:48', '2023-12-07 13:20:22', '0', 1, '', 'admin'); +INSERT INTO `gen_template` (`id`, `template_name`, `generator_path`, `template_desc`, `template_code`, `create_time`, `update_time`, `del_flag`, `tenant_id`, `create_by`, `update_by`) VALUES (13, 'i18n英文模板', '${frontendPath}/src/views/${moduleName}/${functionName}/i18n/en.ts', 'i18n英文模板', 'export default {\n ${functionName}: {\n index: \'#\',\n import${className}Tip: \'import ${ClassName}\',\n#foreach($field in $fieldList)\n ${field.attrName}: \'${field.attrName}\',\n#end\n#foreach($field in $fieldList)\n input$str.pascalCase(${field.attrName})Tip: \'input ${field.attrName}\',\n#end\n }\n}', '2023-02-23 01:20:25', '2023-06-04 10:49:25', '0', 1, '', 'admin'); +INSERT INTO `gen_template` (`id`, `template_name`, `generator_path`, `template_desc`, `template_code`, `create_time`, `update_time`, `del_flag`, `tenant_id`, `create_by`, `update_by`) VALUES (14, 'i18n中文模板', '${frontendPath}/src/views/${moduleName}/${functionName}/i18n/zh-cn.ts', 'i18n中文模板', 'export default {\n ${functionName}: {\n index: \'#\',\n import${className}Tip: \'导入${tableComment}\',\n#foreach($field in $fieldList)\n ${field.attrName}: \'#if(${field.fieldComment})${field.fieldComment}#else ${field.attrName}#end\',\n#end\n#foreach($field in $fieldList)\n input$str.pascalCase(${field.attrName})Tip: \'请输入#if(${field.fieldComment})${field.fieldComment}#else ${field.attrName}#end\',\n#end\n }\n}', '2023-02-23 01:20:40', '2023-06-04 10:49:28', '0', 1, '', 'admin'); +INSERT INTO `gen_template` (`id`, `template_name`, `generator_path`, `template_desc`, `template_code`, `create_time`, `update_time`, `del_flag`, `tenant_id`, `create_by`, `update_by`) VALUES (15, '子实体', '${backendPath}/src/main/java/${packagePath}/${moduleName}/entity/${ChildClassName}Entity.java', '子表实体对象', 'package ${package}.${moduleName}.entity;\n\nimport com.baomidou.mybatisplus.annotation.*;\nimport com.baomidou.mybatisplus.extension.activerecord.Model;\nimport io.swagger.v3.oas.annotations.media.Schema;\n#if($isChildTenant)\nimport com.pig4cloud.pigx.common.core.util.TenantTable;\n#end\nimport lombok.Data;\nimport lombok.EqualsAndHashCode;\n#foreach($import in $importList)\nimport $import;\n#end\n\n/**\n * ${tableComment}\n *\n * @author ${author}\n * @date ${datetime}\n */\n@Data\n#if($isChildTenant)\n@TenantTable\n#end\n@TableName(\"${childTableName}\")\n@EqualsAndHashCode(callSuper = true)\n@Schema(description = \"${childTableName}\")\npublic class ${ChildClassName}Entity extends Model<${ChildClassName}Entity> {\n\n#foreach ($field in $childFieldList)\n#if(${field.fieldComment})#set($comment=${field.fieldComment})#else #set($comment=${field.attrName})#end\n /**\n * $comment\n */\n#if($field.primaryPk == \'1\')\n @TableId(type = IdType.ASSIGN_ID)\n#end\n#if($field.autoFill == \'INSERT\')\n @TableField(fill = FieldFill.INSERT)\n#elseif($field.autoFill == \'INSERT_UPDATE\')\n @TableField(fill = FieldFill.INSERT_UPDATE)\n#elseif($field.autoFill == \'UPDATE\')\n @TableField(fill = FieldFill.UPDATE)\n#end\n#if($field.fieldName == \'del_flag\')\n @TableLogic\n @TableField(fill = FieldFill.INSERT)\n#end\n @Schema(description=\"$comment\"#if($field.hidden),hidden=$field.hidden#end)\n#if($field.formType == \'checkbox\')\n private ${field.attrType}[] $field.attrName;\n#else\n private $field.attrType $field.attrName;\n#end \n#end\n}', '2023-06-01 11:07:14', '2024-05-12 15:07:04', '0', 1, '', 'admin'); +INSERT INTO `gen_template` (`id`, `template_name`, `generator_path`, `template_desc`, `template_code`, `create_time`, `update_time`, `del_flag`, `tenant_id`, `create_by`, `update_by`) VALUES (16, '主子Contoller', '${backendPath}/src/main/java/${packagePath}/${moduleName}/controller/${ClassName}Controller.java', '子表Controller对象', 'package ${package}.${moduleName}.controller;\n\n#if($queryList)\nimport cn.hutool.core.util.StrUtil;\n#end\nimport cn.hutool.core.util.ArrayUtil;\nimport com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;\nimport com.baomidou.mybatisplus.core.toolkit.Wrappers;\nimport com.baomidou.mybatisplus.extension.plugins.pagination.Page;\nimport com.pig4cloud.pigx.common.core.util.R;\nimport com.pig4cloud.pigx.common.log.annotation.SysLog;\nimport ${package}.${moduleName}.entity.${ClassName}Entity;\nimport ${package}.${moduleName}.entity.${ChildClassName}Entity;\nimport ${package}.${moduleName}.service.${ClassName}Service;\nimport org.springframework.security.access.prepost.PreAuthorize;\nimport com.pig4cloud.pigx.common.excel.annotation.ResponseExcel;\nimport io.swagger.v3.oas.annotations.security.SecurityRequirement;\n#if($isSpringBoot3)\nimport org.springdoc.core.annotations.ParameterObject;\n#else\nimport org.springdoc.api.annotations.ParameterObject;\n#end\nimport org.springframework.http.HttpHeaders;\nimport io.swagger.v3.oas.annotations.tags.Tag;\nimport io.swagger.v3.oas.annotations.Operation;\nimport lombok.RequiredArgsConstructor;\nimport org.springframework.web.bind.annotation.*;\n\nimport java.util.List;\nimport java.util.Objects;\n\n/**\n * ${tableComment}\n *\n * @author ${author}\n * @date ${datetime}\n */\n@RestController\n@RequiredArgsConstructor\n@RequestMapping(\"/${functionName}\" )\n@Tag(description = \"${functionName}\" , name = \"${tableComment}管理\" )\n@SecurityRequirement(name = HttpHeaders.AUTHORIZATION)\npublic class ${ClassName}Controller {\n\n private final ${ClassName}Service ${className}Service;\n\n /**\n * 分页查询\n * @param page 分页对象\n * @param ${className} ${tableComment}\n * @return\n */\n @Operation(summary = \"分页查询\" , description = \"分页查询\" )\n @GetMapping(\"/page\" )\n @PreAuthorize(\"@pms.hasPermission(\'${moduleName}_${functionName}_view\')\" )\n public R get${ClassName}Page(@ParameterObject Page page, @ParameterObject ${ClassName}Entity ${className}) {\n LambdaQueryWrapper<${ClassName}Entity> wrapper = Wrappers.lambdaQuery();\n#foreach ($field in $queryList)\n#set($getAttrName=$str.getProperty($field.attrName))\n#set($var=\"${className}.$getAttrName()\")\n#if($field.attrType == \'String\')\n#set($expression=\"StrUtil.isNotBlank\")\n#else\n#set($expression=\"Objects.nonNull\")\n#end\n#if($field.queryType == \'=\')\n wrapper.eq($expression($var),${ClassName}Entity::$getAttrName,$var);\n#elseif( $field.queryType == \'like\' )\n wrapper.like($expression($var),${ClassName}Entity::$getAttrName,$var);\n#elseif( $field.queryType == \'!-\' )\n wrapper.ne($expression($var),${ClassName}Entity::$getAttrName,$var);\n#elseif( $field.queryType == \'>\' )\n wrapper.gt($expression($var),${ClassName}Entity::$getAttrName,$var);\n#elseif( $field.queryType == \'<\' )\n wrapper.lt($expression($var),${ClassName}Entity::$getAttrName,$var);\n#elseif( $field.queryType == \'>=\' )\n wrapper.ge($expression($var),${ClassName}Entity::$getAttrName,$var);\n#elseif( $field.queryType == \'<=\' )\n wrapper.le($expression($var),${ClassName}Entity::$getAttrName,$var);\n#elseif( $field.queryType == \'left like\' )\n wrapper.likeLeft($expression($var),${ClassName}Entity::$getAttrName,$var);\n#elseif( $field.queryType == \'right like\' )\n wrapper.likeRight($expression($var),${ClassName}Entity::$getAttrName,$var);\n#end\n#end\n return R.ok(${className}Service.page(page, wrapper));\n }\n\n /**\n * 通过id查询${tableComment}\n * @param ${pk.attrName} id\n * @return R\n */\n @Operation(summary = \"通过id查询\" , description = \"通过id查询\" )\n @GetMapping(\"/{${pk.attrName}}\" )\n @PreAuthorize(\"@pms.hasPermission(\'${moduleName}_${functionName}_view\')\" )\n public R getById(@PathVariable(\"${pk.attrName}\" ) ${pk.attrType} ${pk.attrName}) {\n return R.ok(${className}Service.getByIdDeep(${pk.attrName}));\n }\n\n /**\n * 新增${tableComment}\n * @param ${className} ${tableComment}\n * @return R\n */\n @Operation(summary = \"新增${tableComment}\" , description = \"新增${tableComment}\" )\n @SysLog(\"新增${tableComment}\" )\n @PostMapping\n @PreAuthorize(\"@pms.hasPermission(\'${moduleName}_${functionName}_add\')\" )\n public R save(@RequestBody ${ClassName}Entity ${className}) {\n return R.ok(${className}Service.saveDeep(${className}));\n }\n\n /**\n * 修改${tableComment}\n * @param ${className} ${tableComment}\n * @return R\n */\n @Operation(summary = \"修改${tableComment}\" , description = \"修改${tableComment}\" )\n @SysLog(\"修改${tableComment}\" )\n @PutMapping\n @PreAuthorize(\"@pms.hasPermission(\'${moduleName}_${functionName}_edit\')\" )\n public R updateById(@RequestBody ${ClassName}Entity ${className}) {\n return R.ok(${className}Service.updateDeep(${className}));\n }\n\n /**\n * 通过id删除${tableComment}\n * @param ids ${pk.attrName}列表\n * @return R\n */\n @Operation(summary = \"通过id删除${tableComment}\" , description = \"通过id删除${tableComment}\" )\n @SysLog(\"通过id删除${tableComment}\" )\n @DeleteMapping\n @PreAuthorize(\"@pms.hasPermission(\'${moduleName}_${functionName}_del\')\" )\n public R removeById(@RequestBody ${pk.attrType}[] ids) {\n return R.ok(${className}Service.removeDeep(ids));\n }\n\n /**\n * 通过id删除${tableComment}子表数据\n * @param ids ${pk.attrName}列表\n * @return R\n */\n @Operation(summary = \"通过id删除${tableComment}子表数据\" , description = \"通过id删除${tableComment}子表数据\" )\n @SysLog(\"通过id删除${tableComment}子表数据\" )\n @DeleteMapping(\"/child\")\n @PreAuthorize(\"@pms.hasPermission(\'${moduleName}_${functionName}_del\')\" )\n public R removeChild(@RequestBody ${pk.attrType}[] ids) {\n return R.ok(${className}Service.removeChild(ids));\n }\n\n /**\n * 导出excel 表格\n * @param ${className} 查询条件\n * @param ids 导出指定ID\n * @return excel 文件流\n */\n @ResponseExcel\n @GetMapping(\"/export\")\n @PreAuthorize(\"@pms.hasPermission(\'${moduleName}_${functionName}_export\')\" )\n public List<${ClassName}Entity> export(${ClassName}Entity ${className},${pk.attrType}[] ids) {\n return ${className}Service.list(Wrappers.lambdaQuery(${className}).in(ArrayUtil.isNotEmpty(ids), ${ClassName}Entity::$str.getProperty($pk.attrName), ids));\n }\n}', '2023-06-01 11:25:28', '2023-10-29 12:17:52', '0', 1, '', 'admin'); +INSERT INTO `gen_template` (`id`, `template_name`, `generator_path`, `template_desc`, `template_code`, `create_time`, `update_time`, `del_flag`, `tenant_id`, `create_by`, `update_by`) VALUES (17, '主子表单', '${frontendPath}/src/views/${moduleName}/${functionName}/form.vue', '子表表单', '\n\n', '2023-06-01 15:42:46', '2023-12-07 13:22:29', '0', 1, '', 'admin'); +INSERT INTO `gen_template` (`id`, `template_name`, `generator_path`, `template_desc`, `template_code`, `create_time`, `update_time`, `del_flag`, `tenant_id`, `create_by`, `update_by`) VALUES (18, '主子表格', '${frontendPath}/src/views/${moduleName}/${functionName}/index.vue', '子表单表格', '\n\n', '2023-06-01 15:43:31', '2023-08-29 10:53:23', '0', 1, ' ', ' '); +INSERT INTO `gen_template` (`id`, `template_name`, `generator_path`, `template_desc`, `template_code`, `create_time`, `update_time`, `del_flag`, `tenant_id`, `create_by`, `update_by`) VALUES (19, '子Mapper', '${backendPath}/src/main/java/${packagePath}/${moduleName}/mapper/${ChildClassName}Mapper.java', '子Mapper', 'package ${package}.${moduleName}.mapper;\n\nimport com.pig4cloud.pigx.common.data.datascope.PigxBaseMapper;\n#if($ChildClassName)\nimport ${package}.${moduleName}.entity.${ChildClassName}Entity;\n#else\nimport ${package}.${moduleName}.entity.${ClassName}Entity;\n#end\nimport org.apache.ibatis.annotations.Mapper;\n\n@Mapper\n#if($ChildClassName)\npublic interface ${ChildClassName}Mapper extends PigxBaseMapper<${ChildClassName}Entity> {\n#else\npublic interface ${ClassName}Mapper extends PigxBaseMapper<${ClassName}Entity> {\n#end\n\n}', '2023-02-23 01:18:18', '2023-08-07 09:54:36', '0', 1, ' ', ' '); COMMIT; -- ---------------------------- diff --git a/pigx-visual/pigx-codegen/src/main/java/com/pig4cloud/pigx/codegen/service/impl/GeneratorServiceImpl.java b/pigx-visual/pigx-codegen/src/main/java/com/pig4cloud/pigx/codegen/service/impl/GeneratorServiceImpl.java index 5937e93ee..3859af688 100755 --- a/pigx-visual/pigx-codegen/src/main/java/com/pig4cloud/pigx/codegen/service/impl/GeneratorServiceImpl.java +++ b/pigx-visual/pigx-codegen/src/main/java/com/pig4cloud/pigx/codegen/service/impl/GeneratorServiceImpl.java @@ -55,284 +55,299 @@ import java.util.zip.ZipOutputStream; @RequiredArgsConstructor public class GeneratorServiceImpl implements GeneratorService { - private final GenTableColumnService columnService; + private final GenTableColumnService columnService; - private final GenFormConfService formConfService; + private final GenFormConfService formConfService; - private final GenFieldTypeService fieldTypeService; + private final GenFieldTypeService fieldTypeService; - private final GenTableService tableService; + private final GenTableService tableService; - private final GenGroupService genGroupService; + private final GenGroupService genGroupService; - private final GenTemplateService genTemplateService; + private final GenTemplateService genTemplateService; - /** - * 生成代码zip写出 - * @param tableId 表 - * @param zip 输出流 - */ - @Override - @SneakyThrows - public void downloadCode(Long tableId, ZipOutputStream zip) { - // 数据模型 - Map dataModel = getDataModel(tableId); + /** + * 生成代码zip写出 + * + * @param tableId 表 + * @param zip 输出流 + */ + @Override + @SneakyThrows + public void downloadCode(Long tableId, ZipOutputStream zip) { + // 数据模型 + Map dataModel = getDataModel(tableId); - Long style = (Long) dataModel.get("style"); + Long style = (Long) dataModel.get("style"); - GroupVo groupVo = genGroupService.getGroupVoById(style); - List templateList = groupVo.getTemplateList(); + GroupVo groupVo = genGroupService.getGroupVoById(style); + List templateList = groupVo.getTemplateList(); - Map generatorConfig = tableService.getGeneratorConfig(); - JSONObject project = (JSONObject) generatorConfig.get("project"); - String frontendPath = project.getStr("frontendPath"); - String backendPath = project.getStr("backendPath"); + Map generatorConfig = tableService.getGeneratorConfig(); + JSONObject project = (JSONObject) generatorConfig.get("project"); + String frontendPath = project.getStr("frontendPath"); + String backendPath = project.getStr("backendPath"); - for (GenTemplateEntity template : templateList) { - String templateCode = template.getTemplateCode(); - String generatorPath = template.getGeneratorPath(); + for (GenTemplateEntity template : templateList) { + String templateCode = template.getTemplateCode(); + String generatorPath = template.getGeneratorPath(); - dataModel.put("frontendPath", frontendPath); - dataModel.put("backendPath", backendPath); - String content = VelocityKit.renderStr(templateCode, dataModel); - String path = VelocityKit.renderStr(generatorPath, dataModel); + dataModel.put("frontendPath", frontendPath); + dataModel.put("backendPath", backendPath); + String content = VelocityKit.renderStr(templateCode, dataModel); + String path = VelocityKit.renderStr(generatorPath, dataModel); - // 添加到zip - zip.putNextEntry(new ZipEntry(path)); - IoUtil.writeUtf8(zip, false, content); - zip.flush(); - zip.closeEntry(); - } + // 添加到zip + zip.putNextEntry(new ZipEntry(path)); + IoUtil.writeUtf8(zip, false, content); + zip.flush(); + zip.closeEntry(); + } - } + } - /** - * 表达式优化的预览代码方法 - * @param tableId 表 - * @return [{模板名称:渲染结果}] - */ - @Override - @SneakyThrows - public List> preview(Long tableId) { - // 数据模型 - Map dataModel = getDataModel(tableId); + /** + * 表达式优化的预览代码方法 + * + * @param tableId 表 + * @return [{模板名称:渲染结果}] + */ + @Override + @SneakyThrows + public List> preview(Long tableId) { + // 数据模型 + Map dataModel = getDataModel(tableId); - Long style = (Long) dataModel.get("style"); + Long style = (Long) dataModel.get("style"); - // 获取模板列表,Lambda 表达式简化代码 - List templateList = genGroupService.getGroupVoById(style).getTemplateList(); + // 获取模板列表,Lambda 表达式简化代码 + List templateList = genGroupService.getGroupVoById(style).getTemplateList(); - Map generatorConfig = tableService.getGeneratorConfig(); - JSONObject project = (JSONObject) generatorConfig.get("project"); - String frontendPath = project.getStr("frontendPath"); - String backendPath = project.getStr("backendPath"); + Map generatorConfig = tableService.getGeneratorConfig(); + JSONObject project = (JSONObject) generatorConfig.get("project"); + String frontendPath = project.getStr("frontendPath"); + String backendPath = project.getStr("backendPath"); - return templateList.stream().map(template -> { - String templateCode = template.getTemplateCode(); - String generatorPath = template.getGeneratorPath(); + return templateList.stream().map(template -> { + String templateCode = template.getTemplateCode(); + String generatorPath = template.getGeneratorPath(); - // 预览模式下, 使用相对路径展示 - dataModel.put("frontendPath", frontendPath); - dataModel.put("backendPath", backendPath); - String content = VelocityKit.renderStr(templateCode, dataModel); - String path = VelocityKit.renderStr(generatorPath, dataModel); + // 预览模式下, 使用相对路径展示 + dataModel.put("frontendPath", frontendPath); + dataModel.put("backendPath", backendPath); + String content = VelocityKit.renderStr(templateCode, dataModel); + String path = VelocityKit.renderStr(generatorPath, dataModel); - // 使用 map 简化代码 - return new HashMap(4) { - { - put("code", content); - put("codePath", path); - } - }; - }).collect(Collectors.toList()); - } + // 使用 map 简化代码 + return new HashMap(4) { + { + put("code", content); + put("codePath", path); + } + }; + }).collect(Collectors.toList()); + } - /** - * 目标目录写入渲染结果方法 - * @param tableId 表 - */ - @Override - public void generatorCode(Long tableId) { - // 数据模型 - Map dataModel = getDataModel(tableId); - Long style = (Long) dataModel.get("style"); + /** + * 目标目录写入渲染结果方法 + * + * @param tableId 表 + */ + @Override + public void generatorCode(Long tableId) { + // 数据模型 + Map dataModel = getDataModel(tableId); + Long style = (Long) dataModel.get("style"); - // 获取模板列表,Lambda 表达式简化代码 - List templateList = genGroupService.getGroupVoById(style).getTemplateList(); + // 获取模板列表,Lambda 表达式简化代码 + List templateList = genGroupService.getGroupVoById(style).getTemplateList(); - templateList.forEach(template -> { - String templateCode = template.getTemplateCode(); - String generatorPath = template.getGeneratorPath(); - String content = VelocityKit.renderStr(templateCode, dataModel); - String path = VelocityKit.renderStr(generatorPath, dataModel); - FileUtil.writeUtf8String(content, path); - }); - } + templateList.forEach(template -> { + String templateCode = template.getTemplateCode(); + String generatorPath = template.getGeneratorPath(); + String content = VelocityKit.renderStr(templateCode, dataModel); + String path = VelocityKit.renderStr(generatorPath, dataModel); + FileUtil.writeUtf8String(content, path); + }); + } - /** - * 获取表单设计器需要的 JSON 方法 - * @param dsName 数据源名称 - * @param tableName 表名称 - * @return JSON 字符串 - */ - @SneakyThrows - @Override - public String vform(String dsName, String tableName) { - // 查询表的元数据 - GenTable genTable = tableService.queryOrBuildTable(dsName, tableName); + /** + * 获取表单设计器需要的 JSON 方法 + * + * @param dsName 数据源名称 + * @param tableName 表名称 + * @return JSON 字符串 + */ + @SneakyThrows + @Override + public String vform(String dsName, String tableName) { + // 查询表的元数据 + GenTable genTable = tableService.queryOrBuildTable(dsName, tableName); - // 获取数据模型 - Map dataModel = getDataModel(genTable.getId()); + // 获取数据模型 + Map dataModel = getDataModel(genTable.getId()); - // 获取模板信息,Lambda 表达式简化代码 - GenTemplateEntity genTemplateEntity = Optional - .ofNullable(genTemplateService.getById(GeneratorStyleEnum.VFORM_JSON.getTemplateId())) - .orElseThrow(() -> new Exception("模板不存在")); + // 获取模板信息,Lambda 表达式简化代码 + GenTemplateEntity genTemplateEntity = Optional + .ofNullable(genTemplateService.getById(GeneratorStyleEnum.VFORM_JSON.getTemplateId())) + .orElseThrow(() -> new Exception("模板不存在")); - // 渲染模板并返回结果 - return VelocityKit.renderStr(genTemplateEntity.getTemplateCode(), dataModel); - } + // 渲染模板并返回结果 + return VelocityKit.renderStr(genTemplateEntity.getTemplateCode(), dataModel); + } - /** - * 获取表单设计器需要的 JSON 方法 - * @param id 表单配置 ID - * @return JSON 字符串 - */ - @SneakyThrows - @Override - public String vformSfc(Long id) { - // 获取表单配置信息 - GenFormConf formConf = formConfService.getById(id); + /** + * 获取表单设计器需要的 JSON 方法 + * + * @param id 表单配置 ID + * @return JSON 字符串 + */ + @SneakyThrows + @Override + public String vformSfc(Long id) { + // 获取表单配置信息 + GenFormConf formConf = formConfService.getById(id); - // 查询表的元数据 - GenTable genTable = tableService.queryOrBuildTable(formConf.getDsName(), formConf.getTableName()); + // 查询表的元数据 + GenTable genTable = tableService.queryOrBuildTable(formConf.getDsName(), formConf.getTableName()); - // 获取数据模型 - Map dataModel = getDataModel(genTable.getId()); + // 获取数据模型 + Map dataModel = getDataModel(genTable.getId()); - // 解析组件列表 - Map> resultMap = formConfService.parse(formConf.getFormInfo()); + // 解析组件列表 + Map> resultMap = formConfService.parse(formConf.getFormInfo()); - // 遍历 widgetList - dataModel.put("resultMap", resultMap); + // 遍历 widgetList + dataModel.put("resultMap", resultMap); - // 获取模板信息 - GenTemplateEntity genTemplateEntity = Optional - .ofNullable(genTemplateService.getById(GeneratorStyleEnum.VFORM_FORM.getTemplateId())) - .orElseThrow(() -> new Exception("模板不存在")); + // 获取模板信息 + GenTemplateEntity genTemplateEntity = Optional + .ofNullable(genTemplateService.getById(GeneratorStyleEnum.VFORM_FORM.getTemplateId())) + .orElseThrow(() -> new Exception("模板不存在")); - // 渲染模板并返回结果 - return VelocityKit.renderStr(genTemplateEntity.getTemplateCode(), dataModel); - } + // 渲染模板并返回结果 + return VelocityKit.renderStr(genTemplateEntity.getTemplateCode(), dataModel); + } - /** - * 通过 Lambda 表达式优化的获取数据模型方法 - * @param tableId 表格 ID - * @return 数据模型 Map 对象 - */ - private Map getDataModel(Long tableId) { - // 获取表格信息 - GenTable table = tableService.getById(tableId); - // 获取字段列表 - List fieldList = columnService.lambdaQuery() - .eq(GenTableColumnEntity::getDsName, table.getDsName()) - .eq(GenTableColumnEntity::getTableName, table.getTableName()) - .orderByAsc(GenTableColumnEntity::getSort) - .list(); + /** + * 通过 Lambda 表达式优化的获取数据模型方法 + * + * @param tableId 表格 ID + * @return 数据模型 Map 对象 + */ + private Map getDataModel(Long tableId) { + // 获取表格信息 + GenTable table = tableService.getById(tableId); + // 获取字段列表 + List fieldList = columnService.lambdaQuery() + .eq(GenTableColumnEntity::getDsName, table.getDsName()) + .eq(GenTableColumnEntity::getTableName, table.getTableName()) + .orderByAsc(GenTableColumnEntity::getSort) + .list(); - table.setFieldList(fieldList); + table.setFieldList(fieldList); - // 创建数据模型对象 - Map dataModel = new HashMap<>(); + // 创建数据模型对象 + Map dataModel = new HashMap<>(); - // 填充数据模型 - dataModel.put("isSpringBoot3", isSpringBoot3()); - dataModel.put("dbType", table.getDbType()); - dataModel.put("package", table.getPackageName()); - dataModel.put("packagePath", table.getPackageName().replace(".", "/")); - dataModel.put("version", table.getVersion()); - dataModel.put("moduleName", table.getModuleName()); - dataModel.put("ModuleName", StrUtil.upperFirst(table.getModuleName())); - dataModel.put("functionName", table.getFunctionName()); - dataModel.put("FunctionName", StrUtil.upperFirst(table.getFunctionName())); - dataModel.put("formLayout", table.getFormLayout()); - dataModel.put("style", table.getStyle()); - dataModel.put("author", table.getAuthor()); - dataModel.put("datetime", DateUtil.now()); - dataModel.put("date", DateUtil.today()); - setFieldTypeList(dataModel, table); + // 填充数据模型 + dataModel.put("isSpringBoot3", isSpringBoot3()); + dataModel.put("dbType", table.getDbType()); + dataModel.put("package", table.getPackageName()); + dataModel.put("packagePath", table.getPackageName().replace(".", "/")); + dataModel.put("version", table.getVersion()); + dataModel.put("moduleName", table.getModuleName()); + dataModel.put("ModuleName", StrUtil.upperFirst(table.getModuleName())); + dataModel.put("functionName", table.getFunctionName()); + dataModel.put("FunctionName", StrUtil.upperFirst(table.getFunctionName())); + dataModel.put("formLayout", table.getFormLayout()); + dataModel.put("style", table.getStyle()); + dataModel.put("author", table.getAuthor()); + dataModel.put("datetime", DateUtil.now()); + dataModel.put("date", DateUtil.today()); + setFieldTypeList(dataModel, table); - // 获取导入的包列表 - Set importList = fieldTypeService.getPackageByTableId(table.getDsName(), table.getTableName()); - dataModel.put("importList", importList); - dataModel.put("tableName", table.getTableName()); - dataModel.put("tableComment", table.getTableComment()); - dataModel.put("className", StrUtil.lowerFirst(table.getClassName())); - dataModel.put("ClassName", table.getClassName()); - dataModel.put("fieldList", table.getFieldList()); + // 获取导入的包列表 + Set importList = fieldTypeService.getPackageByTableId(table.getDsName(), table.getTableName()); + dataModel.put("importList", importList); + dataModel.put("tableName", table.getTableName()); + dataModel.put("tableComment", table.getTableComment()); + dataModel.put("className", StrUtil.lowerFirst(table.getClassName())); + dataModel.put("ClassName", table.getClassName()); + dataModel.put("fieldList", table.getFieldList()); - dataModel.put("backendPath", table.getBackendPath()); - dataModel.put("frontendPath", table.getFrontendPath()); + dataModel.put("backendPath", table.getBackendPath()); + dataModel.put("frontendPath", table.getFrontendPath()); - // 设置子表 - String childTableName = table.getChildTableName(); - if (StrUtil.isNotBlank(childTableName)) { - List childFieldList = columnService.lambdaQuery() - .eq(GenTableColumnEntity::getDsName, table.getDsName()) - .eq(GenTableColumnEntity::getTableName, table.getChildTableName()) - .list(); - dataModel.put("childFieldList", childFieldList); - dataModel.put("childTableName", childTableName); - dataModel.put("mainField", NamingCase.toCamelCase(table.getMainField())); - dataModel.put("childField", NamingCase.toCamelCase(table.getChildField())); - dataModel.put("ChildClassName", NamingCase.toPascalCase(childTableName)); - dataModel.put("childClassName", StrUtil.lowerFirst(NamingCase.toPascalCase(childTableName))); - } + // 设置子表 + String childTableName = table.getChildTableName(); + if (StrUtil.isNotBlank(childTableName)) { + List childFieldList = columnService.lambdaQuery() + .eq(GenTableColumnEntity::getDsName, table.getDsName()) + .eq(GenTableColumnEntity::getTableName, table.getChildTableName()) + .list(); + dataModel.put("childFieldList", childFieldList); + dataModel.put("childTableName", childTableName); + dataModel.put("mainField", NamingCase.toCamelCase(table.getMainField())); + dataModel.put("childField", NamingCase.toCamelCase(table.getChildField())); + dataModel.put("ChildClassName", NamingCase.toPascalCase(childTableName)); + dataModel.put("childClassName", StrUtil.lowerFirst(NamingCase.toPascalCase(childTableName))); + // 设置是否是多租户模式 (判断字段列表中是否包含 tenant_id 字段) + childFieldList.stream().filter(genTableColumnEntity -> genTableColumnEntity.getFieldName().equals("tenant_id")) + .findFirst().ifPresent(columnEntity -> dataModel.put("isChildTenant", true)); + } - return dataModel; - } + // 设置是否是多租户模式 (判断字段列表中是否包含 tenant_id 字段) + table.getFieldList().stream().filter(genTableColumnEntity -> genTableColumnEntity.getFieldName().equals("tenant_id")) + .findFirst().ifPresent(columnEntity -> dataModel.put("isTenant", true)); - /** - * 判断当前是否是 SpringBoot3 版本 - * @return true/fasle - */ - private boolean isSpringBoot3() { - return StrUtil.startWith(SpringBootVersion.getVersion(), "3"); - } + return dataModel; + } - /** - * 将表字段按照类型分组并存储到数据模型中 - * @param dataModel 存储数据的 Map 对象 - * @param table 表信息对象 - */ - private void setFieldTypeList(Map dataModel, GenTable table) { - // 按字段类型分组,使用 Map 存储不同类型的字段列表 - Map> typeMap = table.getFieldList() - .stream() - .collect(Collectors.partitioningBy(columnEntity -> BooleanUtil.toBoolean(columnEntity.getPrimaryPk()))); + /** + * 判断当前是否是 SpringBoot3 版本 + * + * @return true/fasle + */ + private boolean isSpringBoot3() { + return StrUtil.startWith(SpringBootVersion.getVersion(), "3"); + } - // 从分组后的 Map 中获取不同类型的字段列表 - List primaryList = typeMap.get(true); - List formList = typeMap.get(false) - .stream() - .filter(columnEntity -> BooleanUtil.toBoolean(columnEntity.getFormItem())) - .collect(Collectors.toList()); - List gridList = typeMap.get(false) - .stream() - .filter(columnEntity -> BooleanUtil.toBoolean(columnEntity.getGridItem())) - .collect(Collectors.toList()); - List queryList = typeMap.get(false) - .stream() - .filter(columnEntity -> BooleanUtil.toBoolean(columnEntity.getQueryItem())) - .collect(Collectors.toList()); + /** + * 将表字段按照类型分组并存储到数据模型中 + * + * @param dataModel 存储数据的 Map 对象 + * @param table 表信息对象 + */ + private void setFieldTypeList(Map dataModel, GenTable table) { + // 按字段类型分组,使用 Map 存储不同类型的字段列表 + Map> typeMap = table.getFieldList() + .stream() + .collect(Collectors.partitioningBy(columnEntity -> BooleanUtil.toBoolean(columnEntity.getPrimaryPk()))); - if (CollUtil.isNotEmpty(primaryList)) { - dataModel.put("pk", primaryList.get(0)); - } - dataModel.put("primaryList", primaryList); - dataModel.put("formList", formList); - dataModel.put("gridList", gridList); - dataModel.put("queryList", queryList); - } + // 从分组后的 Map 中获取不同类型的字段列表 + List primaryList = typeMap.get(true); + List formList = typeMap.get(false) + .stream() + .filter(columnEntity -> BooleanUtil.toBoolean(columnEntity.getFormItem())) + .collect(Collectors.toList()); + List gridList = typeMap.get(false) + .stream() + .filter(columnEntity -> BooleanUtil.toBoolean(columnEntity.getGridItem())) + .collect(Collectors.toList()); + List queryList = typeMap.get(false) + .stream() + .filter(columnEntity -> BooleanUtil.toBoolean(columnEntity.getQueryItem())) + .collect(Collectors.toList()); + + if (CollUtil.isNotEmpty(primaryList)) { + dataModel.put("pk", primaryList.get(0)); + } + dataModel.put("primaryList", primaryList); + dataModel.put("formList", formList); + dataModel.put("gridList", gridList); + dataModel.put("queryList", queryList); + } }