Browse Source

1.添加针对本项目的代码生成模块

1 14 hours ago
parent
commit
66f132ad05
39 changed files with 2131 additions and 0 deletions
  1. 16 0
      imwork-windows/imwork-silos/pom.xml
  2. 39 0
      imwork-windows/imwork-silos/src/main/java/top/imwork/window/silos/config/DbConfig.java
  3. 35 0
      imwork-windows/imwork-silos/src/main/java/top/imwork/window/silos/controller/generator/GeneratorController.java
  4. 21 0
      imwork-windows/imwork-silos/src/main/java/top/imwork/window/silos/dao/generator/BaseMapper.java
  5. 26 0
      imwork-windows/imwork-silos/src/main/java/top/imwork/window/silos/dao/generator/MySQLMapper.java
  6. 26 0
      imwork-windows/imwork-silos/src/main/java/top/imwork/window/silos/dao/generator/OracleMapper.java
  7. 15 0
      imwork-windows/imwork-silos/src/main/java/top/imwork/window/silos/dao/generator/PostgreSQLMapper.java
  8. 16 0
      imwork-windows/imwork-silos/src/main/java/top/imwork/window/silos/dao/generator/SQLServerMapper.java
  9. 82 0
      imwork-windows/imwork-silos/src/main/java/top/imwork/window/silos/entity/generator/Column.java
  10. 75 0
      imwork-windows/imwork-silos/src/main/java/top/imwork/window/silos/entity/generator/Table.java
  11. 129 0
      imwork-windows/imwork-silos/src/main/java/top/imwork/window/silos/pojo/GeneratorDTO.java
  12. 331 0
      imwork-windows/imwork-silos/src/main/java/top/imwork/window/silos/service/GeneratorService.java
  13. 42 0
      imwork-windows/imwork-silos/src/main/java/top/imwork/window/silos/utils/FreeMarkerTemplateUtils.java
  14. 85 0
      imwork-windows/imwork-silos/src/main/java/top/imwork/window/silos/utils/StringUtils.java
  15. 62 0
      imwork-windows/imwork-silos/src/main/java/top/imwork/window/silos/utils/WordUtils.java
  16. 59 0
      imwork-windows/imwork-silos/src/main/resources/db.properties
  17. 24 0
      imwork-windows/imwork-silos/src/main/resources/mapper/generator/MySQLMapper.xml
  18. 63 0
      imwork-windows/imwork-silos/src/main/resources/mapper/generator/OracleMapper.xml
  19. 37 0
      imwork-windows/imwork-silos/src/main/resources/mapper/generator/PostgreSQLMapper.xml
  20. 90 0
      imwork-windows/imwork-silos/src/main/resources/mapper/generator/SQLServerMapper.xml
  21. 23 0
      imwork-windows/imwork-silos/src/main/resources/moudle/API.ftl
  22. 26 0
      imwork-windows/imwork-silos/src/main/resources/moudle/BO.ftl
  23. 98 0
      imwork-windows/imwork-silos/src/main/resources/moudle/Controller.ftl
  24. 133 0
      imwork-windows/imwork-silos/src/main/resources/moudle/Convert.ftl
  25. 26 0
      imwork-windows/imwork-silos/src/main/resources/moudle/DTO.ftl
  26. 14 0
      imwork-windows/imwork-silos/src/main/resources/moudle/Dao.ftl
  27. 44 0
      imwork-windows/imwork-silos/src/main/resources/moudle/Dao.xml.ftl
  28. 35 0
      imwork-windows/imwork-silos/src/main/resources/moudle/Entity.ftl
  29. 67 0
      imwork-windows/imwork-silos/src/main/resources/moudle/FallBack.ftl
  30. 23 0
      imwork-windows/imwork-silos/src/main/resources/moudle/Feign.ftl
  31. 18 0
      imwork-windows/imwork-silos/src/main/resources/moudle/ListDTO.ftl
  32. 18 0
      imwork-windows/imwork-silos/src/main/resources/moudle/ListParamVO.ftl
  33. 26 0
      imwork-windows/imwork-silos/src/main/resources/moudle/ParamVO.ftl
  34. 19 0
      imwork-windows/imwork-silos/src/main/resources/moudle/ResultBO.ftl
  35. 19 0
      imwork-windows/imwork-silos/src/main/resources/moudle/ResultVO.ftl
  36. 52 0
      imwork-windows/imwork-silos/src/main/resources/moudle/Service.ftl
  37. 84 0
      imwork-windows/imwork-silos/src/main/resources/moudle/ServiceController.ftl
  38. 106 0
      imwork-windows/imwork-silos/src/main/resources/moudle/ServiceImpl.ftl
  39. 27 0
      imwork-windows/imwork-silos/src/main/resources/moudle/VO.ftl

+ 16 - 0
imwork-windows/imwork-silos/pom.xml

@@ -20,6 +20,22 @@
         <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
     </properties>
     <dependencies>
+        <dependency>
+            <groupId>commons-io</groupId>
+            <artifactId>commons-io</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>commons-configuration</groupId>
+            <artifactId>commons-configuration</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>com.alibaba</groupId>
+            <artifactId>fastjson</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.freemarker</groupId>
+            <artifactId>freemarker</artifactId>
+        </dependency>
         <dependency>
             <groupId>com.alibaba</groupId>
             <artifactId>easyexcel</artifactId>

+ 39 - 0
imwork-windows/imwork-silos/src/main/java/top/imwork/window/silos/config/DbConfig.java

@@ -0,0 +1,39 @@
+package top.imwork.window.silos.config;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.context.annotation.Primary;
+import top.imwork.commons.core.exception.BusinessException;
+import top.imwork.window.silos.dao.generator.*;
+
+@Configuration
+public class DbConfig {
+    @Value("${imwork.database}")
+    private String database;
+    @Autowired
+    private MySQLMapper mySQLMapper;
+    @Autowired
+    private OracleMapper oracleMapper;
+    @Autowired
+    private SQLServerMapper sqlServerMapper;
+    @Autowired
+    private PostgreSQLMapper postgreSQLMapper;
+
+    @Bean
+    @Primary
+    public BaseMapper getGeneratorDao(){
+        if("mysql".equalsIgnoreCase(database)){
+            return mySQLMapper;
+        }else if("oracle".equalsIgnoreCase(database)){
+            return oracleMapper;
+        }else if("sqlserver".equalsIgnoreCase(database)){
+            return sqlServerMapper;
+        }else if("postgresql".equalsIgnoreCase(database)){
+            return postgreSQLMapper;
+        }else {
+            throw new BusinessException("不支持当前数据库:" + database);
+        }
+    }
+}

+ 35 - 0
imwork-windows/imwork-silos/src/main/java/top/imwork/window/silos/controller/generator/GeneratorController.java

@@ -1,8 +1,17 @@
 package top.imwork.window.silos.controller.generator;
 
+import jakarta.servlet.http.HttpServletResponse;
+import org.apache.commons.io.IOUtils;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Controller;
 import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.ResponseBody;
+import top.imwork.commons.core.pojo.ResponseMsg;
+import top.imwork.window.silos.service.GeneratorService;
+
+import java.util.Map;
 
 /**
  * Copyright (C), 2015-2021
@@ -21,4 +30,30 @@ public class GeneratorController {
     public String index() {
         return "/generator/generator";
     }
+
+    @Autowired
+    private GeneratorService generatorService;
+
+    /**
+     * 列表
+     */
+    @ResponseBody
+    @RequestMapping("/list")
+    public ResponseMsg list(@RequestParam Map<String, Object> params){
+        return generatorService.queryList(params);
+    }
+
+    /**
+     * 生成代码
+     */
+    @RequestMapping("/generator")
+    public void generator(@RequestParam Map<String, String> params, HttpServletResponse response) throws Exception {
+        String tables = params.get("tableName");
+        byte[] data = generatorService.generatorCode(tables.split(","));
+        response.reset();
+        response.setHeader("Content-Disposition", "attachment; filename=\"imwork.zip\"");
+        response.addHeader("Content-Length", "" + data.length);
+        response.setContentType("application/octet-stream; charset=UTF-8");
+        IOUtils.write(data, response.getOutputStream());
+    }
 }

+ 21 - 0
imwork-windows/imwork-silos/src/main/java/top/imwork/window/silos/dao/generator/BaseMapper.java

@@ -0,0 +1,21 @@
+package top.imwork.window.silos.dao.generator;
+
+import java.util.List;
+import java.util.Map;
+
+/**
+ * 〈功能简述〉<br> 
+ * 〈基础接口〉
+ *
+ * @author Administrator
+ * @create 2020/4/27 0027
+ * @since 1.0.0
+ */
+public interface BaseMapper {
+
+    List<Map<String, Object>> queryList(Map<String, Object> map);
+
+    Map<String, String> queryTable(String tableName);
+
+    List<Map<String, String>> queryColumns(String tableName);
+}

+ 26 - 0
imwork-windows/imwork-silos/src/main/java/top/imwork/window/silos/dao/generator/MySQLMapper.java

@@ -0,0 +1,26 @@
+/**
+ * Copyright (C), 2015-2020
+ * FileName: MySQLMapper
+ * Author:   Administrator
+ * Date:     2020/4/27 0027 9:19
+ * Description: MySQL mapper接口
+ * History:
+ * <author>          <time>          <version>          <desc>
+ * 作者姓名           修改时间           版本号              描述
+ */
+package top.imwork.window.silos.dao.generator;
+
+import org.apache.ibatis.annotations.Mapper;
+
+/**
+ * 〈功能简述〉<br> 
+ * 〈MySQL mapper接口〉
+ *
+ * @author Administrator
+ * @create 2020/4/27 0027
+ * @since 1.0.0
+ */
+@Mapper
+public interface MySQLMapper extends BaseMapper {
+
+}

+ 26 - 0
imwork-windows/imwork-silos/src/main/java/top/imwork/window/silos/dao/generator/OracleMapper.java

