Browse Source

ref: 重构模板文件

冷冷 9 months ago
parent
commit
77d20072e3

+ 114 - 0
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

temps/i18n中文模板 → common/i18n中文模板.ts


temps/i18n英文模板 → common/i18n英文模板.ts


temps/vform.json → common/vform.json


temps/vform.vue → common/vform.vue


temps/权限菜单 → common/权限菜单.sql


+ 23 - 23
config.json

@@ -3,114 +3,114 @@
     {
     {
       "templateName": "Controller",
       "templateName": "Controller",
       "generatorPath": "${backendPath}/src/main/java/${packagePath}/${moduleName}/controller/${ClassName}Controller.java",
       "generatorPath": "${backendPath}/src/main/java/${packagePath}/${moduleName}/controller/${ClassName}Controller.java",
-      "templateFile": "temps/Controller"
+      "templateFile": "single/Controller.java"
     },
     },
     {
     {
       "templateName": "Service",
       "templateName": "Service",
       "generatorPath": "${backendPath}/src/main/java/${packagePath}/${moduleName}/service/${ClassName}Service.java",
       "generatorPath": "${backendPath}/src/main/java/${packagePath}/${moduleName}/service/${ClassName}Service.java",
-      "templateFile": "temps/Service"
+      "templateFile": "single/Service.java"
     },
     },
     {
     {
       "templateName": "ServiceImpl",
       "templateName": "ServiceImpl",
       "generatorPath": "${backendPath}/src/main/java/${packagePath}/${moduleName}/service/impl/${ClassName}ServiceImpl.java",
       "generatorPath": "${backendPath}/src/main/java/${packagePath}/${moduleName}/service/impl/${ClassName}ServiceImpl.java",
-      "templateFile": "temps/ServiceImpl"
+      "templateFile": "single/ServiceImpl.java"
     },
     },
     {
     {
       "templateName": "实体",
       "templateName": "实体",
       "generatorPath": "${backendPath}/src/main/java/${packagePath}/${moduleName}/entity/${ClassName}Entity.java",
       "generatorPath": "${backendPath}/src/main/java/${packagePath}/${moduleName}/entity/${ClassName}Entity.java",
-      "templateFile": "temps/实体"
+      "templateFile": "single/实体.java"
     },
     },
     {
     {
       "templateName": "Mapper",
       "templateName": "Mapper",
       "generatorPath": "${backendPath}/src/main/java/${packagePath}/${moduleName}/mapper/${ClassName}Mapper.java",
       "generatorPath": "${backendPath}/src/main/java/${packagePath}/${moduleName}/mapper/${ClassName}Mapper.java",
-      "templateFile": "temps/Mapper"
+      "templateFile": "single/Mapper.java"
     },
     },
     {
     {
       "templateName": "Mapper.xml",
       "templateName": "Mapper.xml",
       "generatorPath": "${backendPath}/src/main/resources/mapper/${ClassName}Mapper.xml",
       "generatorPath": "${backendPath}/src/main/resources/mapper/${ClassName}Mapper.xml",
-      "templateFile": "temps/Mapper.xml"
+      "templateFile": "single/Mapper.xml"
     },
     },
     {
     {
       "templateName": "权限菜单",
       "templateName": "权限菜单",
       "generatorPath": "${backendPath}/menu/${functionName}_menu.sql",
       "generatorPath": "${backendPath}/menu/${functionName}_menu.sql",
-      "templateFile": "temps/权限菜单"
+      "templateFile": "common/权限菜单.sql"
     },
     },
     {
     {
       "templateName": "api.ts",
       "templateName": "api.ts",
       "generatorPath": "${frontendPath}/src/api/${moduleName}/${functionName}.ts",
       "generatorPath": "${frontendPath}/src/api/${moduleName}/${functionName}.ts",
-      "templateFile": "temps/api.ts"
+      "templateFile": "common/api.ts"
     },
     },
     {
     {
       "templateName": "表格",
       "templateName": "表格",
       "generatorPath": "${frontendPath}/src/views/${moduleName}/${functionName}/index.vue",
       "generatorPath": "${frontendPath}/src/views/${moduleName}/${functionName}/index.vue",
-      "templateFile": "temps/表格"
+      "templateFile": "single/表格.vue"
     },
     },
     {
     {
       "templateName": "表单",
       "templateName": "表单",
       "generatorPath": "${frontendPath}/src/views/${moduleName}/${functionName}/form.vue",
       "generatorPath": "${frontendPath}/src/views/${moduleName}/${functionName}/form.vue",
-      "templateFile": "temps/表单"
+      "templateFile": "single/表单.vue"
     }
     }
   ],
   ],
   "主子表增删改查": [
   "主子表增删改查": [
     {
     {
       "templateName": "Service",
       "templateName": "Service",
       "generatorPath": "${backendPath}/src/main/java/${packagePath}/${moduleName}/service/${ClassName}Service.java",
       "generatorPath": "${backendPath}/src/main/java/${packagePath}/${moduleName}/service/${ClassName}Service.java",
-      "templateFile": "temps/Service"
+      "templateFile": "multiple/主子Service.java"
     },
     },
     {
     {
       "templateName": "ServiceImpl",
       "templateName": "ServiceImpl",
       "generatorPath": "${backendPath}/src/main/java/${packagePath}/${moduleName}/service/impl/${ClassName}ServiceImpl.java",
       "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",
       "generatorPath": "${backendPath}/src/main/java/${packagePath}/${moduleName}/entity/${ClassName}Entity.java",
-      "templateFile": "temps/实体"
+      "templateFile": "multiple/主实体.java"
     },
     },
     {
     {
       "templateName": "Mapper",
       "templateName": "Mapper",
       "generatorPath": "${backendPath}/src/main/java/${packagePath}/${moduleName}/mapper/${ClassName}Mapper.java",
       "generatorPath": "${backendPath}/src/main/java/${packagePath}/${moduleName}/mapper/${ClassName}Mapper.java",
-      "templateFile": "temps/Mapper"
+      "templateFile": "single/Mapper.java"
     },
     },
     {
     {
       "templateName": "Mapper.xml",
       "templateName": "Mapper.xml",
       "generatorPath": "${backendPath}/src/main/resources/mapper/${ClassName}Mapper.xml",
       "generatorPath": "${backendPath}/src/main/resources/mapper/${ClassName}Mapper.xml",
-      "templateFile": "temps/Mapper.xml"
+      "templateFile": "single/Mapper.xml"
     },
     },
     {
     {
       "templateName": "权限菜单",
       "templateName": "权限菜单",
       "generatorPath": "${backendPath}/menu/${functionName}_menu.sql",
       "generatorPath": "${backendPath}/menu/${functionName}_menu.sql",
-      "templateFile": "temps/权限菜单"
+      "templateFile": "common/权限菜单.sql"
     },
     },
     {
     {
       "templateName": "api.ts",
       "templateName": "api.ts",
       "generatorPath": "${frontendPath}/src/api/${moduleName}/${functionName}.ts",
       "generatorPath": "${frontendPath}/src/api/${moduleName}/${functionName}.ts",
-      "templateFile": "temps/api.ts"
+      "templateFile": "common/api.ts"
     },
     },
     {
     {
       "templateName": "子实体",
       "templateName": "子实体",
       "generatorPath": "${backendPath}/src/main/java/${packagePath}/${moduleName}/entity/${ChildClassName}Entity.java",
       "generatorPath": "${backendPath}/src/main/java/${packagePath}/${moduleName}/entity/${ChildClassName}Entity.java",
-      "templateFile": "temps/子实体"
+      "templateFile": "multiple/子实体.java"
     },
     },
     {
     {
       "templateName": "主子Contoller",
       "templateName": "主子Contoller",
       "generatorPath": "${backendPath}/src/main/java/${packagePath}/${moduleName}/controller/${ClassName}Controller.java",
       "generatorPath": "${backendPath}/src/main/java/${packagePath}/${moduleName}/controller/${ClassName}Controller.java",
-      "templateFile": "temps/主子Contoller"
+      "templateFile": "multiple/主子Contoller.java"
     },
     },
     {
     {
       "templateName": "主子表单",
       "templateName": "主子表单",
       "generatorPath": "${frontendPath}/src/views/${moduleName}/${functionName}/form.vue",
       "generatorPath": "${frontendPath}/src/views/${moduleName}/${functionName}/form.vue",
-      "templateFile": "temps/主子表单"
+      "templateFile": "multiple/主子表单.vue"
     },
     },
     {
     {
       "templateName": "主子表格",
       "templateName": "主子表格",
       "generatorPath": "${frontendPath}/src/views/${moduleName}/${functionName}/index.vue",
       "generatorPath": "${frontendPath}/src/views/${moduleName}/${functionName}/index.vue",
-      "templateFile": "temps/主子表格"
+      "templateFile": "multiple/主子表格.vue"
     },
     },
     {
     {
       "templateName": "子Mapper",
       "templateName": "子Mapper",
       "generatorPath": "${backendPath}/src/main/java/${packagePath}/${moduleName}/mapper/${ChildClassName}Mapper.java",
       "generatorPath": "${backendPath}/src/main/java/${packagePath}/${moduleName}/mapper/${ChildClassName}Mapper.java",
-      "templateFile": "temps/子Mapper"
+      "templateFile": "multiple/子Mapper.java"
     }
     }
   ]
   ]
 }
 }

