From 77d20072e33d8605b69bfc065abdad9cc9ba85d1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=86=B7=E5=86=B7?= <2270033969@qq.com> Date: Sun, 14 Jul 2024 11:31:58 +0800 Subject: [PATCH] =?UTF-8?q?ref:=20=E9=87=8D=E6=9E=84=E6=A8=A1=E6=9D=BF?= =?UTF-8?q?=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- common/api.ts | 114 ++++++++++++++++++ ...55\346\226\207\346\250\241\346\235\277.ts" | 0 ...61\346\226\207\346\250\241\346\235\277.ts" | 0 {temps => common}/vform.json | 0 {temps => common}/vform.vue | 0 ...3\351\231\220\350\217\234\345\215\225.sql" | 0 config.json | 46 +++---- gen.sh | 20 --- .../\344\270\273\345\255\220Contoller.java" | 15 +-- .../\344\270\273\345\255\220Service.java" | 9 -- .../\344\270\273\345\255\220ServiceImpl.java" | 8 +- ...3\345\255\220\350\241\250\345\215\225.vue" | 4 +- ...3\345\255\220\350\241\250\346\240\274.vue" | 5 +- ...\344\270\273\345\256\236\344\275\223.java" | 4 - .../\345\255\220Mapper.java" | 8 -- ...\345\255\220\345\256\236\344\275\223.java" | 0 temps/Controller => single/Controller.java | 14 +-- temps/Mapper => single/Mapper.java | 1 - {temps => single}/Mapper.xml | 0 single/Service.java | 8 ++ single/ServiceImpl.java | 18 +++ "single/\345\256\236\344\275\223.java" | 57 +++++++++ .../\350\241\250\345\215\225.vue" | 4 +- .../\350\241\250\346\240\274.vue" | 0 temps/api.ts | 50 -------- 25 files changed, 243 insertions(+), 142 deletions(-) create mode 100644 common/api.ts rename "temps/i18n\344\270\255\346\226\207\346\250\241\346\235\277" => "common/i18n\344\270\255\346\226\207\346\250\241\346\235\277.ts" (100%) rename "temps/i18n\350\213\261\346\226\207\346\250\241\346\235\277" => "common/i18n\350\213\261\346\226\207\346\250\241\346\235\277.ts" (100%) rename {temps => common}/vform.json (100%) rename {temps => common}/vform.vue (100%) rename "temps/\346\235\203\351\231\220\350\217\234\345\215\225" => "common/\346\235\203\351\231\220\350\217\234\345\215\225.sql" (100%) delete mode 100755 gen.sh rename "temps/\344\270\273\345\255\220Contoller" => "multiple/\344\270\273\345\255\220Contoller.java" (93%) rename temps/Service => "multiple/\344\270\273\345\255\220Service.java" (71%) rename temps/ServiceImpl => "multiple/\344\270\273\345\255\220ServiceImpl.java" (97%) rename "temps/\344\270\273\345\255\220\350\241\250\345\215\225" => "multiple/\344\270\273\345\255\220\350\241\250\345\215\225.vue" (99%) rename "temps/\344\270\273\345\255\220\350\241\250\346\240\274" => "multiple/\344\270\273\345\255\220\350\241\250\346\240\274.vue" (96%) rename "temps/\345\256\236\344\275\223" => "multiple/\344\270\273\345\256\236\344\275\223.java" (97%) rename "temps/\345\255\220Mapper" => "multiple/\345\255\220Mapper.java" (60%) rename "temps/\345\255\220\345\256\236\344\275\223" => "multiple/\345\255\220\345\256\236\344\275\223.java" (100%) rename temps/Controller => single/Controller.java (93%) rename temps/Mapper => single/Mapper.java (99%) rename {temps => single}/Mapper.xml (100%) create mode 100644 single/Service.java create mode 100644 single/ServiceImpl.java create mode 100644 "single/\345\256\236\344\275\223.java" rename "temps/\350\241\250\345\215\225" => "single/\350\241\250\345\215\225.vue" (98%) rename "temps/\350\241\250\346\240\274" => "single/\350\241\250\346\240\274.vue" (100%) delete mode 100644 temps/api.ts diff --git a/common/api.ts b/common/api.ts new file mode 100644 index 0000000..a16f95a --- /dev/null +++ b/common/api.ts @@ -0,0 +1,114 @@ +import request from "/@/utils/request" + +/** + * 根据分页查询参数获取列表数据。 + * @param {Object} [query] - 查询参数。 + * @returns {Promise} 请求的 Promise 分页对象。 + */ +export function fetchList(query?: Object) { + return request({ + url: '/${moduleName}/${functionName}/page', + method: 'get', + params: query + }) +} + +/** + * 添加一个新对象。 + * @param {Object} [obj] - 要添加的对象。 + * @returns {Promise} 请求的 Promise 对象 (true/false)。 + */ +export function addObj(obj?: Object) { + return request({ + url: '/${moduleName}/${functionName}', + method: 'post', + data: obj + }) +} + +/** + * 根据查询参数获取对象详情。 + * @param {Object} [obj] - 查询参数。 + * @returns {Promise} 请求的 Promise 对象数组。 + */ +export function getObj(obj?: Object) { + return request({ + url: '/${moduleName}/${functionName}/details', + method: 'get', + params: obj + }) +} + +/** + * 根据 ID 删除对象。 + * @param {Object} [ids] - 要删除的对象 ID。 + * @returns {Promise} 请求的 Promise 对象。 + */ +export function delObjs(ids?: Object) { + return request({ + url: '/${moduleName}/${functionName}', + method: 'delete', + data: ids + }) +} + +/** + * 更新一个已存在的对象。 + * @param {Object} [obj] - 要更新的对象。 + * @returns {Promise} 请求的 Promise 对象。 + */ +export function putObj(obj?: Object) { + return request({ + url: '/${moduleName}/${functionName}', + method: 'put', + data: obj + }) +} + +/** + * 验证某个字段的值是否已经存在。 + * @param {Object} rule - 验证规则对象。 + * @param {*} value - 要验证的值。 + * @param {Function} callback - 验证完成后的回调函数。 + * @param {boolean} isEdit - 当前操作是否为编辑。 + * + * 示例用法: + * 字段名: [ + * { + * validator: (rule, value, callback) => { + * validateExist(rule, value, callback, form.id !== ''); + * }, + * trigger: 'blur', + * }, + * ] + */ +export function validateExist(rule: any, value: any, callback: any, isEdit: boolean) { + if (isEdit) { + return callback(); + } + + getObj({ [rule.field]: value }).then((response) => { + const result = response.data; + if (result !== null) { + callback(new Error('数据已经存在')); + } else { + callback(); + } + }); +} + + +#if($ChildClassName) +/** +* 删除子对象。 +* @param {Object} [ids] - 要删除的子对象 ID。 +* @returns {Promise} 请求的 Promise 对象。 +*/ +export function delChildObj(ids?: Object) { + return request({ + url: '/${moduleName}/${functionName}/child', + method: 'delete', + data: ids + }) +} +#end diff --git "a/temps/i18n\344\270\255\346\226\207\346\250\241\346\235\277" "b/common/i18n\344\270\255\346\226\207\346\250\241\346\235\277.ts" similarity index 100% rename from "temps/i18n\344\270\255\346\226\207\346\250\241\346\235\277" rename to "common/i18n\344\270\255\346\226\207\346\250\241\346\235\277.ts" diff --git "a/temps/i18n\350\213\261\346\226\207\346\250\241\346\235\277" "b/common/i18n\350\213\261\346\226\207\346\250\241\346\235\277.ts" similarity index 100% rename from "temps/i18n\350\213\261\346\226\207\346\250\241\346\235\277" rename to "common/i18n\350\213\261\346\226\207\346\250\241\346\235\277.ts" diff --git a/temps/vform.json b/common/vform.json similarity index 100% rename from temps/vform.json rename to common/vform.json diff --git a/temps/vform.vue b/common/vform.vue similarity index 100% rename from temps/vform.vue rename to common/vform.vue diff --git "a/temps/\346\235\203\351\231\220\350\217\234\345\215\225" "b/common/\346\235\203\351\231\220\350\217\234\345\215\225.sql" similarity index 100% rename from "temps/\346\235\203\351\231\220\350\217\234\345\215\225" rename to "common/\346\235\203\351\231\220\350\217\234\345\215\225.sql" diff --git a/config.json b/config.json index b0c06b5..81a1b49 100644 --- a/config.json +++ b/config.json @@ -3,114 +3,114 @@ { "templateName": "Controller", "generatorPath": "${backendPath}/src/main/java/${packagePath}/${moduleName}/controller/${ClassName}Controller.java", - "templateFile": "temps/Controller" + "templateFile": "single/Controller.java" }, { "templateName": "Service", "generatorPath": "${backendPath}/src/main/java/${packagePath}/${moduleName}/service/${ClassName}Service.java", - "templateFile": "temps/Service" + "templateFile": "single/Service.java" }, { "templateName": "ServiceImpl", "generatorPath": "${backendPath}/src/main/java/${packagePath}/${moduleName}/service/impl/${ClassName}ServiceImpl.java", - "templateFile": "temps/ServiceImpl" + "templateFile": "single/ServiceImpl.java" }, { "templateName": "实体", "generatorPath": "${backendPath}/src/main/java/${packagePath}/${moduleName}/entity/${ClassName}Entity.java", - "templateFile": "temps/实体" + "templateFile": "single/实体.java" }, { "templateName": "Mapper", "generatorPath": "${backendPath}/src/main/java/${packagePath}/${moduleName}/mapper/${ClassName}Mapper.java", - "templateFile": "temps/Mapper" + "templateFile": "single/Mapper.java" }, { "templateName": "Mapper.xml", "generatorPath": "${backendPath}/src/main/resources/mapper/${ClassName}Mapper.xml", - "templateFile": "temps/Mapper.xml" + "templateFile": "single/Mapper.xml" }, { "templateName": "权限菜单", "generatorPath": "${backendPath}/menu/${functionName}_menu.sql", - "templateFile": "temps/权限菜单" + "templateFile": "common/权限菜单.sql" }, { "templateName": "api.ts", "generatorPath": "${frontendPath}/src/api/${moduleName}/${functionName}.ts", - "templateFile": "temps/api.ts" + "templateFile": "common/api.ts" }, { "templateName": "表格", "generatorPath": "${frontendPath}/src/views/${moduleName}/${functionName}/index.vue", - "templateFile": "temps/表格" + "templateFile": "single/表格.vue" }, { "templateName": "表单", "generatorPath": "${frontendPath}/src/views/${moduleName}/${functionName}/form.vue", - "templateFile": "temps/表单" + "templateFile": "single/表单.vue" } ], "主子表增删改查": [ { "templateName": "Service", "generatorPath": "${backendPath}/src/main/java/${packagePath}/${moduleName}/service/${ClassName}Service.java", - "templateFile": "temps/Service" + "templateFile": "multiple/主子Service.java" }, { "templateName": "ServiceImpl", "generatorPath": "${backendPath}/src/main/java/${packagePath}/${moduleName}/service/impl/${ClassName}ServiceImpl.java", - "templateFile": "temps/ServiceImpl" + "templateFile": "multiple/主子ServiceImpl.java" }, { - "templateName": "实体", + "templateName": "主实体", "generatorPath": "${backendPath}/src/main/java/${packagePath}/${moduleName}/entity/${ClassName}Entity.java", - "templateFile": "temps/实体" + "templateFile": "multiple/主实体.java" }, { "templateName": "Mapper", "generatorPath": "${backendPath}/src/main/java/${packagePath}/${moduleName}/mapper/${ClassName}Mapper.java", - "templateFile": "temps/Mapper" + "templateFile": "single/Mapper.java" }, { "templateName": "Mapper.xml", "generatorPath": "${backendPath}/src/main/resources/mapper/${ClassName}Mapper.xml", - "templateFile": "temps/Mapper.xml" + "templateFile": "single/Mapper.xml" }, { "templateName": "权限菜单", "generatorPath": "${backendPath}/menu/${functionName}_menu.sql", - "templateFile": "temps/权限菜单" + "templateFile": "common/权限菜单.sql" }, { "templateName": "api.ts", "generatorPath": "${frontendPath}/src/api/${moduleName}/${functionName}.ts", - "templateFile": "temps/api.ts" + "templateFile": "common/api.ts" }, { "templateName": "子实体", "generatorPath": "${backendPath}/src/main/java/${packagePath}/${moduleName}/entity/${ChildClassName}Entity.java", - "templateFile": "temps/子实体" + "templateFile": "multiple/子实体.java" }, { "templateName": "主子Contoller", "generatorPath": "${backendPath}/src/main/java/${packagePath}/${moduleName}/controller/${ClassName}Controller.java", - "templateFile": "temps/主子Contoller" + "templateFile": "multiple/主子Contoller.java" }, { "templateName": "主子表单", "generatorPath": "${frontendPath}/src/views/${moduleName}/${functionName}/form.vue", - "templateFile": "temps/主子表单" + "templateFile": "multiple/主子表单.vue" }, { "templateName": "主子表格", "generatorPath": "${frontendPath}/src/views/${moduleName}/${functionName}/index.vue", - "templateFile": "temps/主子表格" + "templateFile": "multiple/主子表格.vue" }, { "templateName": "子Mapper", "generatorPath": "${backendPath}/src/main/java/${packagePath}/${moduleName}/mapper/${ChildClassName}Mapper.java", - "templateFile": "temps/子Mapper" + "templateFile": "multiple/子Mapper.java" } ] } diff --git a/gen.sh b/gen.sh deleted file mode 100755 index d789569..0000000 --- a/gen.sh +++ /dev/null @@ -1,20 +0,0 @@ -#!/bin/bash - -# 数据库配置信息 -DB_HOST="localhost" -DB_USER="root" -DB_PASS="root" -DB_NAME="pigxx_boot" - - -# 查询SQL -QUERY="SELECT template_name, template_code FROM gen_template" - -# 创建存储模板文件的目录 -mkdir -p ./temps - -# 执行查询并处理结果 -mysql -h $DB_HOST -u $DB_USER -p$DB_PASS -D $DB_NAME -e "$QUERY" -B -N | while IFS=$'\t' read -r template_name template_code; do - # 创建以template_name命名的文件,并将转义后的template_code写入文件 - echo -e "$template_code" > "./temps/$template_name" -done diff --git "a/temps/\344\270\273\345\255\220Contoller" "b/multiple/\344\270\273\345\255\220Contoller.java" similarity index 93% rename from "temps/\344\270\273\345\255\220Contoller" rename to "multiple/\344\270\273\345\255\220Contoller.java" index a91d171..2c06236 100644 --- "a/temps/\344\270\273\345\255\220Contoller" +++ "b/multiple/\344\270\273\345\255\220Contoller.java" @@ -86,16 +86,17 @@ public class ${ClassName}Controller { return R.ok(${className}Service.page(page, wrapper)); } + /** - * 通过id查询${tableComment} - * @param ${pk.attrName} id - * @return R + * 通过条件查询${tableComment} + * @param ${className} 查询条件 + * @return R 对象列表 */ - @Operation(summary = "通过id查询" , description = "通过id查询" ) - @GetMapping("/{${pk.attrName}}" ) + @Operation(summary = "通过条件查询" , description = "通过条件查询对象" ) + @GetMapping("/details" ) @PreAuthorize("@pms.hasPermission('${moduleName}_${functionName}_view')" ) - public R getById(@PathVariable("${pk.attrName}" ) ${pk.attrType} ${pk.attrName}) { - return R.ok(${className}Service.getByIdDeep(${pk.attrName})); + public R getDetails(@ParameterObject ${ClassName}Entity ${className}) { + return R.ok(${className}Service.listDeep(Wrappers.query(${className})})); } /** diff --git a/temps/Service "b/multiple/\344\270\273\345\255\220Service.java" similarity index 71% rename from temps/Service rename to "multiple/\344\270\273\345\255\220Service.java" index 6ba313e..e2e388d 100644 --- a/temps/Service +++ "b/multiple/\344\270\273\345\255\220Service.java" @@ -1,14 +1,9 @@ package ${package}.${moduleName}.service; -#if($ChildClassName) import com.github.yulichang.extension.mapping.base.MPJDeepService; import ${package}.${moduleName}.entity.${ChildClassName}Entity; -#else -import com.baomidou.mybatisplus.extension.service.IService; -#end import ${package}.${moduleName}.entity.${ClassName}Entity; -#if($ChildClassName) public interface ${ClassName}Service extends MPJDeepService<${ClassName}Entity> { Boolean saveDeep(${ClassName}Entity ${className}); @@ -17,8 +12,4 @@ public interface ${ClassName}Service extends MPJDeepService<${ClassName}Entity> Boolean removeDeep(Long[] ids); Boolean removeChild(Long[] ids); -#else -public interface ${ClassName}Service extends IService<${ClassName}Entity> { -#end - } diff --git a/temps/ServiceImpl "b/multiple/\344\270\273\345\255\220ServiceImpl.java" similarity index 97% rename from temps/ServiceImpl rename to "multiple/\344\270\273\345\255\220ServiceImpl.java" index 75009b3..c1be6c3 100644 --- a/temps/ServiceImpl +++ "b/multiple/\344\270\273\345\255\220ServiceImpl.java" @@ -5,7 +5,6 @@ import ${package}.${moduleName}.mapper.${ClassName}Mapper; import ${package}.${moduleName}.service.${ClassName}Service; import org.springframework.stereotype.Service; -#if($ChildClassName) import cn.hutool.core.collection.CollUtil; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import ${package}.${moduleName}.entity.${ChildClassName}Entity; @@ -13,7 +12,7 @@ import org.springframework.transaction.annotation.Transactional; import lombok.RequiredArgsConstructor; import java.util.Objects; -#end + /** * ${tableComment} * @@ -21,11 +20,9 @@ * @date ${datetime} */ @Service -#if($ChildClassName) @RequiredArgsConstructor -#end public class ${ClassName}ServiceImpl extends ServiceImpl<${ClassName}Mapper, ${ClassName}Entity> implements ${ClassName}Service { -#if($ChildClassName) + private final ${ChildClassName}Mapper ${childClassName}Mapper; @Override @@ -70,5 +67,4 @@ public Boolean removeChild(Long[] ids) { ${childClassName}Mapper.deleteBatchIds(CollUtil.toList(ids)); return Boolean.TRUE; } -#end } diff --git "a/temps/\344\270\273\345\255\220\350\241\250\345\215\225" "b/multiple/\344\270\273\345\255\220\350\241\250\345\215\225.vue" similarity index 99% rename from "temps/\344\270\273\345\255\220\350\241\250\345\215\225" rename to "multiple/\344\270\273\345\255\220\350\241\250\345\215\225.vue" index 772093f..b0dba55 100644 --- "a/temps/\344\270\273\345\255\220\350\241\250\345\215\225" +++ "b/multiple/\344\270\273\345\255\220\350\241\250\345\215\225.vue" @@ -247,8 +247,8 @@ const deleteChild = async (obj: { $childPkName: string }) => { // 初始化表单数据 const get${ClassName}Data = (id: string) => { // 获取数据 - getObj(id).then((res: any) => { - Object.assign(form, res.data) + getObj({${pk.attrName}: id).then((res: any) => { + Object.assign(form, res.data[0]) }) }; diff --git "a/temps/\344\270\273\345\255\220\350\241\250\346\240\274" "b/multiple/\344\270\273\345\255\220\350\241\250\346\240\274.vue" similarity index 96% rename from "temps/\344\270\273\345\255\220\350\241\250\346\240\274" rename to "multiple/\344\270\273\345\255\220\350\241\250\346\240\274.vue" index f0ec0c8..2d0980f 100644 --- "a/temps/\344\270\273\345\255\220\350\241\250\346\240\274" +++ "b/multiple/\344\270\273\345\255\220\350\241\250\346\240\274.vue" @@ -27,10 +27,9 @@ #if($field.fieldDict) - {{ item.label }} - + {{ item.label }} #else - ${field.fieldComment} + ${field.fieldComment} #end diff --git "a/temps/\345\256\236\344\275\223" "b/multiple/\344\270\273\345\256\236\344\275\223.java" similarity index 97% rename from "temps/\345\256\236\344\275\223" rename to "multiple/\344\270\273\345\256\236\344\275\223.java" index 249219a..e6fb255 100644 --- "a/temps/\345\256\236\344\275\223" +++ "b/multiple/\344\270\273\345\256\236\344\275\223.java" @@ -11,11 +11,9 @@ #foreach($import in $importList) import $import; #end -#if($ChildClassName) import com.alibaba.excel.annotation.ExcelIgnore; import com.github.yulichang.annotation.EntityMapping; import java.util.List; -#end /** * ${tableComment} @@ -59,10 +57,8 @@ public class ${ClassName}Entity extends Model<${ClassName}Entity> { private $field.attrType $field.attrName; #end #end -#if($ChildClassName) @ExcelIgnore @TableField(exist = false) @EntityMapping(thisField = "$mainField", joinField = "$childField") private List<${ChildClassName}Entity> ${childClassName}List; -#end } diff --git "a/temps/\345\255\220Mapper" "b/multiple/\345\255\220Mapper.java" similarity index 60% rename from "temps/\345\255\220Mapper" rename to "multiple/\345\255\220Mapper.java" index 585182e..7d89b7b 100644 --- "a/temps/\345\255\220Mapper" +++ "b/multiple/\345\255\220Mapper.java" @@ -1,18 +1,10 @@ package ${package}.${moduleName}.mapper; import com.pig4cloud.pigx.common.data.datascope.PigxBaseMapper; -#if($ChildClassName) import ${package}.${moduleName}.entity.${ChildClassName}Entity; -#else -import ${package}.${moduleName}.entity.${ClassName}Entity; -#end import org.apache.ibatis.annotations.Mapper; @Mapper -#if($ChildClassName) public interface ${ChildClassName}Mapper extends PigxBaseMapper<${ChildClassName}Entity> { -#else -public interface ${ClassName}Mapper extends PigxBaseMapper<${ClassName}Entity> { -#end } diff --git "a/temps/\345\255\220\345\256\236\344\275\223" "b/multiple/\345\255\220\345\256\236\344\275\223.java" similarity index 100% rename from "temps/\345\255\220\345\256\236\344\275\223" rename to "multiple/\345\255\220\345\256\236\344\275\223.java" diff --git a/temps/Controller b/single/Controller.java similarity index 93% rename from temps/Controller rename to single/Controller.java index 03f665f..afac6ba 100644 --- a/temps/Controller +++ b/single/Controller.java @@ -88,15 +88,15 @@ public class ${ClassName}Controller { /** - * 通过id查询${tableComment} - * @param ${pk.attrName} id - * @return R + * 通过条件查询${tableComment} + * @param ${className} 查询条件 + * @return R 对象列表 */ - @Operation(summary = "通过id查询" , description = "通过id查询" ) - @GetMapping("/{${pk.attrName}}" ) + @Operation(summary = "通过条件查询" , description = "通过条件查询对象" ) + @GetMapping("/details" ) @PreAuthorize("@pms.hasPermission('${moduleName}_${functionName}_view')" ) - public R getById(@PathVariable("${pk.attrName}" ) ${pk.attrType} ${pk.attrName}) { - return R.ok(${className}Service.getById(${pk.attrName})); + public R getDetails(@ParameterObject ${ClassName}Entity ${className}) { + return R.ok(${className}Service.list(Wrappers.query(${className})})); } /** diff --git a/temps/Mapper b/single/Mapper.java similarity index 99% rename from temps/Mapper rename to single/Mapper.java index 76a1849..4a2c4ef 100644 --- a/temps/Mapper +++ b/single/Mapper.java @@ -7,5 +7,4 @@ @Mapper public interface ${ClassName}Mapper extends PigxBaseMapper<${ClassName}Entity> { - } diff --git a/temps/Mapper.xml b/single/Mapper.xml similarity index 100% rename from temps/Mapper.xml rename to single/Mapper.xml diff --git a/single/Service.java b/single/Service.java new file mode 100644 index 0000000..ce98c2b --- /dev/null +++ b/single/Service.java @@ -0,0 +1,8 @@ +package ${package}.${moduleName}.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import ${package}.${moduleName}.entity.${ClassName}Entity; + +public interface ${ClassName}Service extends IService<${ClassName}Entity> { + +} diff --git a/single/ServiceImpl.java b/single/ServiceImpl.java new file mode 100644 index 0000000..caf04ac --- /dev/null +++ b/single/ServiceImpl.java @@ -0,0 +1,18 @@ +package ${package}.${moduleName}.service.impl; + +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import ${package}.${moduleName}.entity.${ClassName}Entity; +import ${package}.${moduleName}.mapper.${ClassName}Mapper; +import ${package}.${moduleName}.service.${ClassName}Service; +import org.springframework.stereotype.Service; + +/** + * ${tableComment} + * + * @author ${author} + * @date ${datetime} + */ +@Service +public class ${ClassName}ServiceImpl extends ServiceImpl<${ClassName}Mapper, ${ClassName}Entity> implements ${ClassName}Service { + +} diff --git "a/single/\345\256\236\344\275\223.java" "b/single/\345\256\236\344\275\223.java" new file mode 100644 index 0000000..910b6cf --- /dev/null +++ "b/single/\345\256\236\344\275\223.java" @@ -0,0 +1,57 @@ +package ${package}.${moduleName}.entity; + +import com.baomidou.mybatisplus.annotation.*; +import com.baomidou.mybatisplus.extension.activerecord.Model; +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; +import lombok.EqualsAndHashCode; +#if($isTenant) +import com.pig4cloud.pigx.common.core.util.TenantTable; +#end +#foreach($import in $importList) +import $import; +#end + +/** + * ${tableComment} + * + * @author ${author} + * @date ${datetime} + */ +@Data +#if($isTenant) +@TenantTable +#end +@TableName("${tableName}") +@EqualsAndHashCode(callSuper = true) +@Schema(description = "${tableComment}") +public class ${ClassName}Entity extends Model<${ClassName}Entity> { + +#foreach ($field in $fieldList) +#if(${field.fieldComment})#set($comment=${field.fieldComment})#else #set($comment=${field.attrName})#end + + /** + * $comment + */ +#if($field.primaryPk == '1') + @TableId(type = IdType.ASSIGN_ID) +#end +#if($field.autoFill == 'INSERT') + @TableField(fill = FieldFill.INSERT) +#elseif($field.autoFill == 'INSERT_UPDATE') + @TableField(fill = FieldFill.INSERT_UPDATE) +#elseif($field.autoFill == 'UPDATE') + @TableField(fill = FieldFill.UPDATE) +#end +#if($field.fieldName == 'del_flag') + @TableLogic + @TableField(fill = FieldFill.INSERT) +#end + @Schema(description="$comment"#if($field.hidden),hidden=$field.hidden#end) +#if($field.formType == 'checkbox') + private ${field.attrType}[] $field.attrName; +#else + private $field.attrType $field.attrName; +#end +#end +} diff --git "a/temps/\350\241\250\345\215\225" "b/single/\350\241\250\345\215\225.vue" similarity index 98% rename from "temps/\350\241\250\345\215\225" rename to "single/\350\241\250\345\215\225.vue" index 313b2a6..b7ebb7c 100644 --- "a/temps/\350\241\250\345\215\225" +++ "b/single/\350\241\250\345\215\225.vue" @@ -200,8 +200,8 @@ const onSubmit = async () => { const get${className}Data = (id: string) => { // 获取数据 loading.value = true - getObj(id).then((res: any) => { - Object.assign(form, res.data) + getObj({${pk.attrName}: id}).then((res: any) => { + Object.assign(form, res.data[0]) }).finally(() => { loading.value = false }) diff --git "a/temps/\350\241\250\346\240\274" "b/single/\350\241\250\346\240\274.vue" similarity index 100% rename from "temps/\350\241\250\346\240\274" rename to "single/\350\241\250\346\240\274.vue" diff --git a/temps/api.ts b/temps/api.ts deleted file mode 100644 index 83a5431..0000000 --- a/temps/api.ts +++ /dev/null @@ -1,50 +0,0 @@ -import request from "/@/utils/request" - -export function fetchList(query?: Object) { - return request({ - url: '/${moduleName}/${functionName}/page', - method: 'get', - params: query - }) -} - -export function addObj(obj?: Object) { - return request({ - url: '/${moduleName}/${functionName}', - method: 'post', - data: obj - }) -} - -export function getObj(id?: string) { - return request({ - url: '/${moduleName}/${functionName}/' + id, - method: 'get' - }) -} - -export function delObjs(ids?: Object) { - return request({ - url: '/${moduleName}/${functionName}', - method: 'delete', - data: ids - }) -} - -export function putObj(obj?: Object) { - return request({ - url: '/${moduleName}/${functionName}', - method: 'put', - data: obj - }) -} - -#if($ChildClassName) -export function delChildObj(ids?: Object) { - return request({ - url: '/${moduleName}/${functionName}/child', - method: 'delete', - data: ids - }) -} -#end