@@ -0,0 +1,26 @@
+/**
+ * Copyright (C), 2015-2020
+ * FileName: OracleMapper
+ * Author:   Administrator
+ * Date:     2020/5/4 0004 19:48
+ * Description: Oracle mapper接口
+ * History:
+ * <author>          <time>          <version>          <desc>
+ * 作者姓名           修改时间           版本号              描述
+ */
+package top.imwork.window.silos.dao.generator;
+
+import org.apache.ibatis.annotations.Mapper;
+
+/**
+ * 〈功能简述〉<br> 
+ * 〈Oracle mapper接口〉
+ *
+ * @author Administrator
+ * @create 2020/5/4 0004
+ * @since 1.0.0
+ */
+@Mapper
+public interface OracleMapper extends BaseMapper {
+
+}

+ 15 - 0
imwork-windows/imwork-silos/src/main/java/top/imwork/window/silos/dao/generator/PostgreSQLMapper.java

@@ -0,0 +1,15 @@
+package top.imwork.window.silos.dao.generator;
+
+import org.apache.ibatis.annotations.Mapper;
+
+/**
+ * 〈功能简述〉<br>
+ * 〈PostgreSQL mapper接口〉
+ *
+ * @author Administrator
+ * @create 2020/5/4 0004
+ * @since 1.0.0
+ */
+@Mapper
+public interface PostgreSQLMapper extends BaseMapper {
+}

+ 16 - 0
imwork-windows/imwork-silos/src/main/java/top/imwork/window/silos/dao/generator/SQLServerMapper.java

@@ -0,0 +1,16 @@
+package top.imwork.window.silos.dao.generator;
+
+import org.apache.ibatis.annotations.Mapper;
+
+/**
+ * 〈功能简述〉<br> 
+ * 〈SQLServer mapper接口〉
+ *
+ * @author Administrator
+ * @create 2020/5/4 0004
+ * @since 1.0.0
+ */
+@Mapper
+public interface SQLServerMapper extends BaseMapper {
+
+}

+ 82 - 0
imwork-windows/imwork-silos/src/main/java/top/imwork/window/silos/entity/generator/Column.java

@@ -0,0 +1,82 @@
+package top.imwork.window.silos.entity.generator;
+
+/**
+ * 〈功能简述〉<br>
+ * 〈数据表列属性〉
+ *
+ * @author Administrator
+ * @create 2020/4/27 0027
+ * @since 1.0.0
+ */
+public class Column {
+    //列名
+    private String columnName;
+    //列名类型
+    private String dataType;
+    //列名备注
+    private String comments;
+    //属性名称(第一个字母大写),如:user_name => UserName
+    private String attrName;
+    //属性名称(第一个字母小写),如:user_name => userName
+    private String attrname;
+    //属性类型
+    private String attrType;
+    //其他属性
+    private String extra;
+
+    public String getColumnName() {
+        return columnName;
+    }
+
+    public void setColumnName(String columnName) {
+        this.columnName = columnName;
+    }
+
+    public String getDataType() {
+        return dataType;
+    }
+
+    public void setDataType(String dataType) {
+        this.dataType = dataType;
+    }
+
+    public String getComments() {
+        return comments;
+    }
+
+    public void setComments(String comments) {
+        this.comments = comments;
+    }
+
+    public String getAttrname() {
+        return attrname;
+    }
+
+    public void setAttrname(String attrname) {
+        this.attrname = attrname;
+    }
+
+    public String getAttrName() {
+        return attrName;
+    }
+
+    public void setAttrName(String attrName) {
+        this.attrName = attrName;
+    }
+
+    public String getAttrType() {
+        return attrType;
+    }
+
+    public void setAttrType(String attrType) {
+        this.attrType = attrType;
+    }
+
+    public String getExtra() {
+        return extra;
+    }
+
+    public void setExtra(String extra) {
+        this.extra = extra;
+    }
+}

+ 75 - 0
imwork-windows/imwork-silos/src/main/java/top/imwork/window/silos/entity/generator/Table.java

@@ -0,0 +1,75 @@
+package top.imwork.window.silos.entity.generator;
+
+import java.util.List;
+
+/**
+ * 〈功能简述〉<br>
+ * 〈数据表属性〉
+ *
+ * @author Administrator
+ * @create 2020/4/27 0027
+ * @since 1.0.0
+ */
+public class Table {
+    //表的名称
+    private String tableName;
+    //表的备注
+    private String comments;
+    //表的主键
+    private Column pk;
+    //表的列名(不包含主键)
+    private List<Column> columns;
+
+    //类名(第一个字母大写),如:sys_user => SysUser
+    private String className;
+    //类名(第一个字母小写),如:sys_user => sysUser
+    private String classname;
+
+    public String getTableName() {
+        return tableName;
+    }
+
+    public void setTableName(String tableName) {
+        this.tableName = tableName;
+    }
+
+    public String getComments() {
+        return comments;
+    }
+
+    public void setComments(String comments) {
+        this.comments = comments;
+    }
+
+    public Column getPk() {
+        return pk;
+    }
+
+    public void setPk(Column pk) {
+        this.pk = pk;
+    }
+
+    public List<Column> getColumns() {
+        return columns;
+    }
+
+    public void setColumns(List<Column> columns) {
+        this.columns = columns;
+    }
+
+    public String getClassName() {
+        return className;
+    }
+
+    public void setClassName(String className) {
+        this.className = className;
+    }
+
+    public String getClassname() {
+        return classname;
+    }
+
+    public void setClassname(String classname) {
+        this.classname = classname;
+    }
+}

+ 129 - 0
imwork-windows/imwork-silos/src/main/java/top/imwork/window/silos/pojo/GeneratorDTO.java

@@ -0,0 +1,129 @@
+package top.imwork.window.silos.pojo;
+
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.boot.context.properties.EnableConfigurationProperties;
+import org.springframework.context.annotation.PropertySource;
+import org.springframework.stereotype.Component;
+
+/**
+ * 〈功能简述〉<br> 
+ * 〈配置读取〉
+ *
+ * @author Administrator
+ * @create 2020/4/27 0027
+ * @since 1.0.0
+ */
+@Component
+@PropertySource({"classpath:db.properties"})
+@EnableConfigurationProperties
+public class GeneratorDTO {
+    @Value("${commonsPath}")
+    private String commonsPath;
+
+    @Value("${mainPath}")
+    private String mainPath;
+
+    @Value("${packages}")
+    private String packages;
+
+    @Value("${moduleName}")
+    private String moduleName;
+
+    @Value("${author}")
+    private String author;
+
+    @Value("${email}")
+    private String email;
+
+    @Value("${tablePrefix}")
+    private String tablePrefix;
+
+    @Value("${tinyint}")
+    private String tinyint;
+
+    @Value("${smallint}")
+    private String smallint;
+
+    @Value("${mediumint}")
+    private String mediumint;
+
+    public String getCommonsPath() {
+        return commonsPath;
+    }
+
+    public void setCommonsPath(String commonsPath) {
+        this.commonsPath = commonsPath;
+    }
+
+    public String getMainPath() {
+        return mainPath;
+    }
+
+    public void setMainPath(String mainPath) {
+        this.mainPath = mainPath;
+    }
+
+    public String getPackages() {
+        return packages;
+    }
+
+    public void setPackages(String packages) {
+        this.packages = packages;
+    }
+
+    public String getModuleName() {
+        return moduleName;
+    }
+
+    public void setModuleName(String moduleName) {
+        this.moduleName = moduleName;
+    }
+
+    public String getAuthor() {
+        return author;
+    }
+
+    public void setAuthor(String author) {
+        this.author = author;
+    }
+
+    public String getEmail() {
+        return email;
+    }
+
+    public void setEmail(String email) {
+        this.email = email;
+    }
+
+    public String getTablePrefix() {
+        return tablePrefix;
+    }
+
+    public void setTablePrefix(String tablePrefix) {
+        this.tablePrefix = tablePrefix;
+    }
+
+    public String getTinyint() {
+        return tinyint;
+    }
+
+    public void setTinyint(String tinyint) {
+        this.tinyint = tinyint;
+    }
+
+    public String getSmallint() {
+        return smallint;
+    }
+
+    public void setSmallint(String smallint) {
+        this.smallint = smallint;
+    }
+
+    public String getMediumint() {
+        return mediumint;
+    }
+
+    public void setMediumint(String mediumint) {
+        this.mediumint = mediumint;
+    }
+}

+ 331 - 0
imwork-windows/imwork-silos/src/main/java/top/imwork/window/silos/service/GeneratorService.java