+ 0 - 20
gen.sh

@@ -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

+ 8 - 7
temps/主子Contoller

@@ -86,16 +86,17 @@ public class ${ClassName}Controller {
         return R.ok(${className}Service.page(page, wrapper));
         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')" )
     @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})}));
     }
     }
 
 
     /**
     /**

+ 0 - 9
temps/Service

@@ -1,14 +1,9 @@
 package ${package}.${moduleName}.service;
 package ${package}.${moduleName}.service;
 
 
-#if($ChildClassName)
 import com.github.yulichang.extension.mapping.base.MPJDeepService;
 import com.github.yulichang.extension.mapping.base.MPJDeepService;
 import ${package}.${moduleName}.entity.${ChildClassName}Entity;
 import ${package}.${moduleName}.entity.${ChildClassName}Entity;
-#else
-import com.baomidou.mybatisplus.extension.service.IService;
-#end
 import ${package}.${moduleName}.entity.${ClassName}Entity;
 import ${package}.${moduleName}.entity.${ClassName}Entity;
 
 
-#if($ChildClassName)
 public interface ${ClassName}Service extends MPJDeepService<${ClassName}Entity> {
 public interface ${ClassName}Service extends MPJDeepService<${ClassName}Entity> {
     Boolean saveDeep(${ClassName}Entity ${className});
     Boolean saveDeep(${ClassName}Entity ${className});
 
 
@@ -17,8 +12,4 @@ public interface ${ClassName}Service extends MPJDeepService<${ClassName}Entity>
     Boolean removeDeep(Long[] ids);
     Boolean removeDeep(Long[] ids);
 
 
     Boolean removeChild(Long[] ids);
     Boolean removeChild(Long[] ids);
-#else
-public interface ${ClassName}Service extends IService<${ClassName}Entity> {
-#end
-
 }
 }

+ 2 - 6
temps/ServiceImpl

@@ -5,7 +5,6 @@ import ${package}.${moduleName}.entity.${ClassName}Entity;
 import ${package}.${moduleName}.mapper.${ClassName}Mapper;
 import ${package}.${moduleName}.mapper.${ClassName}Mapper;
 import ${package}.${moduleName}.service.${ClassName}Service;
 import ${package}.${moduleName}.service.${ClassName}Service;
 import org.springframework.stereotype.Service;
 import org.springframework.stereotype.Service;
-#if($ChildClassName)
 import cn.hutool.core.collection.CollUtil;
 import cn.hutool.core.collection.CollUtil;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import ${package}.${moduleName}.entity.${ChildClassName}Entity;
 import ${package}.${moduleName}.entity.${ChildClassName}Entity;
@@ -13,7 +12,7 @@ import ${package}.${moduleName}.mapper.${ChildClassName}Mapper;
 import org.springframework.transaction.annotation.Transactional;
 import org.springframework.transaction.annotation.Transactional;
 import lombok.RequiredArgsConstructor;
 import lombok.RequiredArgsConstructor;
 import java.util.Objects;
 import java.util.Objects;
-#end
+
 /**
 /**
  * ${tableComment}
  * ${tableComment}
  *
  *
@@ -21,11 +20,9 @@ import java.util.Objects;
  * @date ${datetime}
  * @date ${datetime}
  */
  */
 @Service
 @Service
