From cedb011abaf823e3b1896d0895c541d2d10479fc Mon Sep 17 00:00:00 2001 From: lbw Date: Mon, 28 Aug 2023 22:58:22 +0800 Subject: [PATCH] =?UTF-8?q?:recycle:=20Refactoring=20code.=20=E9=87=8D?= =?UTF-8?q?=E6=9E=84=E4=BB=A3=E7=A0=81=E7=94=9F=E6=88=90=E6=A8=A1=E5=9D=97?= =?UTF-8?q?=E9=80=82=E9=85=8D=E5=85=B6=E4=BB=96=E7=B1=BB=E5=9E=8B=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E5=BA=93?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- db/pig.sql | 4 +- db/pig_codegen.sql | 51 +++++++++---------- .../pig/codegen/entity/GenTable.java | 2 +- .../codegen/entity/GenTableColumnEntity.java | 14 ++--- .../service/impl/GenTableServiceImpl.java | 14 +++-- .../service/impl/GeneratorServiceImpl.java | 12 ++--- .../pig/codegen/util/BoolFillEnum.java | 26 ++++++++++ .../codegen/util/CommonColumnFiledEnum.java | 16 +++--- .../codegen/util/GeneratorFileTypeEnum.java | 14 ----- .../pig/codegen/util/GeneratorTypeEnum.java | 21 ++++++++ 10 files changed, 105 insertions(+), 69 deletions(-) create mode 100644 pig-visual/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/util/BoolFillEnum.java delete mode 100644 pig-visual/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/util/GeneratorFileTypeEnum.java create mode 100644 pig-visual/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/util/GeneratorTypeEnum.java diff --git a/db/pig.sql b/db/pig.sql index 8b67ed47..42d7058f 100644 --- a/db/pig.sql +++ b/db/pig.sql @@ -623,7 +623,7 @@ CREATE TABLE `sys_user` ( `mini_openid` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '小程序openId', `qq_openid` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT 'QQ openId', `gitee_login` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '码云标识', - `osc_id` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '开源中国标识' + `osc_id` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '开源中国标识', PRIMARY KEY (`user_id`) USING BTREE, KEY `user_wx_openid` (`wx_openid`) USING BTREE, KEY `user_qq_openid` (`qq_openid`) USING BTREE, @@ -634,7 +634,7 @@ CREATE TABLE `sys_user` ( -- Records of sys_user -- ---------------------------- BEGIN; -INSERT INTO `sys_user` VALUES (1, 'admin', '$2a$10$c/Ae0pRjJtMZg3BnvVpO.eIK6WYWVbKTzqgdy3afR7w.vd.xi3Mgy', '', '17034642999', '/admin/sys-file/s3demo/7ff4ca6b7bf446f3a5a13ac016dc21af.png', '管理员', '管理员', 'pig4cloud@qq.com', 4, ' ', 'admin', '2018-04-20 07:15:18', '2023-07-07 14:55:40', '0', '0', NULL, 'oBxPy5E-v82xWGsfzZVzkD3wEX64', NULL, 'log4j', NULL, 1); +INSERT INTO `sys_user` VALUES (1, 'admin', '$2a$10$c/Ae0pRjJtMZg3BnvVpO.eIK6WYWVbKTzqgdy3afR7w.vd.xi3Mgy', '', '17034642999', '/admin/sys-file/s3demo/7ff4ca6b7bf446f3a5a13ac016dc21af.png', '管理员', '管理员', 'pig4cloud@qq.com', 4, ' ', 'admin', '2018-04-20 07:15:18', '2023-07-07 14:55:40', '0', '0', NULL, 'oBxPy5E-v82xWGsfzZVzkD3wEX64', NULL, 'log4j', NULL); COMMIT; -- ---------------------------- diff --git a/db/pig_codegen.sql b/db/pig_codegen.sql index a7d4b1ed..1daff687 100644 --- a/db/pig_codegen.sql +++ b/db/pig_codegen.sql @@ -2,8 +2,6 @@ DROP DATABASE IF EXISTS `pig_codegen`; CREATE DATABASE `pig_codegen` DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_bin; -SET NAMES utf8mb4; -SET FOREIGN_KEY_CHECKS = 0; USE pig_codegen; -- ---------------------------- @@ -19,7 +17,6 @@ CREATE TABLE `gen_datasource_conf` ( `create_time` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', `update_time` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新', `del_flag` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT '0' COMMENT '删除标记', - `tenant_id` bigint DEFAULT NULL COMMENT '租户ID', `ds_type` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '数据库类型', `conf_type` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '配置类型', `ds_name` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '数据库名称', @@ -99,7 +96,6 @@ CREATE TABLE `gen_group` ( `id` bigint NOT NULL, `group_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '分组名称', `group_desc` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '分组描述', - `tenant_id` bigint NOT NULL COMMENT '租户ID', `create_by` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT ' ' COMMENT '创建人', `update_by` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT ' ' COMMENT '修改人', `create_time` datetime DEFAULT NULL COMMENT '创建人', @@ -112,7 +108,7 @@ CREATE TABLE `gen_group` ( -- Records of gen_group -- ---------------------------- BEGIN; -INSERT INTO `gen_group` VALUES (1, '单表增删改查', '单表增删改查', 1, ' ', 'admin', NULL, '2023-07-07 15:47:51', '0'); +INSERT INTO `gen_group` VALUES (1, '增删改查', '单表增删改查', ' ', ' ', NULL, NULL, '0'); COMMIT; -- ---------------------------- @@ -129,12 +125,12 @@ CREATE TABLE `gen_table` ( `email` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '邮箱', `package_name` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '项目包名', `version` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '项目版本号', - `i18n` tinyint DEFAULT '1' COMMENT '是否生成带有i18n 0 不带有 1带有', - `style` bigint DEFAULT '0' COMMENT '代码风格', + `i18n` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT '0' COMMENT '是否生成带有i18n 0 不带有 1带有', + `style` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT '0' COMMENT '代码风格', `child_table_name` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '子表名称', `main_field` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '主表关联键', `child_field` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '子表关联键', - `generator_type` tinyint DEFAULT NULL COMMENT '生成方式 0:zip压缩包 1:自定义目录', + `generator_type` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT '0' COMMENT '生成方式 0:zip压缩包 1:自定义目录', `backend_path` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '后端生成路径', `frontend_path` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '前端生成路径', `module_name` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '模块名', @@ -169,15 +165,15 @@ CREATE TABLE `gen_table_column` ( `package_name` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '属性包名', `sort` int DEFAULT NULL COMMENT '排序', `auto_fill` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '自动填充 DEFAULT、INSERT、UPDATE、INSERT_UPDATE', - `primary_pk` tinyint DEFAULT NULL COMMENT '主键 0:否 1:是', - `base_field` tinyint DEFAULT NULL COMMENT '基类字段 0:否 1:是', - `form_item` tinyint DEFAULT NULL COMMENT '表单项 0:否 1:是', - `form_required` tinyint DEFAULT NULL COMMENT '表单必填 0:否 1:是', + `primary_pk` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT '0' COMMENT '主键 0:否 1:是', + `base_field` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT '0' COMMENT '基类字段 0:否 1:是', + `form_item` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT '0' COMMENT '表单项 0:否 1:是', + `form_required` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT '0' COMMENT '表单必填 0:否 1:是', `form_type` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '表单类型', `form_validator` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '表单效验', - `grid_item` tinyint DEFAULT NULL COMMENT '列表项 0:否 1:是', - `grid_sort` tinyint DEFAULT NULL COMMENT '列表排序 0:否 1:是', - `query_item` tinyint DEFAULT NULL COMMENT '查询项 0:否 1:是', + `grid_item` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT '0' COMMENT '列表项 0:否 1:是', + `grid_sort` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT '0' COMMENT '列表排序 0:否 1:是', + `query_item` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT '0' COMMENT '查询项 0:否 1:是', `query_type` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '查询方式', `query_form_type` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '查询表单类型', `field_dict` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '字典类型', @@ -203,7 +199,6 @@ CREATE TABLE `gen_template` ( `create_time` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', `update_time` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新', `del_flag` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '0' COMMENT '删除标记', - `tenant_id` bigint NOT NULL COMMENT '租户ID', `create_by` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT ' ' COMMENT '创建人', `update_by` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT ' ' COMMENT '修改人', PRIMARY KEY (`id`) @@ -213,16 +208,18 @@ CREATE TABLE `gen_template` ( -- Records of gen_template -- ---------------------------- BEGIN; -INSERT INTO `gen_template` VALUES (1, '表格', '${frontendPath}/src/views/${moduleName}/${functionName}/index.vue', '表格不含i18n', '\n\n', '2023-02-23 01:19:35', '2023-07-21 22:12:38', '0', 1, '', 'admin'); -INSERT INTO `gen_template` VALUES (2, '表单', '${frontendPath}/src/views/${moduleName}/${functionName}/form.vue', '表单不含i18n', '\n\n', '2023-02-23 01:19:48', '2023-07-21 22:12:41', '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.pig.common.core.util.R;\nimport com.pig4cloud.pig.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.pig.common.excel.annotation.ResponseExcel;\nimport io.swagger.v3.oas.annotations.security.SecurityRequirement;\nimport org.springdoc.core.annotations.ParameterObject;\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-08-22 20:54:58', '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#foreach ($field in $childFieldList)\n#if($field.primaryPk)\n#set($getChildPkName=$str.getProperty($field.attrName))\n#end\n#end\n if (Objects.isNull(${childClassName}.$getChildPkName())) {\n ${childClassName}.$str.setProperty($childField)(${className}.getId());\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-06-04 10:35:21', '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)\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 private $field.attrType $field.attrName;\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-06-04 10:45:15', '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.baomidou.mybatisplus.core.mapper.BaseMapper;\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 BaseMapper<${ChildClassName}Entity> {\n#else\npublic interface ${ClassName}Mapper extends BaseMapper<${ClassName}Entity> {\n#end\n\n}', '2023-02-23 01:18:18', '2023-07-21 22:01:14', '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)\n \n #end\n #if(!$field.primaryPk)\n \n #end\n#end\n \n', '2023-02-23 01:18:35', '2023-06-04 10:34:56', '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\n insert into `sys_menu` ( `menu_id`,`parent_id`, `path`, `permission`, `menu_type`, `icon`, `del_flag`, `create_time`, `sort_order`, `update_time`, `name`)\n values (${menuId}, \'-1\', \'/${moduleName}/${functionName}/index\', \'\', \'0\', \'icon-bangzhushouji\', \'0\', null , \'8\', null , \'${tableComment}管理\');\n\n-- 按钮父菜单ID\n set @parentId = @@identity;\n\n-- 菜单对应按钮SQL\n insert into `sys_menu` ( `menu_id`,`parent_id`, `permission`, `menu_type`, `path`, `icon`, `del_flag`, `create_time`, `sort_order`, `update_time`, `name`)\n values (${math.add($menuId,1)},${menuId}, \'${moduleName}_${functionName}_view\', \'1\', null, \'1\', \'0\', null, \'0\', null, \'${tableComment}查看\');\n\n insert into `sys_menu` ( `menu_id`,`parent_id`, `permission`, `menu_type`, `path`, `icon`, `del_flag`, `create_time`, `sort_order`, `update_time`, `name`)\n values (${math.add($menuId,2)},${menuId}, \'${moduleName}_${functionName}_add\', \'1\', null, \'1\', \'0\', null, \'1\', null, \'${tableComment}新增\');\n\n insert into `sys_menu` (`menu_id`, `parent_id`, `permission`, `menu_type`, `path`, `icon`, `del_flag`, `create_time`, `sort_order`, `update_time`, `name`)\n values (${math.add($menuId,3)},${menuId}, \'${moduleName}_${functionName}_edit\', \'1\', null, \'1\', \'0\', null, \'2\', null, \'${tableComment}修改\');\n\n insert into `sys_menu` (`menu_id`, `parent_id`, `permission`, `menu_type`, `path`, `icon`, `del_flag`, `create_time`, `sort_order`, `update_time`, `name`)\n values (${math.add($menuId,4)},${menuId}, \'${moduleName}_${functionName}_del\', \'1\', null, \'1\', \'0\', null, \'3\', null, \'${tableComment}删除\');\n\n insert into `sys_menu` ( `menu_id`,`parent_id`, `permission`, `menu_type`, `path`, `icon`, `del_flag`, `create_time`, `sort_order`, `update_time`, `name`)\n values (${math.add($menuId,5)},${menuId}, \'${moduleName}_${functionName}_export\', \'1\', null, \'1\', \'0\', null, \'3\', null, \'导入导出\');', '2023-02-23 01:19:08', '2023-07-21 22:08:16', '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 (1, '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.pig.common.core.util.R;\nimport com.pig4cloud.pig.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.plugin.excel.annotation.ResponseExcel;\nimport io.swagger.v3.oas.annotations.security.SecurityRequirement;\nimport org.springdoc.core.annotations.ParameterObject;\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-08-28 22:48:06', '0', '', 'admin'); +INSERT INTO `gen_template` VALUES (2, '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', ' ', ' '); +INSERT INTO `gen_template` VALUES (3, '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}.getId());\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', ' ', ' '); +INSERT INTO `gen_template` VALUES (4, '实体', '${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 private $field.attrType $field.attrName;\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-08-27 22:26:06', '0', ' ', ' '); +INSERT INTO `gen_template` VALUES (5, 'Mapper', '${backendPath}/src/main/java/${packagePath}/${moduleName}/mapper/${ClassName}Mapper.java', 'Mapper', 'package ${package}.${moduleName}.mapper;\n\nimport com.baomidou.mybatisplus.core.mapper.BaseMapper;\nimport ${package}.${moduleName}.entity.${ClassName}Entity;\nimport org.apache.ibatis.annotations.Mapper;\n\n@Mapper\npublic interface ${ClassName}Mapper extends BaseMapper<${ClassName}Entity> {\n\n\n}', '2023-02-23 01:18:18', '2023-08-28 22:47:02', '0', ' ', 'admin'); +INSERT INTO `gen_template` VALUES (6, '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)\n \n #end\n #if(!$field.primaryPk)\n \n #end\n#end\n \n', '2023-02-23 01:18:35', '2023-06-04 10:34:56', '0', ' ', ' '); +INSERT INTO `gen_template` VALUES (7, '权限菜单', '${backendPath}/menu/${functionName}_menu.sql', 'menu.sql', '-- 该脚本不要直接执行, 注意维护菜单的父节点ID 默认 父节点-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)\nvalues (${menuId}, \'-1\', \'/${moduleName}/${functionName}/index\', \'\', \'0\', \'icon-bangzhushouji\', \'0\', null , \'8\', null , \'${tableComment}管理\');\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)\nvalues (${math.add($menuId,1)},${menuId}, \'${moduleName}_${functionName}_view\', \'1\', null, \'1\', \'0\', null, \'0\', null, \'${tableComment}查看\');\n\ninsert into sys_menu ( menu_id,parent_id, permission, menu_type, path, icon, del_flag, create_time, sort_order, update_time, name)\nvalues (${math.add($menuId,2)},${menuId}, \'${moduleName}_${functionName}_add\', \'1\', null, \'1\', \'0\', null, \'1\', null, \'${tableComment}新增\');\n\ninsert into sys_menu (menu_id, parent_id, permission, menu_type, path, icon, del_flag, create_time, sort_order, update_time, name)\nvalues (${math.add($menuId,3)},${menuId}, \'${moduleName}_${functionName}_edit\', \'1\', null, \'1\', \'0\', null, \'2\', null, \'${tableComment}修改\');\n\ninsert into sys_menu (menu_id, parent_id, permission, menu_type, path, icon, del_flag, create_time, sort_order, update_time, name)\nvalues (${math.add($menuId,4)},${menuId}, \'${moduleName}_${functionName}_del\', \'1\', null, \'1\', \'0\', null, \'3\', null, \'${tableComment}删除\');\n\ninsert into sys_menu ( menu_id,parent_id, permission, menu_type, path, icon, del_flag, create_time, sort_order, update_time, name)\nvalues (${math.add($menuId,5)},${menuId}, \'${moduleName}_${functionName}_export\', \'1\', null, \'1\', \'0\', null, \'3\', null, \'导入导出\');', '2023-02-23 01:19:08', '2023-08-28 22:06:16', '0', ' ', ' '); +INSERT INTO `gen_template` VALUES (8, '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', ' ', ' '); +INSERT INTO `gen_template` VALUES (9, '表格', '${frontendPath}/src/views/${moduleName}/${functionName}/index.vue', '表格不含i18n', '\n\n', '2023-02-23 01:19:35', '2023-08-28 22:53:55', '0', '', 'admin'); +INSERT INTO `gen_template` VALUES (10, '表单', '${frontendPath}/src/views/${moduleName}/${functionName}/form.vue', '表单不含i18n', '\n\n', '2023-02-23 01:19:48', '2023-08-27 22:23:19', '0', '', 'admin'); +INSERT INTO `gen_template` VALUES (11, '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', '', 'admin'); +INSERT INTO `gen_template` VALUES (12, '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', '', 'admin'); COMMIT; -- ---------------------------- @@ -249,6 +246,8 @@ INSERT INTO `gen_template_group` VALUES (1, 7); INSERT INTO `gen_template_group` VALUES (1, 8); INSERT INTO `gen_template_group` VALUES (1, 9); INSERT INTO `gen_template_group` VALUES (1, 10); +INSERT INTO `gen_template_group` VALUES (1, 11); +INSERT INTO `gen_template_group` VALUES (1, 12); COMMIT; SET FOREIGN_KEY_CHECKS = 1; diff --git a/pig-visual/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/entity/GenTable.java b/pig-visual/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/entity/GenTable.java index 0ef736ae..ca25c3b9 100644 --- a/pig-visual/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/entity/GenTable.java +++ b/pig-visual/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/entity/GenTable.java @@ -108,7 +108,7 @@ public class GenTable extends Model { * 生成方式 0:zip压缩包 1:自定义目录 */ @Schema(description = "生成方式 0:zip压缩包 1:自定义目录") - private Integer generatorType; + private String generatorType; /** * 后端生成路径 diff --git a/pig-visual/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/entity/GenTableColumnEntity.java b/pig-visual/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/entity/GenTableColumnEntity.java index a54612b7..65ee2a9f 100755 --- a/pig-visual/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/entity/GenTableColumnEntity.java +++ b/pig-visual/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/entity/GenTableColumnEntity.java @@ -94,22 +94,22 @@ public class GenTableColumnEntity extends Model { /** * 主键 0:否 1:是 */ - private boolean primaryPk; + private String primaryPk; /** * 基类字段 0:否 1:是 */ - private boolean baseField; + private String baseField; /** * 表单项 0:否 1:是 */ - private boolean formItem; + private String formItem; /** * 表单必填 0:否 1:是 */ - private boolean formRequired; + private String formRequired; /** * 表单类型 @@ -124,17 +124,17 @@ public class GenTableColumnEntity extends Model { /** * 列表项 0:否 1:是 */ - private boolean gridItem; + private String gridItem; /** * 列表排序 0:否 1:是 */ - private boolean gridSort; + private String gridSort; /** * 查询项 0:否 1:是 */ - private boolean queryItem; + private String queryItem; /** * 查询方式 diff --git a/pig-visual/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/service/impl/GenTableServiceImpl.java b/pig-visual/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/service/impl/GenTableServiceImpl.java index 59b72c5a..b7d9b731 100644 --- a/pig-visual/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/service/impl/GenTableServiceImpl.java +++ b/pig-visual/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/service/impl/GenTableServiceImpl.java @@ -37,9 +37,10 @@ import com.pig4cloud.pig.codegen.mapper.GeneratorMapper; import com.pig4cloud.pig.codegen.service.GenGroupService; import com.pig4cloud.pig.codegen.service.GenTableColumnService; import com.pig4cloud.pig.codegen.service.GenTableService; +import com.pig4cloud.pig.codegen.util.BoolFillEnum; import com.pig4cloud.pig.codegen.util.CommonColumnFiledEnum; import com.pig4cloud.pig.codegen.util.GenKit; -import com.pig4cloud.pig.codegen.util.GeneratorFileTypeEnum; +import com.pig4cloud.pig.codegen.util.GeneratorTypeEnum; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -157,7 +158,7 @@ public class GenTableServiceImpl extends ServiceImpl i table.setTableComment(MapUtil.getStr(queryTable, "tableComment")); table.setDbType(MapUtil.getStr(queryTable, "dbType")); table.setFormLayout(2); - table.setGeneratorType(GeneratorFileTypeEnum.ZIP.ordinal()); + table.setGeneratorType(GeneratorTypeEnum.ZIP_DOWNLOAD.getValue()); table.setClassName(NamingCase.toPascalCase(tableName)); table.setModuleName(GenKit.getModuleName(table.getPackageName())); table.setFunctionName(GenKit.getFunctionName(tableName)); @@ -177,10 +178,13 @@ public class GenTableServiceImpl extends ServiceImpl i genTableColumnEntity.setFieldComment(MapUtil.getStr(columnMap, "comments")); genTableColumnEntity.setFieldType(MapUtil.getStr(columnMap, "dataType")); String columnKey = MapUtil.getStr(columnMap, "columnKey"); - genTableColumnEntity.setPrimaryPk(StringUtils.isNotBlank(columnKey) && "PRI".equalsIgnoreCase(columnKey)); genTableColumnEntity.setAutoFill("DEFAULT"); - genTableColumnEntity.setFormItem(true); - genTableColumnEntity.setGridItem(true); + genTableColumnEntity.setPrimaryPk((StringUtils.isNotBlank(columnKey) && "PRI".equalsIgnoreCase(columnKey)) + ? BoolFillEnum.TRUE.getValue() : BoolFillEnum.FALSE.getValue()); + genTableColumnEntity.setAutoFill("DEFAULT"); + genTableColumnEntity.setFormItem(BoolFillEnum.TRUE.getValue()); + genTableColumnEntity.setGridItem(BoolFillEnum.TRUE.getValue()); + // 审计字段处理 if (EnumUtil.contains(CommonColumnFiledEnum.class, columnName)) { diff --git a/pig-visual/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/service/impl/GeneratorServiceImpl.java b/pig-visual/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/service/impl/GeneratorServiceImpl.java index 7876c094..a44aca5a 100755 --- a/pig-visual/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/service/impl/GeneratorServiceImpl.java +++ b/pig-visual/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/service/impl/GeneratorServiceImpl.java @@ -21,6 +21,7 @@ import cn.hutool.core.collection.CollUtil; import cn.hutool.core.date.DateUtil; import cn.hutool.core.io.FileUtil; import cn.hutool.core.io.IoUtil; +import cn.hutool.core.util.BooleanUtil; import cn.hutool.core.util.StrUtil; import cn.hutool.json.JSONObject; import com.pig4cloud.pig.codegen.entity.GenTable; @@ -62,8 +63,6 @@ public class GeneratorServiceImpl implements GeneratorService { private final GenGroupService genGroupService; - private final GenTemplateService genTemplateService; - /** * 生成代码zip写出 * @param tableId 表 @@ -225,21 +224,22 @@ public class GeneratorServiceImpl implements GeneratorService { // 按字段类型分组,使用 Map 存储不同类型的字段列表 Map> typeMap = table.getFieldList() .stream() - .collect(Collectors.partitioningBy(GenTableColumnEntity::isPrimaryPk)); + .collect(Collectors + .partitioningBy(columnEntity -> BooleanUtil.toBoolean(columnEntity.getPrimaryPk()))); // 从分组后的 Map 中获取不同类型的字段列表 List primaryList = typeMap.get(true); List formList = typeMap.get(false) .stream() - .filter(GenTableColumnEntity::isFormItem) + .filter(columnEntity -> BooleanUtil.toBoolean(columnEntity.getFormItem())) .collect(Collectors.toList()); List gridList = typeMap.get(false) .stream() - .filter(GenTableColumnEntity::isGridItem) + .filter(columnEntity -> BooleanUtil.toBoolean(columnEntity.getGridItem())) .collect(Collectors.toList()); List queryList = typeMap.get(false) .stream() - .filter(GenTableColumnEntity::isQueryItem) + .filter(columnEntity -> BooleanUtil.toBoolean(columnEntity.getQueryItem())) .collect(Collectors.toList()); if (CollUtil.isNotEmpty(primaryList)) { diff --git a/pig-visual/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/util/BoolFillEnum.java b/pig-visual/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/util/BoolFillEnum.java new file mode 100644 index 00000000..a4017629 --- /dev/null +++ b/pig-visual/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/util/BoolFillEnum.java @@ -0,0 +1,26 @@ +package com.pig4cloud.pig.codegen.util; + +import lombok.Getter; +import lombok.RequiredArgsConstructor; + +/** + * boolean 类型枚举 + * + */ + +@Getter +@RequiredArgsConstructor +public enum BoolFillEnum { + + /** + * true + */ + TRUE("1"), + /** + * false + */ + FALSE("0"); + + private final String value; + +} diff --git a/pig-visual/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/util/CommonColumnFiledEnum.java b/pig-visual/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/util/CommonColumnFiledEnum.java index 47cdd843..5ef0f830 100644 --- a/pig-visual/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/util/CommonColumnFiledEnum.java +++ b/pig-visual/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/util/CommonColumnFiledEnum.java @@ -16,38 +16,38 @@ public enum CommonColumnFiledEnum { /** * create_by 字段 */ - create_by(false, false, "INSERT", 100), + create_by("0", "0", "INSERT", 100), /** * create_time 字段 */ - create_time(false, false, "INSERT", 101), + create_time("0", "0", "INSERT", 101), /** * update_by 字段 */ - update_by(false, false, "INSERT_UPDATE", 102), + update_by("0", "0", "INSERT_UPDATE", 102), /** * update_time 字段 */ - update_time(false, false, "INSERT_UPDATE", 103), + update_time("0", "0", "INSERT_UPDATE", 103), /** * del_flag 字段 */ - del_flag(false, false, "DEFAULT", 104), + del_flag("0", "0", "DEFAULT", 104), /** * tenant_id 字段 */ - tenant_id(false, false, "DEFAULT", 105); + tenant_id("0", "0", "DEFAULT", 105); /** * 表单是否默认显示 */ - private Boolean formItem; + private String formItem; /** * 表格是否默认显示 */ - private Boolean gridItem; + private String gridItem; /** * 自动填充策略 diff --git a/pig-visual/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/util/GeneratorFileTypeEnum.java b/pig-visual/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/util/GeneratorFileTypeEnum.java deleted file mode 100644 index dc744e79..00000000 --- a/pig-visual/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/util/GeneratorFileTypeEnum.java +++ /dev/null @@ -1,14 +0,0 @@ -package com.pig4cloud.pig.codegen.util; - -public enum GeneratorFileTypeEnum { - - /** - * zip - */ - ZIP, - /** - * 目录直接写入 - */ - DIRECTORY; - -} diff --git a/pig-visual/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/util/GeneratorTypeEnum.java b/pig-visual/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/util/GeneratorTypeEnum.java new file mode 100644 index 00000000..e991e883 --- /dev/null +++ b/pig-visual/pig-codegen/src/main/java/com/pig4cloud/pig/codegen/util/GeneratorTypeEnum.java @@ -0,0 +1,21 @@ +package com.pig4cloud.pig.codegen.util; + +import lombok.Getter; +import lombok.RequiredArgsConstructor; + +@Getter +@RequiredArgsConstructor +public enum GeneratorTypeEnum { + + /** + * zip压缩包 0 + */ + ZIP_DOWNLOAD("0"), + /** + * 自定义目录 1 + */ + CUSTOM_DIRECTORY("1"); + + private final String value; + +}