@@ -0,0 +1,331 @@
+package top.imwork.window.silos.service;
+
+import com.github.pagehelper.Page;
+import com.github.pagehelper.PageHelper;
+import freemarker.template.Template;
+import org.apache.commons.configuration.Configuration;
+import org.apache.commons.configuration.ConfigurationException;
+import org.apache.commons.configuration.PropertiesConfiguration;
+import org.apache.commons.io.IOUtils;
+import org.apache.commons.lang.StringUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import top.imwork.commons.core.constants.DateConstants;
+import top.imwork.commons.core.exception.BusinessException;
+import top.imwork.commons.core.pojo.ResponseMsg;
+import top.imwork.commons.core.utils.DateUtils;
+import top.imwork.window.silos.dao.generator.BaseMapper;
+import top.imwork.window.silos.entity.generator.Column;
+import top.imwork.window.silos.entity.generator.Table;
+import top.imwork.window.silos.pojo.GeneratorDTO;
+import top.imwork.window.silos.utils.FreeMarkerTemplateUtils;
+import top.imwork.window.silos.utils.WordUtils;
+
+import java.io.ByteArrayOutputStream;
+import java.io.File;
+import java.io.StringWriter;
+import java.util.*;
+import java.util.zip.ZipEntry;
+import java.util.zip.ZipOutputStream;
+
+/**
+ * 〈功能简述〉<br>
+ * 〈〉
+ *
+ * @author Administrator
+ * @create 2020/5/10 0010
+ * @since 1.0.0
+ */
+@Service
+public class GeneratorService {
+    @Autowired
+    private GeneratorDTO generatorDTO;
+
+    @Autowired
+    private BaseMapper baseMapper;
+
+    public ResponseMsg queryList(Map<String, Object> params) {
+        Integer pages = Integer.parseInt(String.valueOf(params.get("page")));
+        Integer rows = Integer.parseInt(String.valueOf(params.get("limit")));
+
+        Page<?> page = PageHelper.startPage(pages, rows);
+        List<Map<String, Object>> list = baseMapper.queryList(params);
+
+        Map<String, Object> map = new HashMap<>();
+        map.put("code", 0);
+        map.put("count", (int) page.getTotal());
+        map.put("data", list);
+        return ResponseMsg.ok(map);
+    }
+
+    public Map<String, String> queryTable(String tableName) {
+        return baseMapper.queryTable(tableName);
+    }
+
+    public List<Map<String, String>> queryColumns(String tableName) {
+        return baseMapper.queryColumns(tableName);
+    }
+
+    public byte[] generatorCode(String[] tableNames) throws ConfigurationException {
+        ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
+        ZipOutputStream zip = new ZipOutputStream(outputStream);
+
+        for (String tableName : tableNames) {
+            //查询表信息
+            Map<String, String> table = queryTable(tableName);
+            //查询列信息
+            List<Map<String, String>> columns = queryColumns(tableName);
+            //生成代码
+            generatorCode(table, columns, zip);
+        }
+        IOUtils.closeQuietly(zip);
+        return outputStream.toByteArray();
+    }
+
+    public static List<String> getTemplates() {
+        List<String> templates = new ArrayList<String>();
+        templates.add("Entity.ftl");
+        templates.add("Dao.ftl");
+        templates.add("Dao.xml.ftl");
+        templates.add("Service.ftl");
+        templates.add("ServiceImpl.ftl");
+        templates.add("ServiceController.ftl");
+        templates.add("Feign.ftl");
+        templates.add("FallBack.ftl");
+        templates.add("VO.ftl");
+        templates.add("ResultBO.ftl");
+        templates.add("BO.ftl");
+        templates.add("DTO.ftl");
+        templates.add("ListDTO.ftl");
+        templates.add("API.ftl");
+        templates.add("ListParamVO.ftl");
+        templates.add("ParamVO.ftl");
+        templates.add("ResultVO.ftl");
+        templates.add("Convert.ftl");
+
+        return templates;
+    }
+
+    /**
+     * 获取配置信息
+     */
+    public static Configuration getConfig() throws ConfigurationException {
+        return new PropertiesConfiguration("db.properties");
+    }
+
+    /**
+     * 生成代码
+     */
+    public void generatorCode(Map<String, String> table,
+                              List<Map<String, String>> columns, ZipOutputStream zip) throws ConfigurationException {
+        //配置信息
+        Configuration config = getConfig();
+        boolean hasBigDecimal = false;
+        //表信息
+        Table tb = new Table();
+        tb.setTableName(table.get("tableName"));
+        tb.setComments(table.get("tableComment"));
+
+        //表名转换成Java类名
+        String className = tableToJava(tb.getTableName(), this.generatorDTO.getTablePrefix().split(","));
+        tb.setClassName(className);
+        tb.setClassname(StringUtils.uncapitalize(className));
+
+        //列信息
+        List<Column> columsList = new ArrayList<>();
+        for (Map<String, String> column : columns) {
+            Column columnEntity = new Column();
+            columnEntity.setColumnName(column.get("columnName"));
+            columnEntity.setDataType(column.get("dataType"));
+            columnEntity.setComments(column.get("columnComment"));
+            columnEntity.setExtra(column.get("extra"));
+
+            //列名转换成Java属性名
+            String attrName = columnToJava(columnEntity.getColumnName());
+            columnEntity.setAttrName(attrName);
+            columnEntity.setAttrname(StringUtils.uncapitalize(attrName));
+
+            //列的数据类型,转换成Java类型
+            String attrType = config.getString(columnEntity.getDataType(), "unknowType");
+            columnEntity.setAttrType(attrType);
+            if (!hasBigDecimal && attrType.equals("BigDecimal")) {
+                hasBigDecimal = true;
+            }
+            //是否主键
+            if ("PRI".equalsIgnoreCase(column.get("columnKey")) && tb.getPk() == null) {
+                tb.setPk(columnEntity);
+            }
+
+            columsList.add(columnEntity);
+        }
+        tb.setColumns(columsList);
+
+        //没主键,则第一个字段为主键
+        if (tb.getPk() == null) {
+            tb.setPk(tb.getColumns().get(0));
+        }
+
+
+        String mainPath = generatorDTO.getMainPath();
+        mainPath = StringUtils.isBlank(mainPath) ? "top.imwork" : mainPath;
+        //封装模板数据
+        Map<String, Object> map = new HashMap<>();
+        map.put("tableName", tb.getTableName());
+        map.put("comments", tb.getComments());
+        map.put("pk", tb.getPk());
+        map.put("className", tb.getClassName());
+        map.put("classname", tb.getClassname());
+        map.put("pathName", tb.getClassname().toLowerCase());
+        map.put("columns", tb.getColumns());
+        map.put("hasBigDecimal", hasBigDecimal);
+        map.put("mainPath", mainPath);
+        map.put("commonsPath", generatorDTO.getCommonsPath());
+        map.put("package", generatorDTO.getPackages());
+        map.put("moduleName", generatorDTO.getModuleName());
+        map.put("author", generatorDTO.getAuthor());
+        map.put("email", generatorDTO.getEmail());
+        map.put("datetime", DateUtils.format(new Date(), DateConstants.DATE_TIME_PATTERN));
+
+        //获取模板列表
+        List<String> templates = getTemplates();
+        for (String template : templates) {
+            try {
+                Template tl = FreeMarkerTemplateUtils.getTemplate(template);
+
+                //渲染模板
+                StringWriter sw = new StringWriter();
+                tl.process(map, sw);
+                //添加到zip
+                zip.putNextEntry(new ZipEntry(getFileName(template, tb.getClassName(), generatorDTO.getPackages(), generatorDTO.getModuleName())));
+                IOUtils.write(sw.toString(), zip, "UTF-8");
+                IOUtils.closeQuietly(sw);
+                zip.closeEntry();
+            } catch (Exception e) {
+                throw new BusinessException("渲染模板失败,表名:" + tb.getTableName(), e);
+            }
+        }
+    }
+
+    /**
+     * 列名转换成Java属性名
+     */
+    public static String columnToJava(String columnName) {
+        return WordUtils.capitalizeFully(columnName, new char[]{'_'}).replace("_", "");
+    }
+
+    /**
+     * 表名转换成Java类名
+     */
+    public static String tableToJava(String tableName, String[] tablePrefixArray) {
+        if (null != tablePrefixArray && tablePrefixArray.length > 0) {
+            for (String tablePrefix : tablePrefixArray) {
+                tableName = tableName.replace(tablePrefix, "");
+            }
+        }
+        return columnToJava(tableName);
+    }
+
+    /**
+     * 获取文件名
+     */
+    public static String getFileName(String template, String className, String packageName, String moduleName) {
+        String packagePath = "main" + File.separator + "java" + File.separator;
+        String apiPath = "main" + File.separator + "java" + File.separator;
+        if (StringUtils.isNotBlank(packageName)) {
+            packagePath += packageName.replace(".", File.separator) + File.separator + moduleName + File.separator;
+            apiPath += packageName.replace(".", File.separator) + File.separator;
+        }
+
+        if (template.equals("Entity.ftl")) {
+            return packagePath + "entity" + File.separator + className + ".java";
+        }
+
+        if (template.equals("Dao.xml.ftl")) {
+            return "main" + File.separator + "resources" + File.separator + "mapper" + File.separator + moduleName + File.separator + className + "Dao.xml";
+        }
+
+        if (template.equals("Dao.ftl")) {
+            return packagePath + "dao" + File.separator + className + "Dao.java";
+        }
+
+        if (template.equals("Service.ftl")) {
+            return packagePath + "service" + File.separator + "I" + className + "Service.java";
+        }
+
+        if (template.equals("ServiceImpl.ftl")) {
+            return packagePath + "service" + File.separator + "impl" + File.separator + className + "ServiceImpl.java";
+        }
+
+        /*if (template.contains("Controller.ftl")) {
+            return packagePath + "controller" + File.separator + className + "Controller.java";
+        }*/
+
+        if (template.equals("ServiceController.ftl")) {
+            return packagePath + "controller" + File.separator + className + "ServiceController.java";
+        }
+
+        if (template.equals("API.ftl")) {
+            return apiPath + "api" + File.separator + moduleName + File.separator + "I" + className + "ServiceApi.java";
+        }
+
+        if (template.equals("Feign.ftl")) {
+            return apiPath + "feign" + File.separator + moduleName + File.separator + "I" + className + "ServiceFeign.java";
+        }
+
+        if (template.equals("FallBack.ftl")) {
+            return apiPath + "feign" + File.separator + moduleName + File.separator + "fallback" + File.separator + className + "ServiceFeignFallbackFactory.java";
+        }
+
+        if (template.equals("VO.ftl")) {
+            return packagePath + File.separator + "pojo" + File.separator + "vo" + File.separator + className + "VO.java";
+        }
+
+        if (template.equals("ResultBO.ftl")) {
+            return packagePath + File.separator + "pojo" + File.separator + "bo" + File.separator + className + "ResultBO.java";
+        }
+
+        if (template.equals("BO.ftl")) {
+            return packagePath + File.separator + "pojo" + File.separator + "bo" + File.separator + className + "BO.java";
+        }
+
+        if (template.equals("DTO.ftl")) {
+            return packagePath + File.separator + "pojo" + File.separator + "dto" + File.separator + className + "DTO.java";
+        }
+
+        if (template.equals("ListDTO.ftl")) {
+            return packagePath + File.separator + "pojo" + File.separator + "dto" + File.separator + className + "ListDTO.java";
+        }
+
+        if (template.equals("ListParamVO.ftl")) {
+            return packagePath + File.separator + "pojo" + File.separator + "po" + File.separator + className + "ListParamVO.java";
+        }
+
+        if (template.equals("ParamVO.ftl")) {
+            return packagePath + File.separator + "pojo" + File.separator + "po" + File.separator + className + "ParamVO.java";
+        }
+
+        if (template.equals("ResultVO.ftl")) {
+            return packagePath + File.separator + "pojo" + File.separator + "vo" + File.separator + className + "ResultVO.java";
+        }
+
+        if (template.equals("Convert.ftl")) {
+            return packagePath + File.separator + "convert" + File.separator + className + "Convert.java";
+        }
+
+        /*if (template.contains("menu.sql.ftl" )) {
+            return className.toLowerCase() + "_menu.sql";
+        }
+
+        if (template.contains("index.vue.ftl" )) {
+            return "main" + File.separator + "resources" + File.separator + "src" + File.separator + "views" + File.separator + "modules" +
+                    File.separator + moduleName + File.separator + className.toLowerCase() + ".vue";
+        }
+
+        if (template.contains("add-or-update.vue.ftl" )) {
+            return "main" + File.separator + "resources" + File.separator + "src" + File.separator + "views" + File.separator + "modules" +
+                    File.separator + moduleName + File.separator + className.toLowerCase() + "-add-or-update.vue";
+        }*/
+
+        return null;
+    }
+}

