diff --git a/.gitignore b/.gitignore
index 9154f4c..f5f5dad 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,5 +1,7 @@
# ---> Java
# Compiled class file
+target
+target/*
*.class
# Log file
@@ -9,6 +11,10 @@
*.ctxt
# Mobile Tools for Java (J2ME)
+.idea
+
+.idea/*
+
.mtj.tmp/
# Package Files #
diff --git a/pom.xml b/pom.xml
new file mode 100644
index 0000000..cd5ca3d
--- /dev/null
+++ b/pom.xml
@@ -0,0 +1,72 @@
+
+
+ 4.0.0
+
+ org.yangliu
+ code-generate
+ 1.0
+
+
+ 8
+ 8
+
+ 1.4.3
+ 8.0.27
+
+
+
+
+
+ org.slf4j
+ slf4j-log4j12
+ 1.7.36
+
+
+
+
+ mysql
+ mysql-connector-java
+ ${mysql-connector-java.version}
+
+
+
+
+ org.postgresql
+ postgresql
+ 42.2.16
+
+
+
+
+
+ org.freemarker
+ freemarker
+ 2.3.32
+
+
+
+
+ com.google.guava
+ guava
+ 23.0
+
+
+ cn.hutool
+ hutool-all
+ 5.8.16
+
+
+ commons-lang
+ commons-lang
+ 2.6
+
+
+ org.apache.commons
+ commons-lang3
+ 3.12.0
+
+
+
+
\ No newline at end of file
diff --git a/src/main/java/org/yangliu/codegenerate/Main.java b/src/main/java/org/yangliu/codegenerate/Main.java
new file mode 100644
index 0000000..0cb6817
--- /dev/null
+++ b/src/main/java/org/yangliu/codegenerate/Main.java
@@ -0,0 +1,175 @@
+package org.yangliu.codegenerate;
+
+import cn.hutool.core.util.StrUtil;
+import com.google.common.base.CaseFormat;
+import freemarker.cache.ClassTemplateLoader;
+import freemarker.core.XMLOutputFormat;
+import freemarker.template.Configuration;
+import freemarker.template.Template;
+import freemarker.template.TemplateException;
+import org.apache.commons.lang.StringUtils;
+import org.yangliu.codegenerate.entity.TableEntityVo;
+import org.yangliu.codegenerate.entity.TableVo;
+import org.yangliu.codegenerate.util.MarkerGenerate;
+import org.yangliu.codegenerate.util.TableFieldUtil;
+
+import java.io.File;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.io.InputStream;
+import java.sql.Connection;
+import java.sql.DatabaseMetaData;
+import java.sql.DriverManager;
+import java.sql.ResultSet;
+import java.util.*;
+
+/**
+ * @Description
+ * @Author ZhouWenTao
+ * @Date 2023/8/13 19:16
+ */
+public class Main {
+ //包名
+ private static String bussi_package = "com.enjoy.oqc";
+ //生成项目目录
+ private static String project_path = "E:\\workspace_2\\enjoy\\qms\\enjoy-oqc\\src\\main\\java\\";
+
+ private static String project_resource_mapper_path = "E:\\workspace_2\\enjoy\\qms\\enjoy-oqc\\src\\main\\resources\\mapper\\oqc\\";
+
+ //实体类模板
+ private static String bussi_entity_template = "XXXEntity.javai";
+ private static String bussi_entity_dto_template = "XXXEntityDto.javai";
+ private static String bussi_entity_vo_template = "XXXEntityVo.javai";
+
+ //mapper模板
+ private static String bussi_mapper_template = "XXXMapper.javai";
+ //mapper.xml模板
+ private static String bussi_mapperxml_template = "XXXMapper.xmli";
+ //service 模板
+ private static String bussi_service_template = "XXXService.javai";
+ private static String bussi_serviceimpl_template = "XXXServiceImpl.javai";
+ //controller
+ private static String bussi_controller_template = "XXXController.javai";
+
+ //模板所在目录
+ private static String templatepath = "/yangliu/";
+
+ private static String author = "yangliu";
+ // postgresql或mysql
+ private static String dbType = "postgresql";
+
+ public static void main(String[] args) throws Exception {
+ String driver = "org.postgresql.Driver";
+ String url = "jdbc:postgresql://10.201.145.19:35432/enjoy-oqc?stringtype=unspecified&useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false";
+ String user = "enjoy";
+ String password = "Nomi1234";
+ List tableEntityVoList = printTableStructure(driver, url, user, password, "oqc_project");
+
+ generate(bussi_package, "oqc_spot_check_record", "OqcSpotCheckRecord","抽检记录表", tableEntityVoList);
+ }
+
+ /**
+ *
+ * @param bussiPackage
+ * @param tableName
+ * @param entityName
+ * @param originalColumns
+ */
+ private static void generate(String bussiPackage, String tableName, String entityName,String description, List originalColumns) {
+ TableVo tableVo = new TableVo();
+ tableVo.setFtlDescription(description);
+ //包名
+ Map dataMap = new HashMap<>();
+ dataMap.put("bussiPackage", bussiPackage);//包
+ dataMap.put("entityPackage", "domain");
+ dataMap.put("tableName", tableName);//表名称
+ dataMap.put("tableVo", tableVo);//表属性
+ //主键
+ dataMap.put("primaryKeyField", "id");
+
+ dataMap.put("entityName", entityName);//实体类名称
+ dataMap.put("author", author);//作者
+ dataMap.put("originalColumns", originalColumns);//字段
+
+ StringBuffer parsePath = new StringBuffer(project_path);
+ if (StringUtils.isNotBlank(bussi_package)) {
+ String[] bussiPackageSplit = bussi_package.split("\\.");
+ for (String bpackage : bussiPackageSplit) {
+ parsePath = parsePath.append(bpackage).append(File.separator);
+ }
+ }
+ //生成实体类
+ String entityParsePath = parsePath + (String) dataMap.get("entityPackage") + File.separator;
+ MarkerGenerate.generate(templatepath, bussi_entity_template, entityParsePath, entityName + ".java", dataMap);
+ String dtoParsePath = parsePath + "dto" + File.separator;
+ MarkerGenerate.generate(templatepath, bussi_entity_dto_template, dtoParsePath, entityName + "Dto.java", dataMap);
+ String voParsePath = parsePath + "vo" + File.separator;
+ MarkerGenerate.generate(templatepath, bussi_entity_vo_template, voParsePath, entityName + "Vo.java", dataMap);
+
+ //生成Mapper
+ String mapperParsePath = parsePath + "mapper" + File.separator;
+ MarkerGenerate.generate(templatepath, bussi_mapper_template, mapperParsePath, entityName + "Mapper.java", dataMap);
+ //生成Mapper.xml
+ String mapperXmlParsePath = project_resource_mapper_path;
+ MarkerGenerate.generate(templatepath, bussi_mapperxml_template, mapperXmlParsePath, entityName + "Mapper.xml", dataMap);
+ //生成Service
+ String serviceParsePath = parsePath + "service" + File.separator;
+ MarkerGenerate.generate(templatepath,bussi_service_template,serviceParsePath,String.format("I%sService.java",entityName),dataMap);
+ //生成ServiceImpl
+ String serviceImplParsePath = serviceParsePath+"impl"+File.separator;
+ MarkerGenerate.generate(templatepath,bussi_serviceimpl_template,serviceImplParsePath,String.format("%sServiceImpl.java",entityName),dataMap);
+ //生成Controller
+ String controllerParsePath = parsePath + "controller" + File.separator;
+ MarkerGenerate.generate(templatepath,bussi_controller_template,controllerParsePath,String.format("%sController.java",entityName),dataMap);
+
+ }
+
+ /**
+ * 打印所有表结构
+ *
+ * @param driver driver
+ * @param url url
+ * @param user user
+ * @param password password
+ * @throws Exception exception
+ */
+ private static List printTableStructure(String driver, String url, String user, String password, String table) throws Exception {
+ Class.forName(driver);
+ Connection connection = DriverManager.getConnection(url, user, password);
+
+ DatabaseMetaData metaData = connection.getMetaData();
+ // 获取所有表
+ //ResultSet tableResultSet = metaData.getTables(null, null, table+"%", new String[]{"TABLE"});
+ //单表
+ ResultSet tableResultSet = metaData.getTables(null, null, table, new String[]{"TABLE"});
+ List tableEntityVoList = new ArrayList<>();
+ while (tableResultSet.next()) {
+ String tableName = tableResultSet.getString("TABLE_NAME");
+ System.out.println("table:" + tableName);
+ // 获取表字段结构
+ ResultSet columnResultSet = metaData.getColumns(null, "%", tableName, "%");
+ while (columnResultSet.next()) {
+ // 字段名称
+ String columnName = columnResultSet.getString("COLUMN_NAME");
+ // 数据类型
+ String columnType = columnResultSet.getString("TYPE_NAME");
+ // 字段长度
+ int datasize = columnResultSet.getInt("COLUMN_SIZE");
+ // 小数部分位数
+ int digits = columnResultSet.getInt("DECIMAL_DIGITS");
+ // 是否可为空 1代表可空 0代表不可为空
+ int nullable = columnResultSet.getInt("NULLABLE");
+ // 描述
+ String remarks = columnResultSet.getString("REMARKS");
+ System.out.println(columnName + " " + columnType + " " + datasize + " " + digits + " " + nullable + " " + remarks);
+ //System.out.println("1"+TableFieldUtil.fieldTypeParseJava(dbType,columnType));
+ String entityField = CaseFormat.LOWER_UNDERSCORE.to(CaseFormat.LOWER_CAMEL, columnName);
+ tableEntityVoList.add(new TableEntityVo(entityField, TableFieldUtil.fieldTypeParseJava(dbType, columnType), columnType, remarks));
+ }
+ System.out.println("=================================");
+ }
+ return tableEntityVoList;
+ }
+
+
+}
diff --git a/src/main/java/org/yangliu/codegenerate/entity/TableEntityVo.java b/src/main/java/org/yangliu/codegenerate/entity/TableEntityVo.java
new file mode 100644
index 0000000..7cb0242
--- /dev/null
+++ b/src/main/java/org/yangliu/codegenerate/entity/TableEntityVo.java
@@ -0,0 +1,69 @@
+package org.yangliu.codegenerate.entity;
+
+/**
+ * @Description
+ * @Author ZhouWenTao
+ * @Date 2023/8/13 20:44
+ */
+public class TableEntityVo {
+ //字段
+ private String fieldName;
+ private String fieldType;
+ //字段类型
+ private String fieldDbType;
+ //字段描述
+ private String filedComment;
+
+
+ public TableEntityVo() {
+ }
+
+ public TableEntityVo(String fieldName,String fieldType,String fieldDbType,String filedComment) {
+ this.filedComment = filedComment;
+ this.fieldName = fieldName;
+ this.fieldType = fieldType;
+ this.fieldDbType = fieldDbType;
+ }
+
+ public String getFiledComment() {
+ return filedComment;
+ }
+
+ public void setFiledComment(String filedComment) {
+ this.filedComment = filedComment;
+ }
+
+ public String getFieldName() {
+ return fieldName;
+ }
+
+ public void setFieldName(String fieldName) {
+ this.fieldName = fieldName;
+ }
+
+ public String getFieldDbType() {
+ return fieldDbType;
+ }
+
+ public void setFieldDbType(String fieldDbType) {
+ this.fieldDbType = fieldDbType;
+ }
+
+ public String getFieldType() {
+ return fieldType;
+ }
+
+ public void setFieldType(String fieldType) {
+ this.fieldType = fieldType;
+ }
+
+ @Override
+ public String toString() {
+ return "TableEntityVo{" +
+ "fieldName='" + fieldName + '\'' +
+ ", fieldType='" + fieldType + '\'' +
+ ", fieldDbType='" + fieldDbType + '\'' +
+ ", filedComment='" + filedComment + '\'' +
+ '}';
+ }
+}
diff --git a/src/main/java/org/yangliu/codegenerate/entity/TableVo.java b/src/main/java/org/yangliu/codegenerate/entity/TableVo.java
new file mode 100644
index 0000000..59059fe
--- /dev/null
+++ b/src/main/java/org/yangliu/codegenerate/entity/TableVo.java
@@ -0,0 +1,22 @@
+package org.yangliu.codegenerate.entity;
+
+import java.io.Serializable;
+
+/**
+ * @Description
+ * @Author ZhouWenTao
+ * @Date 2023/8/13 21:43
+ */
+public class TableVo implements Serializable {
+ //表描述
+ private String ftlDescription;
+
+
+ public String getFtlDescription() {
+ return ftlDescription;
+ }
+
+ public void setFtlDescription(String ftlDescription) {
+ this.ftlDescription = ftlDescription;
+ }
+}
diff --git a/src/main/java/org/yangliu/codegenerate/util/MarkerGenerate.java b/src/main/java/org/yangliu/codegenerate/util/MarkerGenerate.java
new file mode 100644
index 0000000..0d87b7c
--- /dev/null
+++ b/src/main/java/org/yangliu/codegenerate/util/MarkerGenerate.java
@@ -0,0 +1,91 @@
+package org.yangliu.codegenerate.util;
+
+import freemarker.cache.ClassTemplateLoader;
+import freemarker.core.XMLOutputFormat;
+import freemarker.template.Configuration;
+import freemarker.template.Template;
+import freemarker.template.TemplateException;
+import org.apache.commons.lang.StringUtils;
+import org.yangliu.codegenerate.Main;
+
+import java.io.File;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.util.Map;
+
+/**
+ * @Description
+ * @Author ZhouWenTao
+ * @Date 2023/8/13 21:04
+ */
+public class MarkerGenerate {
+ public static void generate(String basePackagePath,String templateName,String parsePath,String fileName,Map dataMap) {
+ String entityName = (String) dataMap.get("entityName");
+ if (StringUtils.isNotBlank(entityName)) {
+ dataMap.put("uncap_first",StringUtils.uncapitalize(entityName));
+ }
+
+ // 创建生成文件所在目录
+ folderCreate(parsePath);
+
+ //第一步:创建一个 Configuration 对象,直接 new 一个对象。构造方法的参数就是 freemarker的版本号。
+ Configuration configuration = new Configuration(Configuration.getVersion());
+ //第二步:设置模板文件所在的路径。
+ configuration.setTemplateLoader(new ClassTemplateLoader(Main.class,basePackagePath));
+ //第三步:设置模板文件使用的字符集。一般就是 utf-8.
+ configuration.setDefaultEncoding("UTF-8");
+ configuration.setOutputFormat(XMLOutputFormat.INSTANCE);
+ //第四步:加载一个模板,创建一个模板对象。
+ Template template = null;
+ try {
+ template = configuration.getTemplate(templateName);
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ String outPut=parsePath+fileName;
+ FileWriter fileWriter = null;
+ try {
+ fileWriter = new FileWriter(outPut);
+ // 第七步:调用模板对象的 process 方法输出文件。
+ template.process(dataMap,fileWriter);
+ // 第八步:关闭流
+ fileWriter.close();
+ } catch (IOException e) {
+ e.printStackTrace();
+ } catch (TemplateException e) {
+ e.printStackTrace();
+ }
+ }
+
+
+ public static void folderCreate(String folder){
+ if (StringUtils.isNotBlank(folder)) {
+ File file =new File(folder);
+ if (file.exists()) {
+ if (file.isDirectory()) {
+ System.out.println("dir exists");
+ }
+ else {
+ System.out.println("the same name file exists, can not create dir");
+ }
+ } else {
+ System.out.println("dir not exists, create it ...");
+ file.mkdirs();
+ }
+
+ /*String[] folderSpilt = folder.split(File.separator);
+ StringBuffer sb=new StringBuffer();
+ for (String f : folderSpilt) {
+ sb=sb.append(f);
+ File file=new File(sb.toString());
+ if (!file.exists()) {
+ try {
+ file.createNewFile();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+ }*/
+ }
+ }
+}
diff --git a/src/main/java/org/yangliu/codegenerate/util/TableFieldUtil.java b/src/main/java/org/yangliu/codegenerate/util/TableFieldUtil.java
new file mode 100644
index 0000000..bca13f9
--- /dev/null
+++ b/src/main/java/org/yangliu/codegenerate/util/TableFieldUtil.java
@@ -0,0 +1,37 @@
+package org.yangliu.codegenerate.util;
+
+import org.yangliu.codegenerate.util.fieldType.DbColumnType;
+import org.yangliu.codegenerate.util.fieldType.MySqlTypeConvert;
+import org.yangliu.codegenerate.util.fieldType.PostgreSqlTypeConvert;
+
+import java.util.Arrays;
+import java.util.List;
+
+/**
+ * @Description
+ * @Author ZhouWenTao
+ * @Date 2023/8/13 21:54
+ */
+public class TableFieldUtil {
+ private static List strArray= Arrays.asList("char","varchar","text","xml");
+
+
+ private static List integerArray= Arrays.asList("int","int2","int4","int8","text","xml");
+
+ /**
+ * 将 数据库字段类型转成 java类型
+ * @param fieldType
+ * @return
+ */
+ public static String fieldTypeParseJava(String databaseType,String fieldType){
+ if (databaseType.equals("mysql")) {
+ DbColumnType dbColumnType = MySqlTypeConvert.processTypeConvert(fieldType);
+ return dbColumnType.getType();
+ }else if(databaseType.equals("postgresql")){
+ DbColumnType dbColumnType = PostgreSqlTypeConvert.processTypeConvert(fieldType);
+ return dbColumnType.getType();
+ }
+ System.out.println("暂不支持该数据库");
+ return null;
+ }
+}
diff --git a/src/main/java/org/yangliu/codegenerate/util/fieldType/DbColumnType.java b/src/main/java/org/yangliu/codegenerate/util/fieldType/DbColumnType.java
new file mode 100644
index 0000000..717b08d
--- /dev/null
+++ b/src/main/java/org/yangliu/codegenerate/util/fieldType/DbColumnType.java
@@ -0,0 +1,48 @@
+package org.yangliu.codegenerate.util.fieldType;
+
+/**
+ * @Description
+ * @Author ZhouWenTao
+ * @Date 2023/8/13 22:01
+ */
+public enum DbColumnType {
+ BASE_INT("int", (String)null),
+ BASE_BOOLEAN("boolean", (String)null),
+ BASE_FLOAT("float", (String)null),
+ BASE_DOUBLE("double", (String)null),
+ STRING("String", (String)null),
+ LONG("Long", (String)null),
+ INTEGER("Integer", (String)null),
+ FLOAT("Float", (String)null),
+ DOUBLE("Double", (String)null),
+ BOOLEAN("Boolean", (String)null),
+ BYTE_ARRAY("byte[]", (String)null),
+ CHARACTER("Character", (String)null),
+ OBJECT("Object", (String)null),
+ DATE("Date", "java.util.Date"),
+ TIME("Time", "java.sql.Time"),
+ BLOB("Blob", "java.sql.Blob"),
+ CLOB("Clob", "java.sql.Clob"),
+ TIMESTAMP("Timestamp", "java.sql.Timestamp"),
+ BIG_INTEGER("BigInteger", "java.math.BigInteger"),
+ BIG_DECIMAL("BigDecimal", "java.math.BigDecimal"),
+ LOCAL_DATE("LocalDate", "java.time.LocalDate"),
+ LOCAL_TIME("LocalTime", "java.time.LocalTime"),
+ LOCAL_DATE_TIME("LocalDateTime", "java.time.LocalDateTime");
+
+ private final String type;
+ private final String pkg;
+
+ private DbColumnType(String type, String pkg) {
+ this.type = type;
+ this.pkg = pkg;
+ }
+
+ public String getType() {
+ return this.type;
+ }
+
+ public String getPkg() {
+ return this.pkg;
+ }
+}
diff --git a/src/main/java/org/yangliu/codegenerate/util/fieldType/MySqlTypeConvert.java b/src/main/java/org/yangliu/codegenerate/util/fieldType/MySqlTypeConvert.java
new file mode 100644
index 0000000..023e5fc
--- /dev/null
+++ b/src/main/java/org/yangliu/codegenerate/util/fieldType/MySqlTypeConvert.java
@@ -0,0 +1,51 @@
+package org.yangliu.codegenerate.util.fieldType;
+
+/**
+ * @Description mysql字段类型转java类型的方法代码
+ * @Author ZhouWenTao
+ * @Date 2023/8/13 22:00
+ */
+public class MySqlTypeConvert {
+ public MySqlTypeConvert() {
+ }
+
+ /**
+ * mysql字段类型转java类型
+ * @param fieldType mysql字段类型
+ * @return
+ */
+ public static DbColumnType processTypeConvert(String fieldType) {
+ String t = fieldType.toLowerCase();
+ if (!t.contains("char") && !t.contains("text")) {
+ if (t.contains("bigint")) {
+ return DbColumnType.LONG;
+ } else if (t.contains("int")) {
+ return DbColumnType.INTEGER;
+ } else if (!t.contains("date") && !t.contains("time") && !t.contains("year")) {
+ if (t.contains("text")) {
+ return DbColumnType.STRING;
+ } else if (t.contains("bit")) {
+ return DbColumnType.BOOLEAN;
+ } else if (t.contains("decimal")) {
+ return DbColumnType.BIG_DECIMAL;
+ } else if (t.contains("clob")) {
+ return DbColumnType.CLOB;
+ } else if (t.contains("blob")) {
+ return DbColumnType.BLOB;
+ } else if (t.contains("binary")) {
+ return DbColumnType.BYTE_ARRAY;
+ } else if (t.contains("float")) {
+ return DbColumnType.FLOAT;
+ } else if (t.contains("double")) {
+ return DbColumnType.DOUBLE;
+ } else {
+ return !t.contains("json") && !t.contains("enum") ? DbColumnType.STRING : DbColumnType.STRING;
+ }
+ } else {
+ return DbColumnType.DATE;
+ }
+ } else {
+ return DbColumnType.STRING;
+ }
+ }
+}
diff --git a/src/main/java/org/yangliu/codegenerate/util/fieldType/PostgreSqlTypeConvert.java b/src/main/java/org/yangliu/codegenerate/util/fieldType/PostgreSqlTypeConvert.java
new file mode 100644
index 0000000..ce3bfcc
--- /dev/null
+++ b/src/main/java/org/yangliu/codegenerate/util/fieldType/PostgreSqlTypeConvert.java
@@ -0,0 +1,47 @@
+package org.yangliu.codegenerate.util.fieldType;
+
+/**
+ * @Description pgsql字段类型转java类型的方法代码
+ * @Author ZhouWenTao
+ * @Date 2023/8/13 22:01
+ */
+
+public class PostgreSqlTypeConvert {
+ public PostgreSqlTypeConvert() {
+ }
+
+ public static DbColumnType processTypeConvert(String fieldType) {
+ String t = fieldType.toLowerCase();
+ if (!t.contains("char") && !t.contains("text")) {
+ if (t.contains("bigint")) {
+ return DbColumnType.LONG;
+ } else if (t.contains("int")) {
+ return DbColumnType.INTEGER;
+ } else if (!t.contains("date") && !t.contains("time") && !t.contains("year")) {
+ if (t.contains("text")) {
+ return DbColumnType.STRING;
+ } else if (t.contains("bit")) {
+ return DbColumnType.BOOLEAN;
+ } else if (t.contains("decimal")) {
+ return DbColumnType.BIG_DECIMAL;
+ } else if (t.contains("clob")) {
+ return DbColumnType.CLOB;
+ } else if (t.contains("blob")) {
+ return DbColumnType.BYTE_ARRAY;
+ } else if (t.contains("float")) {
+ return DbColumnType.FLOAT;
+ } else if (t.contains("double")) {
+ return DbColumnType.DOUBLE;
+ } else if (!t.contains("json") && !t.contains("enum")) {
+ return t.contains("boolean") ? DbColumnType.BOOLEAN : DbColumnType.STRING;
+ } else {
+ return DbColumnType.STRING;
+ }
+ } else {
+ return DbColumnType.DATE;
+ }
+ } else {
+ return DbColumnType.STRING;
+ }
+ }
+}
diff --git a/src/main/resources/yangliu/XXXController.javai b/src/main/resources/yangliu/XXXController.javai
new file mode 100644
index 0000000..0de31ad
--- /dev/null
+++ b/src/main/resources/yangliu/XXXController.javai
@@ -0,0 +1,142 @@
+package ${bussiPackage}.controller;
+
+import com.enjoy.common.core.web.controller.BaseController;
+import com.enjoy.common.core.web.domain.AjaxResult;
+import com.enjoy.common.core.web.page.TableDataInfo;
+import com.enjoy.common.log.annotation.Log;
+import com.enjoy.common.log.enums.BusinessType;
+import ${bussiPackage}.${entityPackage}.${entityName};
+import ${bussiPackage}.dto.${entityName}Dto;
+import ${bussiPackage}.vo.${entityName}Vo;
+import ${bussiPackage}.service.I${entityName}Service;
+
+
+import java.util.Arrays;
+import java.util.List;
+import java.util.Map;
+import java.io.IOException;
+import java.io.UnsupportedEncodingException;
+import java.net.URLDecoder;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import io.swagger.annotations.ApiImplicitParam;
+import io.swagger.annotations.ApiImplicitParams;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+
+ /**
+ * @Description: ${tableVo.ftlDescription}
+ * @Author: ${author}
+ * @Date: ${.now?string["yyyy-MM-dd"]}
+ * @Version: V1.0
+ */
+@Slf4j
+@Api(tags="${tableVo.ftlDescription}")
+@RestController
+@RequestMapping("/${entityName?uncap_first}")
+public class ${entityName}Controller extends BaseController {
+ @Autowired
+ private I${entityName}Service ${entityName?uncap_first}Service;
+
+ /**
+ * 分页列表查询
+ *
+ * @param ${entityName?uncap_first}
+ * @param pageNo
+ * @param pageSize
+ * @param req
+ * @return
+ */
+ @ApiOperation(value="${tableVo.ftlDescription}-分页列表查询", notes="${tableVo.ftlDescription}-分页列表查询")
+ @ApiImplicitParams({
+ @ApiImplicitParam(name = "pageNo", value = "分页参数:当前页", dataType = "String", paramType = "query"),
+ @ApiImplicitParam(name = "pageSize", value = "分页参数:每页数量", dataType = "String", paramType = "query")
+ })
+ @GetMapping(value = "/list")
+ public TableDataInfo queryPageList(${entityName} ${entityName?uncap_first},
+ @RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
+ @RequestParam(name="pageSize", defaultValue="10") Integer pageSize,
+ HttpServletRequest req) {
+ startPage();
+ List<${entityName}> list = ${entityName?uncap_first}Service.list();
+ return getDataTable(list);
+ }
+
+ /**
+ * ${tableVo.ftlDescription}-查询所有数据
+ */
+ @ApiOperation("${tableVo.ftlDescription}-查询所有数据")
+ @GetMapping("/listAll")
+ public AjaxResult listAll() {
+ return AjaxResult.success(${entityName?uncap_first}Service.list());
+ }
+
+ /**
+ * 获取${tableVo.ftlDescription}
+ */
+ @ApiOperation("获取${tableVo.ftlDescription}")
+ @GetMapping(value = "/{id}")
+ public AjaxResult getInfo(@PathVariable("id") String id) {
+ return AjaxResult.success(${entityName?uncap_first}Service.getById(id));
+ }
+
+ /**
+ * 添加
+ *
+ * @param ${entityName?uncap_first}
+ * @return
+ */
+ @ApiOperation(value="${tableVo.ftlDescription}-添加", notes="${tableVo.ftlDescription}-添加")
+ @Log(title = "${tableVo.ftlDescription}-添加", businessType = BusinessType.INSERT)
+ @PostMapping(value = "/add")
+ public AjaxResult add(@RequestBody ${entityName} ${entityName?uncap_first}) {
+ ${entityName?uncap_first}Service.save(${entityName?uncap_first});
+ return AjaxResult.success("添加成功");
+ }
+
+ /**
+ * 编辑
+ *
+ * @param ${entityName?uncap_first}
+ * @return
+ */
+ @Log(title = "${tableVo.ftlDescription}-编辑", businessType = BusinessType.UPDATE)
+ @ApiOperation(value="${tableVo.ftlDescription}-编辑", notes="${tableVo.ftlDescription}-编辑")
+ @RequestMapping(value = "/edit", method = {RequestMethod.PUT,RequestMethod.POST})
+ public AjaxResult edit(@RequestBody ${entityName} ${entityName?uncap_first}) {
+ ${entityName?uncap_first}Service.updateById(${entityName?uncap_first});
+ return AjaxResult.success("编辑成功!");
+ }
+
+ /**
+ * 通过id删除
+ *
+ * @param id
+ * @return
+ */
+ @Log(title = "${tableVo.ftlDescription}-通过id删除", businessType = BusinessType.DELETE)
+ @ApiOperation(value="${tableVo.ftlDescription}-通过id删除", notes="${tableVo.ftlDescription}-通过id删除")
+ @DeleteMapping(value = "/delete")
+ public AjaxResult delete(@RequestParam(name="id",required=true) String id) {
+ ${entityName?uncap_first}Service.removeById(id);
+ return AjaxResult.success("删除成功!");
+ }
+
+ /**
+ * 批量删除
+ *
+ * @param ids
+ * @return
+ */
+ @Log(title = "${tableVo.ftlDescription}-批量删除", businessType = BusinessType.DELETE)
+ @ApiOperation(value="${tableVo.ftlDescription}-批量删除", notes="${tableVo.ftlDescription}-批量删除")
+ @DeleteMapping(value = "/deleteBatch")
+ public AjaxResult deleteBatch(@RequestParam(name="ids",required=true) String ids) {
+ this.${entityName?uncap_first}Service.removeByIds(Arrays.asList(ids.split(",")));
+ return AjaxResult.success("批量删除成功!");
+ }
+
+}
diff --git a/src/main/resources/yangliu/XXXEntity.javai b/src/main/resources/yangliu/XXXEntity.javai
new file mode 100644
index 0000000..366e04a
--- /dev/null
+++ b/src/main/resources/yangliu/XXXEntity.javai
@@ -0,0 +1,68 @@
+package ${bussiPackage}.${entityPackage};
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import com.baomidou.mybatisplus.annotation.TableLogic;
+import com.enjoy.common.core.web.domain.BaseEntity;
+import com.enjoy.common.core.annotation.Excel;
+import com.enjoy.common.core.utils.iqc.ExcelImport;
+import com.enjoy.common.core.web.domain.BaseEntity;
+import com.fasterxml.jackson.annotation.JsonFormat;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.*;
+import lombok.experimental.Accessors;
+import org.springframework.format.annotation.DateTimeFormat;
+
+import java.util.Date;
+
+/**
+ * @Description: ${tableVo.ftlDescription}
+ * @Author: ${author}
+ * @Date: ${.now?string["yyyy-MM-dd"]}
+ * @Version: V1.0
+ */
+@Data
+@AllArgsConstructor
+@NoArgsConstructor
+@EqualsAndHashCode(callSuper = false)
+@Accessors(chain = true)
+@ApiModel(value="${tableName}对象", description="${tableVo.ftlDescription}")
+@TableName("${tableName}")
+public class ${entityName} extends BaseEntity{
+ private static final long serialVersionUID = 1L;
+ <#list originalColumns as po>
+ /**${po.filedComment}*/
+ <#if po.fieldName == primaryKeyField>
+ @TableId(type = IdType.ASSIGN_ID)
+ <#else>
+ <#if po.fieldType =='Date'>
+ <#if po.fieldDbType =='date'>
+ @Excel(name = "${po.filedComment}", width = 15)
+ @ExcelImport("${po.filedComment}")
+ @JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd")
+ @DateTimeFormat(pattern="yyyy-MM-dd")
+ <#elseif po.fieldDbType =='datetime'>
+ @Excel(name = "${po.filedComment}", width = 20)
+ @ExcelImport("${po.filedComment}")
+ @JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
+ @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
+ <#elseif po.fieldDbType =='timestamp'>
+ @Excel(name = "${po.filedComment}", width = 20)
+ @ExcelImport("${po.filedComment}")
+ @JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
+ @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
+ #if>
+ <#else>
+ @Excel(name = "${po.filedComment}", width = 15)
+ @ExcelImport("${po.filedComment}")
+ #if>
+ #if>
+ @ApiModelProperty(value = "${po.filedComment}",example = "${po.filedComment}")
+ <#if po.fieldName == 'delFlag'>
+ @TableLogic
+ #if>
+ private <#if po.fieldType=='java.sql.Blob'>byte[]<#else>${po.fieldType}#if> ${po.fieldName};
+ #list>
+}
diff --git a/src/main/resources/yangliu/XXXEntityDto.javai b/src/main/resources/yangliu/XXXEntityDto.javai
new file mode 100644
index 0000000..3145d83
--- /dev/null
+++ b/src/main/resources/yangliu/XXXEntityDto.javai
@@ -0,0 +1,61 @@
+package ${bussiPackage}.dto;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import com.enjoy.common.core.annotation.Excel;
+import com.enjoy.common.core.utils.iqc.ExcelImport;
+import com.enjoy.common.core.web.domain.BaseEntity;
+import com.fasterxml.jackson.annotation.JsonFormat;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.*;
+import lombok.experimental.Accessors;
+import org.springframework.format.annotation.DateTimeFormat;
+
+import java.util.Date;
+
+/**
+ * @Description: ${tableVo.ftlDescription}
+ * @Author: ${author}
+ * @Date: ${.now?string["yyyy-MM-dd"]}
+ * @Version: V1.0
+ */
+@Data
+@AllArgsConstructor
+@NoArgsConstructor
+@EqualsAndHashCode(callSuper = false)
+@Accessors(chain = true)
+@ApiModel(value="${tableName}对象", description="${tableVo.ftlDescription}")
+public class ${entityName}Dto{
+ private static final long serialVersionUID = 1L;
+ <#list originalColumns as po>
+ /**${po.filedComment}*/
+ <#if po.fieldName == primaryKeyField>
+ <#else>
+ <#if po.fieldType =='Date'>
+ <#if po.fieldDbType =='date'>
+ @Excel(name = "${po.filedComment}", width = 15)
+ @ExcelImport("${po.filedComment}")
+ @JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd")
+ @DateTimeFormat(pattern="yyyy-MM-dd")
+ <#elseif po.fieldDbType =='datetime'>
+ @Excel(name = "${po.filedComment}", width = 20)
+ @ExcelImport("${po.filedComment}")
+ @JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
+ @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
+ <#elseif po.fieldDbType =='timestamp'>
+ @Excel(name = "${po.filedComment}", width = 20)
+ @ExcelImport("${po.filedComment}")
+ @JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
+ @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
+ #if>
+ <#else>
+ @Excel(name = "${po.filedComment}", width = 15)
+ @ExcelImport("${po.filedComment}")
+ #if>
+ #if>
+ @ApiModelProperty(value = "${po.filedComment}",example = "${po.filedComment}")
+ private <#if po.fieldType=='java.sql.Blob'>byte[]<#else>${po.fieldType}#if> ${po.fieldName};
+ #list>
+}
diff --git a/src/main/resources/yangliu/XXXEntityVo.javai b/src/main/resources/yangliu/XXXEntityVo.javai
new file mode 100644
index 0000000..3ba8680
--- /dev/null
+++ b/src/main/resources/yangliu/XXXEntityVo.javai
@@ -0,0 +1,61 @@
+package ${bussiPackage}.vo;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import com.enjoy.common.core.annotation.Excel;
+import com.enjoy.common.core.utils.iqc.ExcelImport;
+import com.enjoy.common.core.web.domain.BaseEntity;
+import com.fasterxml.jackson.annotation.JsonFormat;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.*;
+import lombok.experimental.Accessors;
+import org.springframework.format.annotation.DateTimeFormat;
+
+import java.util.Date;
+
+/**
+ * @Description: ${tableVo.ftlDescription}
+ * @Author: ${author}
+ * @Date: ${.now?string["yyyy-MM-dd"]}
+ * @Version: V1.0
+ */
+@Data
+@AllArgsConstructor
+@NoArgsConstructor
+@EqualsAndHashCode(callSuper = false)
+@Accessors(chain = true)
+@ApiModel(value="${tableName}对象", description="${tableVo.ftlDescription}")
+public class ${entityName}Vo{
+ private static final long serialVersionUID = 1L;
+ <#list originalColumns as po>
+ /**${po.filedComment}*/
+ <#if po.fieldName == primaryKeyField>
+ <#else>
+ <#if po.fieldType =='Date'>
+ <#if po.fieldDbType =='date'>
+ @Excel(name = "${po.filedComment}", width = 15)
+ @ExcelImport("${po.filedComment}")
+ @JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd")
+ @DateTimeFormat(pattern="yyyy-MM-dd")
+ <#elseif po.fieldDbType =='datetime'>
+ @Excel(name = "${po.filedComment}", width = 20)
+ @ExcelImport("${po.filedComment}")
+ @JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
+ @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
+ <#elseif po.fieldDbType =='timestamp'>
+ @Excel(name = "${po.filedComment}", width = 20)
+ @ExcelImport("${po.filedComment}")
+ @JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
+ @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
+ #if>
+ <#else>
+ @Excel(name = "${po.filedComment}", width = 15)
+ @ExcelImport("${po.filedComment}")
+ #if>
+ #if>
+ @ApiModelProperty(value = "${po.filedComment}",example = "${po.filedComment}")
+ private <#if po.fieldType=='java.sql.Blob'>byte[]<#else>${po.fieldType}#if> ${po.fieldName};
+ #list>
+}
diff --git a/src/main/resources/yangliu/XXXMapper.javai b/src/main/resources/yangliu/XXXMapper.javai
new file mode 100644
index 0000000..0fbd648
--- /dev/null
+++ b/src/main/resources/yangliu/XXXMapper.javai
@@ -0,0 +1,16 @@
+package ${bussiPackage}.mapper;
+
+import java.util.List;
+import org.apache.ibatis.annotations.Param;
+import ${bussiPackage}.${entityPackage}.${entityName};
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+
+/**
+ * @Description: ${tableVo.ftlDescription}
+ * @Author: ${author}
+ * @Date: ${.now?string["yyyy-MM-dd"]}
+ * @Version: V1.0
+ */
+public interface ${entityName}Mapper extends BaseMapper<${entityName}> {
+
+}
diff --git a/src/main/resources/yangliu/XXXMapper.xmli b/src/main/resources/yangliu/XXXMapper.xmli
new file mode 100644
index 0000000..9594782
--- /dev/null
+++ b/src/main/resources/yangliu/XXXMapper.xmli
@@ -0,0 +1,5 @@
+
+
+
+
+
\ No newline at end of file
diff --git a/src/main/resources/yangliu/XXXService.javai b/src/main/resources/yangliu/XXXService.javai
new file mode 100644
index 0000000..fa07046
--- /dev/null
+++ b/src/main/resources/yangliu/XXXService.javai
@@ -0,0 +1,14 @@
+package ${bussiPackage}.service;
+
+import ${bussiPackage}.${entityPackage}.${entityName};
+import com.baomidou.mybatisplus.extension.service.IService;
+
+/**
+ * @Description: ${tableVo.ftlDescription}
+ * @Author: ${author}
+ * @Date: ${.now?string["yyyy-MM-dd"]}
+ * @Version: V1.0
+ */
+public interface I${entityName}Service extends IService<${entityName}> {
+
+}
\ No newline at end of file
diff --git a/src/main/resources/yangliu/XXXServiceImpl.javai b/src/main/resources/yangliu/XXXServiceImpl.javai
new file mode 100644
index 0000000..b12de87
--- /dev/null
+++ b/src/main/resources/yangliu/XXXServiceImpl.javai
@@ -0,0 +1,19 @@
+package ${bussiPackage}.service.impl;
+
+import ${bussiPackage}.${entityPackage}.${entityName};
+import ${bussiPackage}.mapper.${entityName}Mapper;
+import ${bussiPackage}.service.I${entityName}Service;
+import org.springframework.stereotype.Service;
+
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+
+/**
+ * @Description: ${tableVo.ftlDescription}
+ * @Author: ${author}
+ * @Date: ${.now?string["yyyy-MM-dd"]}
+ * @Version: V1.0
+ */
+@Service
+public class ${entityName}ServiceImpl extends ServiceImpl<${entityName}Mapper, ${entityName}> implements I${entityName}Service {
+
+}