-#if($ChildClassName)
 @RequiredArgsConstructor
 @RequiredArgsConstructor
-#end
 public class ${ClassName}ServiceImpl extends ServiceImpl<${ClassName}Mapper, ${ClassName}Entity> implements ${ClassName}Service {
 public class ${ClassName}ServiceImpl extends ServiceImpl<${ClassName}Mapper, ${ClassName}Entity> implements ${ClassName}Service {
-#if($ChildClassName)
+
   private final ${ChildClassName}Mapper ${childClassName}Mapper;
   private final ${ChildClassName}Mapper ${childClassName}Mapper;
 
 
     @Override
     @Override
@@ -70,5 +67,4 @@ public class ${ClassName}ServiceImpl extends ServiceImpl<${ClassName}Mapper, ${C
         ${childClassName}Mapper.deleteBatchIds(CollUtil.toList(ids));
         ${childClassName}Mapper.deleteBatchIds(CollUtil.toList(ids));
         return Boolean.TRUE;
         return Boolean.TRUE;
     }
     }
-#end
 }
 }

+ 2 - 2
temps/主子表单

@@ -247,8 +247,8 @@ const deleteChild = async (obj: { $childPkName: string }) => {
 // 初始化表单数据
 // 初始化表单数据
 const get${ClassName}Data = (id: 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])
   })
   })
 };
 };
 
 

+ 2 - 3
temps/主子表格