+ 42 - 0
imwork-windows/imwork-silos/src/main/java/top/imwork/window/silos/utils/FreeMarkerTemplateUtils.java

@@ -0,0 +1,42 @@
+package top.imwork.window.silos.utils;
+
+import freemarker.cache.ClassTemplateLoader;
+import freemarker.cache.NullCacheStorage;
+import freemarker.template.Configuration;
+import freemarker.template.Template;
+import freemarker.template.TemplateExceptionHandler;
+
+import java.io.IOException;
+
+/**
+ * 〈功能简述〉<br> 
+ * 〈模板工具〉
+ *
+ * @author Administrator
+ * @create 2020/4/27 0027
+ * @since 1.0.0
+ */
+public class FreeMarkerTemplateUtils {
+    private FreeMarkerTemplateUtils(){}
+    private static final Configuration CONFIGURATION = new Configuration(Configuration.VERSION_2_3_22);
+
+    static{
+        //这里比较重要,用来指定加载模板所在的路径
+        CONFIGURATION.setTemplateLoader(new ClassTemplateLoader(FreeMarkerTemplateUtils.class, "/moudle"));
+        CONFIGURATION.setDefaultEncoding("UTF-8");
+        CONFIGURATION.setTemplateExceptionHandler(TemplateExceptionHandler.RETHROW_HANDLER);
+        CONFIGURATION.setCacheStorage(NullCacheStorage.INSTANCE);
+    }
+
+    public static Template getTemplate(String templateName) throws IOException {
+        try {
+            return CONFIGURATION.getTemplate(templateName);
+        } catch (IOException e) {
+            throw e;
+        }
+    }
+
+    public static void clearCache() {
+        CONFIGURATION.clearTemplateCache();
+    }
+}

+ 85 - 0
imwork-windows/imwork-silos/src/main/java/top/imwork/window/silos/utils/StringUtils.java

@@ -0,0 +1,85 @@
+package top.imwork.window.silos.utils;
+
+import java.lang.reflect.Array;
+import java.util.Collection;
+import java.util.Map;
+import java.util.Optional;
+
+/**
+ * Copyright (C), 2015-2022
+ * FileName: StringUtils
+ * Author<作者姓名>:   stars
+ * CreateTime<创建时间>:   2022/5/18 16:25
+ * UpdateTime<修改时间>:   2022/5/18 16:25
+ * Description〈功能简述〉: 字符串处理工具
+ * History<历史描述>:
+ * Since<版本号>: 1.0.0
+ */
+public class StringUtils {
+    private StringUtils() {
+        // 私有构造方法
+        throw new IllegalStateException("Utility class");
+    }
+
+    /**
+     * 判断字符串是否为空
+     *
+     * @param str 要判断的字符串
+     * @return boolean  true为空false非空
+     */
+    public static boolean isEmpty(String str) {
+        return str == null || "".equals(str.trim());
+    }
+
+    /**
+     * 判断对象是否为空
+     *
+     * @param obj 要判断的对象
+     * @return boolean  true为空false非空
+     */
+    public static boolean isEmpty(Object obj) {
+        if (obj == null) {
+            return true;
+        } else if (obj instanceof Optional) {
+            return !((Optional)obj).isPresent();
+        } else if (obj instanceof CharSequence) {
+            return ((CharSequence)obj).length() == 0;
+        } else if (obj.getClass().isArray()) {
+            return Array.getLength(obj) == 0;
+        } else if (obj instanceof Collection) {
+            return ((Collection)obj).isEmpty();
+        } else {
+            return obj instanceof Map ? ((Map)obj).isEmpty() : false;
+        }
+    }
+
+    /**
+     * 判断字符串是否不为空
+     *
+     * @param str 要判断的字符串
+     * @return boolean  true非空false空
+     */
+    public static boolean isNotEmpty(String str) {
+        return !isEmpty(str);
+    }
+
+    /**
+     * 判断字符串是否为空字符串
+     *
+     * @param str 要判断的字符串
+     * @return boolean  true空false非空
+     */
+    public static boolean isBlank(String str) {
+        return "".equals(str.trim());
+    }
+
+    /**
+     * 判断字符串是否为非空字符串
+     *
+     * @param str 要判断的字符串
+     * @return boolean  true非空false空
+     */
+    public static boolean isNotBlank(String str) {
+        return !isBlank(str);
+    }
+}

+ 62 - 0
imwork-windows/imwork-silos/src/main/java/top/imwork/window/silos/utils/WordUtils.java

@@ -0,0 +1,62 @@
+package top.imwork.window.silos.utils;
+
+/**
+ * 〈功能简述〉<br> 
+ * 〈doc工具〉
+ *
+ * @author Administrator
+ * @create 2020/4/27 0027
+ * @since 1.0.0
+ */
+public class WordUtils {
+
+    public static String capitalizeFully(String str, char... delimiters) {
+        int delimLen = delimiters == null ? -1 : delimiters.length;
+        if (!StringUtils.isEmpty(str) && delimLen != 0) {
+            str = str.toLowerCase();
+            return capitalize(str, delimiters);
+        } else {
+            return str;
+        }
+    }
+
+    public static String capitalize(String str, char... delimiters) {
+        int delimLen = delimiters == null ? -1 : delimiters.length;
+        if (!StringUtils.isEmpty(str) && delimLen != 0) {
+            char[] buffer = str.toCharArray();
+            boolean capitalizeNext = true;
+
+            for(int i = 0; i < buffer.length; ++i) {
+                char ch = buffer[i];
+                if (isDelimiter(ch, delimiters)) {
+                    capitalizeNext = true;
+                } else if (capitalizeNext) {
+                    buffer[i] = Character.toTitleCase(ch);
+                    capitalizeNext = false;
+                }
+            }
+
+            return new String(buffer);
+        } else {
+            return str;
+        }
+    }
+
+    private static boolean isDelimiter(char ch, char[] delimiters) {
+        if (delimiters == null) {
+            return Character.isWhitespace(ch);
+        } else {
+            char[] var2 = delimiters;
+            int var3 = delimiters.length;
+
+            for(int var4 = 0; var4 < var3; ++var4) {
+                char delimiter = var2[var4];
+                if (ch == delimiter) {
+                    return true;
+                }
+            }
+
+            return false;
+        }
+    }
+}

+ 59 - 0
imwork-windows/imwork-silos/src/main/resources/db.properties

@@ -0,0 +1,59 @@
+imwork.database= mysql
+
+commonsPath=top.imwork
+mainPath=top.imwork.window
+packages=top.imwork.window
+moduleName=silos
+author=jiangxiaowei
+#Email
+email=e-jiangxiaowei@outlook.com
+tablePrefix=book_
+
+tinyint=Integer
+smallint=Integer
+mediumint=Integer
+int=Integer
+integer=Integer
+bigint=Long
+float=Float
+double=Double
+decimal=BigDecimal
+bit=Boolean
+
+char=String
+varchar=String
+tinytext=String
+text=String
+mediumtext=String
+longtext=String
+
+date=Date
+datetime=Date
+timestamp=Date
+
+NUMBER=Integer
+INT=Integer
+INTEGER=Integer
+BINARY_INTEGER=Integer
+LONG=String
+FLOAT=Float
+BINARY_FLOAT=Float
+DOUBLE=Double
+BINARY_DOUBLE=Double
+DECIMAL=BigDecimal
+CHAR=String
+VARCHAR=String
+VARCHAR2=String
+NVARCHAR=String
+NVARCHAR2=String
+CLOB=String
+BLOB=String
+DATE=Date
+DATETIME=Date
+TIMESTAMP=Date
+TIMESTAMP(6)=Date
+
+int8=Long
+int4=Integer
+int2=Integer
+numeric=BigDecimal

+ 24 - 0
imwork-windows/imwork-silos/src/main/resources/mapper/generator/MySQLMapper.xml