@@ -27,10 +27,9 @@
       <el-form-item label="#if(${field.fieldComment})${field.fieldComment}#else ${field.attrName}#end" prop="${field.attrName}">
       <el-form-item label="#if(${field.fieldComment})${field.fieldComment}#else ${field.attrName}#end" prop="${field.attrName}">
             <el-radio-group v-model="state.queryForm.${field.attrName}">
             <el-radio-group v-model="state.queryForm.${field.attrName}">
       #if($field.fieldDict)
       #if($field.fieldDict)
-             <el-radio :label="item.value" v-for="(item, index) in ${field.fieldDict}" border :key="index">{{ item.label }}
-            </el-radio>
+            <el-radio :label="item.value" v-for="(item, index) in ${field.fieldDict}" border :key="index">{{ item.label }}</el-radio>
        #else
        #else
-           <el-radio label="${field.fieldComment}" border>${field.fieldComment}</el-radio>
+            <el-radio label="${field.fieldComment}" border>${field.fieldComment}</el-radio>
        #end
        #end
             </el-radio-group>
             </el-radio-group>
      </el-form-item>
      </el-form-item>

+ 0 - 4
temps/实体

@@ -11,11 +11,9 @@ import com.pig4cloud.pigx.common.core.util.TenantTable;
 #foreach($import in $importList)
 #foreach($import in $importList)
 import $import;
 import $import;
 #end
 #end
-#if($ChildClassName)
 import com.alibaba.excel.annotation.ExcelIgnore;
 import com.alibaba.excel.annotation.ExcelIgnore;
 import com.github.yulichang.annotation.EntityMapping;
 import com.github.yulichang.annotation.EntityMapping;
 import java.util.List;
 import java.util.List;
-#end
 
 
 /**
 /**
  * ${tableComment}
  * ${tableComment}
@@ -59,10 +57,8 @@ public class ${ClassName}Entity extends Model<${ClassName}Entity> {
     private $field.attrType $field.attrName;
     private $field.attrType $field.attrName;
 #end    
 #end    
 #end
 #end
-#if($ChildClassName)
     @ExcelIgnore
     @ExcelIgnore
     @TableField(exist = false)
     @TableField(exist = false)
     @EntityMapping(thisField = "$mainField", joinField = "$childField")
     @EntityMapping(thisField = "$mainField", joinField = "$childField")
     private List<${ChildClassName}Entity> ${childClassName}List;
     private List<${ChildClassName}Entity> ${childClassName}List;
-#end
 }
 }

+ 0 - 8
temps/子Mapper

@@ -1,18 +1,10 @@
 package ${package}.${moduleName}.mapper;
 package ${package}.${moduleName}.mapper;
 
 
 import com.pig4cloud.pigx.common.data.datascope.PigxBaseMapper;
 import com.pig4cloud.pigx.common.data.datascope.PigxBaseMapper;
-#if($ChildClassName)
 import ${package}.${moduleName}.entity.${ChildClassName}Entity;
 import ${package}.${moduleName}.entity.${ChildClassName}Entity;
-#else
-import ${package}.${moduleName}.entity.${ClassName}Entity;
-#end
 import org.apache.ibatis.annotations.Mapper;
 import org.apache.ibatis.annotations.Mapper;
 
 
 @Mapper
 @Mapper
-#if($ChildClassName)
 public interface ${ChildClassName}Mapper extends PigxBaseMapper<${ChildClassName}Entity> {
 public interface ${ChildClassName}Mapper extends PigxBaseMapper<${ChildClassName}Entity> {
-#else
-public interface ${ClassName}Mapper extends PigxBaseMapper<${ClassName}Entity> {
-#end
 
 
 }
 }

temps/子实体 → multiple/子实体.java


+ 7 - 7
temps/Controller

@@ -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')" )
     @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})}));
     }
     }
 
 
     /**
     /**

+ 0 - 1
temps/Mapper

@@ -7,5 +7,4 @@ import org.apache.ibatis.annotations.Mapper;
 @Mapper
 @Mapper
 public interface ${ClassName}Mapper extends PigxBaseMapper<${ClassName}Entity> {
 public interface ${ClassName}Mapper extends PigxBaseMapper<${ClassName}Entity> {
 
 
-
 }
 }

temps/Mapper.xml → single/Mapper.xml


+ 8 - 0
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> {
+
+}

+ 18 - 0
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 {
+
+}

+ 57 - 0
single/实体.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
+}

+ 2 - 2
temps/表单

@@ -200,8 +200,8 @@ const onSubmit = async () => {
 const get${className}Data = (id: string) => {
 const get${className}Data = (id: string) => {
   // 获取数据
   // 获取数据
   loading.value = true
   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(() => {
   }).finally(() => {
     loading.value = false
     loading.value = false
   })
   })

temps/表格 → single/表格.vue


+ 0 - 50
temps/api.ts

@@ -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