@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+
+<mapper namespace="top.imwork.window.silos.dao.generator.MySQLMapper">
+    <select id="queryList" resultType="map">
+        select table_name tableName, engine, table_comment tableComment, create_time createTime from
+        information_schema.tables
+        where table_schema = (select database())
+        <if test="tableName != null and tableName.trim() != ''">
+            and table_name like concat('%', #{tableName}, '%')
+        </if>
+        order by create_time desc
+    </select>
+
+    <select id="queryTable" resultType="map">
+		select table_name tableName, engine, table_comment tableComment, create_time createTime from information_schema.tables
+			where table_schema = (select database()) and table_name = #{tableName}
+	</select>
+
+    <select id="queryColumns" resultType="map">
+		select column_name columnName, data_type dataType, column_comment columnComment, column_key columnKey, extra from information_schema.columns
+ 			where table_name = #{tableName} and table_schema = (select database()) order by ordinal_position
+	</select>
+</mapper>

+ 63 - 0
imwork-windows/imwork-silos/src/main/resources/mapper/generator/OracleMapper.xml

@@ -0,0 +1,63 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+
+<mapper namespace="top.imwork.window.silos.dao.generator.OracleMapper">
+	<resultMap id="tableMap" type="map">
+		<result column="TABLENAME" property="tableName"></result>
+		<result column="TABLECOMMENT" property="tableComment"></result>
+		<result column="COLUMNNAME" property="columnName"></result>
+		<result column="DATATYPE" property="dataType"></result>
+		<result column="COLUMNCOMMENT" property="columnComment"></result>
+		<result column="COLUMNKEY" property="columnKey"></result>
+		<result column="EXTRA" property="extra"></result>
+		<result column="CREATETIME" property="createTime"></result>
+	</resultMap>
+
+	<select id="queryList" resultMap="tableMap">
+		select dt.table_name tableName,
+		dtc.comments tableComment,
+		uo.created createTime
+		from user_tables dt,
+		user_tab_comments dtc,
+		user_objects uo
+		where dt.table_name = dtc.table_name and dt.table_name = uo.object_name and uo.object_type='TABLE'
+		<if test="tableName != null and tableName.trim() != ''">
+			and dt.table_name like concat('%', UPPER(#{tableName}))
+		</if>
+		order by uo.CREATED desc
+	</select>
+
+	<select id="queryTable" resultMap="tableMap">
+		select dt.table_name tableName,dtc.comments tableComment,dt.last_analyzed createTime from user_tables dt,user_tab_comments dtc where dt.table_name=dtc.table_name and dt.table_name = UPPER(#{tableName})
+	</select>
+
+	<select id="queryColumns" resultMap="tableMap">
+        select temp.column_name columnname,
+        temp.data_type dataType,
+        temp.comments columnComment,
+        case temp.constraint_type when 'P' then 'PRI' when 'C' then 'UNI' else '' end "COLUMNKEY",
+        '' "EXTRA"
+        from (
+        select col.column_id,
+        col.column_name,
+        col.data_type,
+        colc.comments,
+        uc.constraint_type,
+        -- 去重
+        row_number() over (partition by col.column_name order by uc.constraint_type desc) as row_flg
+        from user_tab_columns col
+        left join user_col_comments colc
+        on colc.table_name = col.table_name
+        and colc.column_name = col.column_name
+        left join user_cons_columns ucc
+        on ucc.table_name = col.table_name
+        and ucc.column_name = col.column_name
+        left join user_constraints uc
+        on uc.constraint_name = ucc.constraint_name
+        where col.table_name = upper(#{tableName})
+        ) temp
+        where temp.row_flg = 1
+        order by temp.column_id
+	</select>
+
+</mapper>

+ 37 - 0
imwork-windows/imwork-silos/src/main/resources/mapper/generator/PostgreSQLMapper.xml

@@ -0,0 +1,37 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+
+<mapper namespace="top.imwork.window.silos.dao.generator.PostgreSQLMapper">
+	<resultMap id="tableMap" type="map">
+		<result column="tablename" property="tableName"></result>
+		<result column="tablecomment" property="tableComment"></result>
+		<result column="columnname" property="columnName"></result>
+		<result column="datatype" property="dataType"></result>
+		<result column="columncomment" property="columnComment"></result>
+		<result column="columnkey" property="columnKey"></result>
+		<result column="extra" property="extra"></result>
+		<result column="createtime" property="createTime"></result>
+	</resultMap>
+
+	<select id="queryList" resultMap="tableMap">
+		select t1.tablename as tableName, obj_description(relfilenode, 'pg_class') as tableComment, now() as createTime from pg_tables t1, pg_class t2
+		where t1.tablename not like 'pg%' and t1.tablename not like 'sql_%' and t1.tablename = t2.relname
+		<if test="tableName != null and tableName.trim() != ''">
+			and t1.tablename like concat('%', #{tableName}, '%')
+		</if>
+		order by t1.tablename desc
+	</select>
+
+	<select id="queryTable" resultMap="tableMap">
+		select t1.tablename as tableName, obj_description(relfilenode, 'pg_class') as tableComment, now() as createTime from pg_tables t1, pg_class t2
+			where t1.tablename = #{tableName} and t1.tablename = t2.relname
+	</select>
+
+	<select id="queryColumns" resultMap="tableMap">
+ 		select t2.attname as columnName, pg_type.typname as dataType, col_description(t2.attrelid,t2.attnum) as columnComment, '' as extra,
+			(CASE t3.contype WHEN 'p' THEN 'PRI' ELSE '' END) as columnKey
+		from pg_class as t1, pg_attribute as t2 inner join pg_type on pg_type.oid = t2.atttypid
+			left join pg_constraint t3 on t2.attnum = t3.conkey[1] and t2.attrelid = t3.conrelid
+		where t1.relname = #{tableName} and t2.attrelid = t1.oid and t2.attnum>0
+	</select>
+</mapper>

+ 90 - 0
imwork-windows/imwork-silos/src/main/resources/mapper/generator/SQLServerMapper.xml

@@ -0,0 +1,90 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+
+<mapper namespace="top.imwork.window.silos.dao.generator.SQLServerMapper">
+	<select id="queryList" resultType="map">
+		select * from
+		(
+		select cast(so.name as varchar(500)) as tableName, cast(sep.value as varchar(500)) as tableComment, getDate() as createTime
+		from sysobjects so
+		left JOIN sys.extended_properties sep
+		on sep.major_id=so.id and sep.minor_id=0
+		where (xtype='U' or xtype='v')
+		) t where 1=1
+		<if test="tableName != null and tableName.trim() != ''">
+			and t.tableName like concat('%', #{tableName}, '%')
+		</if>
+		order by t.tableName
+	</select>
+
+	<select id="queryTable" resultType="map">
+		select * from (
+			select cast(so.name as varchar(500)) as tableName, 'mssql' as engine,cast(sep.value as varchar(500)) as tableComment, getDate() as createTime
+			from sysobjects so
+			left JOIN sys.extended_properties sep on sep.major_id=so.id and sep.minor_id=0
+			where (xtype='U' or xtype='v')
+		) t where t.tableName=#{tableName}
+	</select>
+
+	<select id="queryColumns" resultType="map">
+		SELECT
+		cast(
+			b.NAME AS VARCHAR(500)
+		) AS columnName,
+		cast(
+			sys.types.NAME AS VARCHAR(500)
+		) AS dataType,
+		cast(
+			c.VALUE AS VARCHAR(500)
+		) AS columnComment,
+		(
+			SELECT
+				CASE
+					count( 1 )
+					WHEN 1 then 'PRI'
+					ELSE ''
+				END
+			FROM
+				syscolumns,
+				sysobjects,
+				sysindexes,
+				sysindexkeys,
+				systypes
+			WHERE
+				syscolumns.xusertype = systypes.xusertype
+				AND syscolumns.id = object_id(A.NAME)
+				AND sysobjects.xtype = 'PK'
+				AND sysobjects.parent_obj = syscolumns.id
+				AND sysindexes.id = syscolumns.id
+				AND sysobjects.NAME = sysindexes.NAME
+				AND sysindexkeys.id = syscolumns.id
+				AND sysindexkeys.indid = sysindexes.indid
+				AND syscolumns.colid = sysindexkeys.colid
+				AND syscolumns.NAME = B.NAME
+			) as columnKey,
+			'' as extra
+		FROM
+			(
+				select
+					name,
+					object_id
+				from
+					sys.tables
+			UNION all select
+					name,
+					object_id
+				from
+					sys.views
+			) a
+		INNER JOIN sys.COLUMNS b ON
+			b.object_id = a.object_id
+		LEFT JOIN sys.types ON
+			b.user_type_id = sys.types.user_type_id
+		LEFT JOIN sys.extended_properties c ON
+			c.major_id = b.object_id
+			AND c.minor_id = b.column_id
+		WHERE
+			a.NAME = #{tableName}
+			and sys.types.NAME != 'sysname'
+	</select>
+</mapper>

+ 23 - 0
imwork-windows/imwork-silos/src/main/resources/moudle/API.ftl

@@ -0,0 +1,23 @@
+package ${package}.api.${moduleName};
+
+import ${package}.commons.base.pojo.ResponseMsg;
+import org.springframework.cloud.openfeign.FeignClient;
+import ${package}.commons.core.base.BaseApi;
+import ${package}.${moduleName}.pojo.po.${className}ListParamVO;
+import ${package}.${moduleName}.pojo.po.${className}ParamVO;
+
+/**
+ * 〈功能简述〉
+ * ${comments}
+ * fallback与fallbackFactory同时使用只有fallback生效
+ * 建议使用fallbackFactory
+ *
+ * @author ${author}
+ * email: ${email}
+ * date: ${datetime}
+ * @since 1.0.0
+ */
+@FeignClient(contextId = "${moduleName}-${classname}",value = "imwork-${moduleName}-service" ,path = "/${moduleName}/${classname}")
+public interface I${className}ServiceApi extends BaseApi<ResponseMsg, ${className}ParamVO, ${className}ListParamVO> {
+
+}

+ 26 - 0
imwork-windows/imwork-silos/src/main/resources/moudle/BO.ftl

@@ -0,0 +1,26 @@
+package ${package}.${moduleName}.pojo.bo;
+
+import lombok.Data;
+
+import java.io.Serial;
+import java.io.Serializable;
+import java.util.Date;
+
+/**
+ * ${comments}
+ *
+ * @author ${author}
+ * email: ${email}
+ * date: ${datetime}
+ */
+@Data
+public class ${className}BO implements Serializable {
+    @Serial
+    private static final long serialVersionUID = 1L;
+<#list columns as column>
+    /**
+     * ${column.comments}
+     */
+    private ${column.attrType} ${column.attrname};
+</#list>
+}

+ 98 - 0
imwork-windows/imwork-silos/src/main/resources/moudle/Controller.ftl

@@ -0,0 +1,98 @@
+package ${package}.${moduleName}.controller;
+
+import org.apache.dubbo.config.annotation.Reference;
+import io.swagger.annotations.*;
+import org.springframework.validation.annotation.Validated;
+import org.springframework.web.bind.annotation.*;
+
+import java.util.Map;
+
+import ${mainPath}.commons.core.base.BaseController;
+import ${mainPath}.commons.core.pojo.vo.ResponseMsg;
+import ${mainPath}.commons.core.pojo.dto.DeleteByIdsDTO;
+
+import ${package}.feign.${moduleName}.I${className}ServiceFeign;
+import ${package}.api.${moduleName}.I${className}ServiceApi;
+
+import ${package}.${moduleName}.entity.${className};
+import ${package}.${moduleName}.pojo.vo.${className}VO;
+import ${package}.${moduleName}.pojo.ao.${className}ListAO;
+
+/**
+ * ${comments}
+ *
+ * @author ${author}
+ * @email ${email}
+ * @date ${datetime}
+ */
+@RestController
+@RequestMapping("/${moduleName}/${pathName}")
+public class ${className}Controller extends BaseController implements I${className}ServiceFeign{
+
+    @Reference
+    I${className}ServiceApi ${classname}ServiceApi;
+
+    /**
+     * 根据id查询数据
+     * @param id long类型的id
+     * @return 返回查询结果
+     */
+    @ApiOperation(value = "根据id查询数据详情", httpMethod = "GET")
+    @ApiResponses(value = {@ApiResponse(code = 200, response = ${className}VO.class, message = "调用成功")})
+    @GetMapping("/info/{${pk.attrname}}")
+    @Override
+    public ResponseMsg info(@PathVariable("${pk.attrname}") ${pk.attrType} ${pk.attrname}){
+        ${className} ${classname} = ${classname}ServiceApi.info(${pk.attrname});
+        return ResponseMsg.ok().put("data", ${classname});
+    }
+
+    /**
+     * 分页查询${comments}
+     */
+    @ApiOperation(value = "分页查询${comments}", httpMethod = "GET")
+    @ApiResponses(value = {@ApiResponse(code = 200, response = ${className}VO.class, message = "调用成功")})
+    @GetMapping("/list")
+    @Override
+    public ResponseMsg list(@Validated @RequestBody ${className}ListAO ${classname}ListAO){
+        Map<String, Object> resultMap = ${classname}ServiceApi.list(${classname}ListAO);
+        return ResponseMsg.ok().put("data", resultMap);
+    }
+
+    /**
+     * 新增/修改info
+     * @param ${classname} 实体信息
+     * @return responseMsg 操作结果
+     */
+    @ApiOperation(value = "新增/修改${comments}", httpMethod = "POST")
+    @ApiResponses(value = {@ApiResponse(code = 200, response = ResponseMsg.class, message = "调用成功")})
+    @PostMapping("/save")
+    @Override
+    public ResponseMsg save(@RequestBody ${className} ${classname}){
+        return Boolean.TRUE.equals(${classname}ServiceApi.save(${classname})) ? ResponseMsg.ok() : ResponseMsg.fail("保存失败!");
+    }
+
+    /**
+     * 根据id删除${comments}
+     * @param id id
+     * @return responseMsg 操作结果
+     */
+    @ApiOperation(value = "根据id软删除${comments}", httpMethod = "DELETE")
+    @ApiResponses(value = {@ApiResponse(code = 200, response = ResponseMsg.class, message = "调用成功")})
+    @DeleteMapping("/delete/{id}")
+    @Override
+    public ResponseMsg delete(@PathVariable("id") Long id){
+        return Boolean.TRUE.equals(${classname}ServiceApi.delete(id)) ? ResponseMsg.ok() : ResponseMsg.fail();
+    }
+
+    /**
+     * 根据传入的对象删除
+     */
+    @ApiOperation(value = "根据传入的对象删除${comments}", httpMethod = "DELETE")
+    @ApiResponses(value = {@ApiResponse(code = 200, response = ResponseMsg.class, message = "调用成功")})
+    @DeleteMapping("/deleteByIds")
+    @Override
+    public ResponseMsg deleteByIds(@RequestBody DeleteByIdsDTO dto){
+        int num = ${classname}ServiceApi.deleteByIds(dto.getIds());
+        return num > 0 ? ResponseMsg.ok("操作成功,受影响的记录有" + num + "条!") : ResponseMsg.fail("删除失败");
+    }
+}

+ 133 - 0
imwork-windows/imwork-silos/src/main/resources/moudle/Convert.ftl

@@ -0,0 +1,133 @@
+package ${package}.${moduleName}.convert;
+
+import org.springframework.util.ObjectUtils;
+import ${package}.${moduleName}.entity.${className};
+import ${package}.${moduleName}.pojo.bo.${className}BO;
+import ${package}.${moduleName}.pojo.bo.${className}ResultBO;
+import ${package}.${moduleName}.pojo.dto.${className}ListDTO;
+import ${package}.${moduleName}.pojo.po.${className}ListParamVO;
+import ${package}.${moduleName}.pojo.po.${className}ParamVO;
+import ${package}.${moduleName}.pojo.vo.${className}ResultVO;
+import ${package}.${moduleName}.pojo.vo.${className}VO;
+import ${package}.${moduleName}.pojo.dto.${className}DTO;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * ${comments}
+ * 实体转换
+ *
+ * @author ${author}
+ * email: ${email}
+ * date: ${datetime}
+ */
+public class ${className}Convert {
+    private ${className}Convert() {}
+
+    public static ${className} ${classname}DtoToDo(${className}DTO ${classname}DTO) {
+        if (${classname}DTO == null) {
+            return new ${className}();
+        }
+        ${className} ${classname} = new ${className}();
+        return ${classname};
+    }
+
+    public static ${className}BO ${classname}DoToBo(${className} ${classname}) {
+       if (${classname} == null) {
+           return new ${className}BO();
+       }
+       ${className}BO ${classname}BO = new ${className}BO();
+       return ${classname}BO;
+    }
+
+    public static ${className}DTO ${classname}ParamVoToDto(${className}ParamVO ${classname}ParamVO) {
+        if (${classname}ParamVO == null) {
+            return new ${className}DTO();
+        }
+        ${className}DTO ${classname}DTO = new ${className}DTO();
+        return ${classname}DTO;
+    }
+
+    public static List<${className}BO> ${classname}ListTo${className}BOList(List<${className}> records) {
+         if (ObjectUtils.isEmpty(records)) {
+             return new ArrayList<>();
+         }
+         List<${className}BO> ${classname}BOList = new ArrayList<>();
+         for (${className} ${classname} : records) {
+             ${classname}BOList.add(${classname}DoToBo(${classname}));
+         }
+         return ${classname}BOList;
+    }
+
+    public static ${className}VO ${classname}BoToVo(${className}BO ${classname}BO) {
+         if (${classname}BO == null) {
+         return new ${className}VO();
+         }
+         ${className}VO ${classname}VO = new ${className}VO();
+         return ${classname}VO;
+    }
+
+    public static ${className}ListDTO ${classname}ListParamVoToDTO(${className}ListParamVO ${classname}ListParamVO) {
+        if (${classname}ListParamVO == null) {
+            return new ${className}ListDTO();
+        }
+        ${className}ListDTO ${classname}ListDTO = new ${className}ListDTO();
+        ${classname}ListDTO.set${className}Name(${classname}ListParamVO.get${className}Name());
+        ${classname}ListDTO.setPageNo(${classname}ListParamVO.getPageNo());
+        ${classname}ListDTO.setPageRows(${classname}ListParamVO.getPageRows());
+        ${classname}ListDTO.setDelFlag(${classname}ListParamVO.getDelFlag());
+        ${classname}ListDTO.setCreator(${classname}ListParamVO.getCreator());
+        ${classname}ListDTO.setCreateBeginTime(${classname}ListParamVO.getCreateBeginTime());
+        ${classname}ListDTO.setCreateEndTime(${classname}ListParamVO.getCreateEndTime());
+        ${classname}ListDTO.setModifier(${classname}ListParamVO.getModifier());
+        ${classname}ListDTO.setUpdateBeginTime(${classname}ListParamVO.getUpdateBeginTime());
+        ${classname}ListDTO.setUpdateEndTime(${classname}ListParamVO.getUpdateEndTime());
+        ${classname}ListDTO.setRemark(${classname}ListParamVO.getRemark());
+        return ${classname}ListDTO;
+    }
+        
+    public static ${className}ListParamVO ${classname}ListParamDtoToVo(${className}ListDTO ${classname}ListDTO) {
+        if (${classname}ListDTO == null) {
+            return new ${className}ListParamVO();
+        }
+        ${className}ListParamVO ${classname}ListParamVO = new ${className}ListParamVO();
+        ${classname}ListParamVO.set${className}Name(${classname}ListDTO.get${className}Name());
+        ${classname}ListParamVO.setPageNo(${classname}ListDTO.getPageNo());
+        ${classname}ListParamVO.setPageRows(${classname}ListDTO.getPageRows());
+        ${classname}ListParamVO.setDelFlag(${classname}ListDTO.getDelFlag());
+        ${classname}ListParamVO.setCreator(${classname}ListDTO.getCreator());
+        ${classname}ListParamVO.setCreateBeginTime(${classname}ListDTO.getCreateBeginTime());
+        ${classname}ListParamVO.setCreateEndTime(${classname}ListDTO.getCreateEndTime());
+        ${classname}ListParamVO.setModifier(${classname}ListDTO.getModifier());
+        ${classname}ListParamVO.setUpdateBeginTime(${classname}ListDTO.getUpdateBeginTime());
+        ${classname}ListParamVO.setUpdateEndTime(${classname}ListDTO.getUpdateEndTime());
+        ${classname}ListParamVO.setRemark(${classname}ListDTO.getRemark());
+        return ${classname}ListParamVO;
+    }
+
+    private static List<${className}VO> ${classname}BoListTo${className}VoList(List<${className}BO> dataList) {
+        if (ObjectUtils.isEmpty(dataList)) {
+            return new ArrayList<>();
+        }
+        List<${className}VO> ${classname}VOList = new ArrayList<>();
+        for (${className}BO ${classname}BO : dataList) {
+             ${classname}VOList.add(${classname}BoToVo(${classname}BO));
+        }
+        return ${classname}VOList;
+    }
+
+    public static ${className}ResultVO ${classname}ResultBoToVo(${className}ResultBO ${classname}ResultBO) {
+        if (${classname}ResultBO == null) {
+            return new ${className}ResultVO();
+        }
+        ${className}ResultVO ${classname}ResultVO = new ${className}ResultVO();
+        ${classname}ResultVO.setPageNo(${classname}ResultBO.getPageNo());
+        ${classname}ResultVO.setPageRows(${classname}ResultBO.getPageRows());
+        ${classname}ResultVO.setPageCount(${classname}ResultBO.getPageCount());
+        ${classname}ResultVO.setTotalRows(${classname}ResultBO.getTotalRows());
+        ${classname}ResultVO.setDataList(${classname}BoListTo${className}VoList(${classname}ResultBO.getDataList()));
+        ${classname}ResultVO.setParams(${classname}ListParamDtoToVo(${classname}ResultBO.getParams()));
+        return ${classname}ResultVO;
+    }
+}

+ 26 - 0
imwork-windows/imwork-silos/src/main/resources/moudle/DTO.ftl

@@ -0,0 +1,26 @@
+package ${package}.${moduleName}.pojo.dto;
+
+import lombok.Data;
+
+import java.io.Serial;
+import java.io.Serializable;
+import java.util.Date;
+
+/**
+ * ${comments}
+ *
+ * @author ${author}
+ * email: ${email}
+ * date: ${datetime}
+ */
+@Data
+public class ${className}DTO implements Serializable {
+    @Serial
+    private static final long serialVersionUID = 1L;
+<#list columns as column>
+    /**
+     * ${column.comments}
+     */
+    private ${column.attrType} ${column.attrname};
+</#list>
+}

+ 14 - 0
imwork-windows/imwork-silos/src/main/resources/moudle/Dao.ftl

@@ -0,0 +1,14 @@
+package ${package}.${moduleName}.dao;
+
+import ${commonsPath}.commons.dao.base.BaseDao;
+import ${package}.${moduleName}.entity.${className};
+
+/**
+ * ${comments}
+ *
+ * @author ${author}
+ * email: ${email}
+ * date: ${datetime}
+ */
+public interface ${className}Dao extends BaseDao<${className}> {
+}

+ 44 - 0
imwork-windows/imwork-silos/src/main/resources/moudle/Dao.xml.ftl

@@ -0,0 +1,44 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+
+<mapper namespace="${package}.${moduleName}.dao.${className}Dao">
+    <resultMap type="${package}.${moduleName}.entity.${className}" id="BaseResultMap">
+        <#list columns as column>
+            <result property="${column.attrname}" column="${column.columnName}"/>
+        </#list>
+    </resultMap>
+
+    <sql id="Base_Column_List">
+    <#list columns as column>
+    <#if (column_has_next)>
+        ${column.columnName},
+    <#else>
+        ${column.columnName}
+    </#if>
+    </#list>
+    </sql>
+
+    <!--根据ids批量删除-->
+    <update id="deleteByIds" parameterType="ArrayList">
+        update ${tableName}
+        set del_flag = 'Y'
+        where id in
+        <foreach item="ids" collection="array" open="(" separator=","  close=")">
+            <#noparse>#{</#noparse>ids<#noparse>}</#noparse>
+        </foreach>
+    </update>
+
+    <!--根据id查询信息-->
+    <select id="info" resultMap="BaseResultMap" parameterType="long">
+        select *
+        from ${tableName}
+        where 1 = 1
+        and id = <#noparse>#{id}</#noparse>
+    </select>
+
+    <!--分页查询-->
+    <select id="queryPage" resultType="${package}.${moduleName}.entity.${className}">
+        select *
+        from ${tableName} <#noparse>${ew.customSqlSegment}</#noparse>
+    </select>
+</mapper>

+ 35 - 0
imwork-windows/imwork-silos/src/main/resources/moudle/Entity.ftl

@@ -0,0 +1,35 @@
+package ${package}.${moduleName}.entity;
+
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+
+<#if hasBigDecimal>
+import java.math.BigDecimal;
+</#if>
+import java.io.Serial;
+import java.io.Serializable;
+import java.util.Date;
+import lombok.Data;
+
+/**
+ * ${comments}
+ *
+ * @author ${author}
+ * email: ${email}
+ * date: ${datetime}
+ */
+@Data
+@TableName("${tableName}")
+public class ${className} implements Serializable {
+    @Serial
+    private static final long serialVersionUID = 1L;
+<#list columns as column>
+    /**
+     * ${column.comments}
+     */
+    <#if column.columnName == pk.columnName>
+    @TableId
+    </#if>
+    private ${column.attrType} ${column.attrname};
+</#list>
+}

+ 67 - 0
imwork-windows/imwork-silos/src/main/resources/moudle/FallBack.ftl

@@ -0,0 +1,67 @@
+package ${package}.feign.${moduleName}.fallback;
+
+import feign.hystrix.FallbackFactory;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.stereotype.Component;
+import ${package}.commons.core.vo.ResponseMsg;
+import ${package}.feign.${moduleName}.I${className}ServiceFeign;
+import ${package}.${moduleName}.entity.${className};
+
+import java.util.Map;
+
+/**
+ * 〈功能简述〉
+ * ${comments}
+ * fallbackFactory实现
+ *
+ * @author ${author}
+ * @email ${email}
+ * @create ${datetime}
+ * @since 1.0.0
+ */
+@Component
+public class ${className}ServiceFeignFallbackFactory implements FallbackFactory<I${className}ServiceFeign> {
+    private Logger logger = LoggerFactory.getLogger(${className}ServiceFeignFallbackFactory.class);
+
+    @Override
+    public I${className}ServiceFeign create(Throwable throwable) {
+        logger.error("fallback reason:{}",throwable.getMessage());
+        return new I${className}ServiceFeign(){
+            @Override
+            public ResponseMsg info(Long id) {
+                return null;
+            }
+
+            @Override
+            public ResponseMsg insert(${className} ${classname}) {
+                return null;
+            }
+
+            @Override
+            public ResponseMsg save(${className} ${classname}) {
+                return null;
+            }
+
+            @Override
+            public ResponseMsg update(${className} ${classname}) {
+                return null;
+            }
+
+            @Override
+            public ResponseMsg delete(Long id) {
+                return null;
+            }
+
+            @Override
+            public ResponseMsg deleteByIds(Boolean flag, String[] ids) {
+                return null;
+            }
+
+            @Override
+            public ResponseMsg list(Map params) {
+                return null;
+            }
+        };
+    }
+}

+ 23 - 0
imwork-windows/imwork-silos/src/main/resources/moudle/Feign.ftl

@@ -0,0 +1,23 @@
+package ${package}.feign.${moduleName};
+
+import org.springframework.cloud.openfeign.FeignClient;
+
+import ${package}.commons.core.base.BaseFeign;
+import ${package}.${moduleName}.entity.${className};
+import ${package}.${moduleName}.pojo.ao.${className}ListAO;
+
+/**
+ * 〈功能简述〉
+ * ${comments}
+ *
+ * fallback与fallbackFactory同时使用只有fallback生效
+ * 建议使用fallbackFactory
+ *
+ * @author ${author}
+ * @email ${email}
+ * @create ${datetime}
+ * @since 1.0.0
+ */
+@FeignClient(contextId = "${moduleName}-${classname}",value = "imwork-${moduleName}-client" ,path = "/${moduleName}/${classname}")
+public interface I${className}ServiceFeign extends BaseFeign<${className}, ${className}ListAO> {
+}

+ 18 - 0
imwork-windows/imwork-silos/src/main/resources/moudle/ListDTO.ftl

@@ -0,0 +1,18 @@
+package ${package}.${moduleName}.pojo.dto;
+
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import ${package}.commons.base.pojo.BaseParams;
+
+/**
+ * ${comments}
+ *
+ * @author ${author}
+ * email: ${email}
+ * date: ${datetime}
+ */
+@EqualsAndHashCode(callSuper = true)
+@Data
+public class ${className}ListDTO extends BaseParams {
+    private String ${classname}Name;
+}

+ 18 - 0
imwork-windows/imwork-silos/src/main/resources/moudle/ListParamVO.ftl

@@ -0,0 +1,18 @@
+package ${package}.${moduleName}.pojo.po;
+
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import ${package}.commons.base.pojo.BaseParams;
+
+/**
+ * ${comments}
+ *
+ * @author ${author}
+ * email: ${email}
+ * date: ${datetime}
+ */
+@EqualsAndHashCode(callSuper = true)
+@Data
+public class ${className}ListParamVO extends BaseParams {
+    private String ${className}Name;
+}

+ 26 - 0
imwork-windows/imwork-silos/src/main/resources/moudle/ParamVO.ftl

@@ -0,0 +1,26 @@
+package ${package}.${moduleName}.pojo.po;
+
+import lombok.Data;
+
+import java.io.Serial;
+import java.io.Serializable;
+import java.util.Date;
+
+/**
+ * ${comments}
+ *
+ * @author ${author}
+ * email: ${email}
+ * date: ${datetime}
+ */
+@Data
+public class ${className}ParamVO implements Serializable {
+    @Serial
+    private static final long serialVersionUID = 1L;
+<#list columns as column>
+    /**
+     * ${column.comments}
+     */
+    private ${column.attrType} ${column.attrname};
+</#list>
+}

+ 19 - 0
imwork-windows/imwork-silos/src/main/resources/moudle/ResultBO.ftl

@@ -0,0 +1,19 @@
+package ${package}.${moduleName}.pojo.bo;
+
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import ${package}.commons.base.pojo.BaseResult;
+import ${package}.${moduleName}.pojo.dto.${className}ListDTO;
+
+/**
+ * ${comments}
+ *
+ * @author ${author}
+ * email: ${email}
+ * date: ${datetime}
+ */
+@EqualsAndHashCode(callSuper = true)
+@Data
+public class ${className}ResultBO extends BaseResult<${className}BO, ${className}ListDTO>{
+
+}

+ 19 - 0
imwork-windows/imwork-silos/src/main/resources/moudle/ResultVO.ftl

@@ -0,0 +1,19 @@
+package ${package}.${moduleName}.pojo.vo;
+
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import ${package}.commons.base.pojo.BaseResult;
+import ${package}.${moduleName}.pojo.po.${className}ListParamVO;
+
+/**
+ * ${comments}
+ *
+ * @author ${author}
+ * email: ${email}
+ * date: ${datetime}
+ */
+@EqualsAndHashCode(callSuper = true)
+@Data
+public class ${className}ResultVO extends BaseResult<${className}VO, ${className}ListParamVO>{
+
+}

+ 52 - 0
imwork-windows/imwork-silos/src/main/resources/moudle/Service.ftl

@@ -0,0 +1,52 @@
+package ${package}.${moduleName}.service;
+
+import ${package}.${moduleName}.pojo.bo.${className}BO;
+import ${package}.${moduleName}.pojo.bo.${className}ResultBO;
+import ${package}.${moduleName}.pojo.dto.${className}ListDTO;
+import ${package}.${moduleName}.pojo.dto.${className}DTO;
+
+/**
+ * ${comments}
+ *
+ * @author ${author}
+ * email: ${email}
+ * date: ${datetime}
+ */
+public interface I${className}Service{
+
+    /**
+     * 根据${comments}id获取${comments}详情
+     * @param id ${comments}id
+     * @return ${className}BO ${comments}详情
+     */
+    ${className}BO info(Long id);
+
+    /**
+     * 新增/修改 信息
+     * @param ${classname}DTO 要保存的信息
+     * @return ${className}BO 保存后的信息
+     */
+    ${className}BO save(${className}DTO ${classname}DTO);
+
+    /**
+     * 根据id删除信息
+     * @param id id
+     * @return true/false 是否删除成功
+     */
+    Boolean delete(Long id);
+
+    /**
+     * 根据ids删除信息
+     * @param ids ids
+     * @return true/false 是否删除成功
+     */
+    Boolean deleteByIds(String[] ids);
+
+    /**
+     * 分页查询信息
+     * @param ${classname}ListDTO 分页信息
+     * @return ${className}ResultBO 查询结果
+     */
+    ${className}ResultBO queryPage(${className}ListDTO ${classname}ListDTO);
+}
+

+ 84 - 0
imwork-windows/imwork-silos/src/main/resources/moudle/ServiceController.ftl

@@ -0,0 +1,84 @@
+package ${package}.${moduleName}.controller;
+
+import jakarta.annotation.Resource;
+import jakarta.validation.Valid;
+import org.springframework.web.bind.annotation.*;
+
+import ${package}.api.${moduleName}.I${className}ServiceApi;
+import ${package}.commons.base.pojo.ResponseMsg;
+import ${package}.commons.base.pojo.DeleteParams;
+import ${package}.${moduleName}.convert.${className}Convert;
+import ${package}.${moduleName}.pojo.bo.${className}BO;
+import ${package}.${moduleName}.pojo.bo.${className}ResultBO;
+import ${package}.${moduleName}.pojo.po.${className}ListParamVO;
+import ${package}.${moduleName}.pojo.po.${className}ParamVO;
+import ${package}.${moduleName}.service.I${className}Service;
+
+/**
+ * ${comments}
+ *
+ * @author ${author}
+ * email: ${email}
+ * date: ${datetime}
+ */
+@RestController
+@RequestMapping("/${pathName}")
+public class ${className}ServiceController extends BaseServiceController implements I${className}ServiceApi{
+
+    @Resource
+    public I${className}Service ${classname}Service;
+
+    /**
+     * 根据id查询数据
+     * @param id long类型的id
+     * @return 返回查询结果
+     */
+    @GetMapping("/info/{${pk.attrname}}")
+    @Override
+    public ResponseMsg info(@PathVariable("${pk.attrname}") ${pk.attrType} ${pk.attrname}){
+        return ResponseMsg.buildResponse(${classname}Service.info(${pk.attrname}));
+    }
+
+    /**
+     * 新增/修改info
+     * @param ${classname}ParamVO 实体信息
+     * @return responseMsg 操作结果
+     */
+    @PostMapping("/save")
+    @Override
+    public ResponseMsg save(@RequestBody @Valid ${className}ParamVO ${classname}ParamVO){
+        ${className}BO ${classname}BO = ${classname}Service.save(${className}Convert.${classname}ParamVoToDto(${classname}ParamVO));
+        return ResponseMsg.buildResponse(${className}Convert.${classname}BoToVo(${classname}BO));
+    }
+
+    /**
+     * 根据id删除${comments}
+     * @param id id
+     * @return true/false 成功/失败
+     */
+    @DeleteMapping("/delete/{id}")
+    @Override
+    public ResponseMsg delete(@PathVariable("id") Long id){
+        return ${classname}Service.delete(id)? ResponseMsg.ok() : ResponseMsg.fail();
+    }
+
+    /**
+     * 批量逻辑删除信息
+     *
+     * @param dto 删除条件
+     * @return true/false 是否删除成功
+     */
+    @DeleteMapping("/deleteByIds")
+    @Override
+    public ResponseMsg deleteByIds(@RequestBody DeleteParams dto){
+        String[] idArr = dto.getIds().split(",");
+        return ${classname}Service.deleteByIds(idArr)? ResponseMsg.ok() : ResponseMsg.fail();
+    }
+
+    @PostMapping("/queryPage")
+    @Override
+    public ResponseMsg queryPage(@RequestBody @Valid ${className}ListParamVO ${classname}ListParamVO) {
+        ${className}ResultBO ${classname}ResultBO = ${classname}Service.queryPage(${className}Convert.${classname}ListParamVoToDTO(${classname}ListParamVO));
+        return ResponseMsg.buildResponse(${className}Convert.${classname}ResultBoToVo(${classname}ResultBO));
+    }
+}

+ 106 - 0
imwork-windows/imwork-silos/src/main/resources/moudle/ServiceImpl.ftl

@@ -0,0 +1,106 @@
+package ${package}.${moduleName}.service.impl;
+
+import org.springframework.stereotype.Service;
+import org.springframework.util.ObjectUtils;
+import jakarta.annotation.Resource;
+
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+
+import ${package}.commons.base.util.StringUtils;
+import ${package}.${moduleName}.dao.${className}Dao;
+import ${package}.${moduleName}.entity.${className};
+import ${package}.${moduleName}.pojo.bo.${className}BO;
+import ${package}.${moduleName}.pojo.bo.${className}ResultBO;
+import ${package}.${moduleName}.pojo.dto.${className}DTO;
+import ${package}.${moduleName}.pojo.dto.${className}ListDTO;
+import ${package}.${moduleName}.service.I${className}Service;
+import ${package}.${moduleName}.convert.${className}Convert;
+
+@Service("${classname}Service")
+public class ${className}ServiceImpl extends ServiceImpl<${className}Dao,${className}> implements I${className}Service {
+    @Resource
+    private ${className}Dao ${classname}Dao;
+
+    /**
+     * 根据id获取信息
+     * @param id 用户id
+     * @return ${className}BO 响应信息
+     */
+    @Override
+    public ${className}BO info(Long id) {
+        ${className} ${classname} = ${classname}Dao.info(id);
+        return ${className}Convert.${classname}DoToBo(${classname});
+    }
+
+    /**
+     * 新增/更新信息
+     * @param ${classname}DTO 信息
+     * @return ${classname}BO 更新后信息
+     */
+    @Override
+    public ${className}BO save(${className}DTO ${classname}DTO) {
+        ${className} ${classname} = ${className}Convert.${classname}DtoToDo(${classname}DTO);
+        if (ObjectUtils.isEmpty(${classname}.getId())) {
+            ${classname}Dao.insert(${classname});
+        } else {
+            ${classname}Dao.updateById(${classname});
+        }
+        return ${className}Convert.${classname}DoToBo(${classname});
+    }
+
+    /**
+     * 根据id删除信息
+     * @param id id
+     * @return true/false 是否删除成功
+     */
+    @Override
+    public Boolean delete(Long id) {
+        return ${classname}Dao.deleteById(id) == 1 ? Boolean.TRUE : Boolean.FALSE;
+    }
+
+    @Override
+    public Boolean deleteByIds(String[] ids) {
+        return ${classname}Dao.deleteByIds(ids) > 0 ? Boolean.TRUE : Boolean.FALSE;
+    }
+
+    @Override
+    public ${className}ResultBO queryPage(${className}ListDTO ${classname}ListDTO) {
+        QueryWrapper<${className}> queryWrapper = new QueryWrapper<>();
+
+        if (!StringUtils.isEmpty(${classname}ListDTO.get${className}Name())) {
+            queryWrapper.like("${classname}_name", ${classname}ListDTO.get${className}Name());
+        }
+
+        if (!StringUtils.isEmpty(${classname}ListDTO.getCreateBeginTime())) {
+            queryWrapper.apply("create_time >= '" + ${classname}ListDTO.getCreateBeginTime() + "'");
+        }
+
+        if (!StringUtils.isEmpty(${classname}ListDTO.getCreateEndTime())) {
+            queryWrapper.apply("create_time <= '" + ${classname}ListDTO.getCreateEndTime() + "'");
+        }
+
+        if (!StringUtils.isEmpty(${classname}ListDTO.getUpdateBeginTime())) {
+            queryWrapper.apply("update_time >= '" + ${classname}ListDTO.getUpdateBeginTime() + "'");
+        }
+
+        if (!StringUtils.isEmpty(${classname}ListDTO.getUpdateEndTime())) {
+            queryWrapper.apply("update_time <= '" + ${classname}ListDTO.getUpdateEndTime() + "'");
+        }
+
+        Page<${className}> page = new Page<>(${classname}ListDTO.getPageNo(), ${classname}ListDTO.getPageRows());
+        IPage<${className}> iPage = ${classname}Dao.queryPage(page, queryWrapper);
+
+        ${className}ResultBO resultBO = new ${className}ResultBO();
+        resultBO.setPageNo(${classname}ListDTO.getPageNo());
+        resultBO.setPageRows(${classname}ListDTO.getPageRows());
+        resultBO.setPageCount((int) iPage.getPages());
+        resultBO.setTotalRows((int) iPage.getTotal());
+        resultBO.setDataList(${className}Convert.${classname}ListTo${className}BOList(iPage.getRecords()));
+        resultBO.setParams(${classname}ListDTO);
+
+        return resultBO;
+    }
+}

+ 27 - 0
imwork-windows/imwork-silos/src/main/resources/moudle/VO.ftl

@@ -0,0 +1,27 @@
+package ${package}.${moduleName}.pojo.vo;
+
+import lombok.Data;
+
+import java.io.Serial;
+import java.io.Serializable;
+import java.util.Date;
+
+/**
+ *〈功能简述〉
+ * ${comments}响应消息体
+ *
+ * @author ${author}
+ * email: ${email}
+ * date: ${datetime}
+ */
+@Data
+public class ${className}VO implements Serializable{
+    @Serial
+    private static final long serialVersionUID = 1L;
+<#list columns as column>
+    /**
+     * ${column.comments}
+     */
+    private ${column.attrType} ${column.attrname};
+</#list>
+}