mirror of
https://github.com/moshowgame/SpringBootCodeGenerator.git
synced 2026-03-22 15:39:04 +08:00
Compare commits
14 Commits
r20191126.
...
r20191229.
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
03152e54ef | ||
|
|
8b37443018 | ||
|
|
eb7760ac18 | ||
|
|
ae7815105f | ||
|
|
b7861ca9fc | ||
|
|
870d95e1bf | ||
|
|
a84a4c1087 | ||
|
|
f746461188 | ||
|
|
02c43a8a9e | ||
|
|
f45b1bfa8a | ||
|
|
a68989be66 | ||
|
|
6cfa5d2c63 | ||
|
|
a4736f65b5 | ||
|
|
60b214bf0f |
161
README.md
161
README.md
@@ -1,78 +1,83 @@
|
|||||||
# SpringBootCodeGenerator
|
# SpringBootCodeGenerator
|
||||||

|

|
||||||

|

|
||||||

|

|
||||||
[](https://travis-ci.org/moshowgame/SpringBootCodeGenerator)
|
[](https://travis-ci.org/moshowgame/SpringBootCodeGenerator)
|
||||||
|
|
||||||
|
|
||||||
# Description
|
# Description
|
||||||
- √ 基于SpringBoot2+Freemarker+Bootstrap
|
- √ 基于SpringBoot2+Freemarker+Bootstrap
|
||||||
- √ 以释放双手为目的
|
- √ 以释放双手为目的
|
||||||
- √ 支持mysql/oracle/pgsql三大数据库
|
- √ 支持mysql/oracle/pgsql三大数据库
|
||||||
- √ 用DDL-SQL语句生成JPA/JdbcTemplate/Mybatis/MybatisPlus/BeetlSQL相关代码.
|
- √ 用DDL-SQL语句生成JPA/JdbcTemplate/Mybatis/MybatisPlus/BeetlSQL相关代码.
|
||||||
|
|
||||||
|
|
||||||
# Url
|
# Url
|
||||||
|
|
||||||
|访问路径|http://localhost:1234/generator|
|
|访问路径|http://localhost:1234/generator|
|
||||||
|-|-|
|
|-|-|
|
||||||
|在线地址|http://java.bejson.com/generator|
|
|在线地址|http://java.bejson.com/generator|
|
||||||
|CSDN博客|http://zhengkai.blog.csdn.net|
|
|CSDN博客|http://zhengkai.blog.csdn.net|
|
||||||
|
|最新Jar包|https://github.com/moshowgame/SpringBootCodeGenerator/releases|
|
||||||
感谢bejson三叔将他部署在[BEJSON](www.bejson.com)上,目前是besjon专供工具(线上版本不一定是最新的,会有延迟,请谅解,谢谢).
|
|
||||||
|
感谢bejson三叔将他部署在[BEJSON](www.bejson.com)上,目前是besjon专供工具(线上版本不一定是最新的,会有延迟,请谅解,谢谢).
|
||||||
|
|
||||||
# Update
|
|
||||||
|
# Update
|
||||||
|更新日期|更新内容|
|
|
||||||
|-|-|
|
|更新日期|更新内容|
|
||||||
|20191124|1.java代码结构优化. 2.新增简单的json生成模式 3.新增简单的正则表达式匹配模式(感谢@ydq的贡献) 4.新增对复制String代码中的乱SQL代码的支持 5.优化对JSON的父子节点/处理,JSONObject和JSONArray节点处理,子节点缺失'{'头处理|
|
|-|-|
|
||||||
|20191123|1.移除频繁出错和被过滤的layer,改为jquery-toast. 2.Util功能优化,新增json和xml.|
|
|20191229|1.修复bejson安全防护策略拦截问题(感谢@liangbintao和@1808083642的反馈) 2.优化字段名含date字符串的处理(感谢@smilexzh的反馈) 3.控制台动态输出项目访问地址(感谢@gaohanghang的提交)|
|
||||||
|20191116|优化对primary关键字的处理(感谢@liujiansgit的反馈). |
|
|20191128|1.修复支持string-copy导致的以n结尾的字母不显示问题 2.jpa-entity新增swagger@ApiModel@ApiModelProperty注解和SQL字段@Column注解(感谢@yjq907的建议) |
|
||||||
|20191115|1.添加tinyint类型转换(感谢@lixiliang&@liujiansgit的Suggestion) 2.添加一键复制功能(感谢@gaohanghang的Suggestion) 3.Mybatis的insert增加keyProperty="id"用于返回自增id(感谢@88888888888888888888的Suggestion) 4.优化date类型的支持(感谢@SteveLsf的反馈) 5.其他一些优化. |
|
|20191126|1.springboot2内置tomcat更换为性能更强大的undertow 2.修复tinyintTransType参数丢失问题 |
|
||||||
|20191015|修复jdbcTemplates中insert语句第一个字段丢失的问题. |
|
|20191124|1.java代码结构优化. 2.新增简单的json生成模式 3.新增简单的正则表达式匹配模式(感谢@ydq的贡献) 4.新增对复制String代码中的乱SQL代码的支持 5.优化对JSON的父子节点/处理,JSONObject和JSONArray节点处理,子节点缺失'{'头处理|
|
||||||
|20190915|1.添加对象getset模板 2.添加sql模板 3.启动类添加日志输出,方便项目使用(感谢@gaohanghang 的pull request) |
|
|20191123|1.移除频繁出错和被过滤的layer,改为jquery-toast. 2.Util功能优化,新增json和xml.|
|
||||||
|20190910-2|优化以及更新Maven依赖,减少打包体积. |
|
|20191116|优化对primary关键字的处理(感谢@liujiansgit的反馈). |
|
||||||
|20190910-1|1.修复mapper接口load方法,但是xml中方法不匹配问题 2.移除mapper中CRUD时的@param 注解,会影响xml的解析(感谢@caojiantao的反馈).3.优化MyBatis的xml文件对Oracle的支持.(感谢@wylove1992的反馈) 4.新增对boolean的处理(感谢@violinxsc的反馈)以及优化tinyint类型生成boolean类型问题(感谢@hahaYhui的反馈) |
|
|20191115|1.添加tinyint类型转换(感谢@lixiliang&@liujiansgit的Suggestion) 2.添加一键复制功能(感谢@gaohanghang的Suggestion) 3.Mybatis的insert增加keyProperty="id"用于返回自增id(感谢@88888888888888888888的Suggestion) 4.优化date类型的支持(感谢@SteveLsf的反馈) 5.其他一些优化. |
|
||||||
|20190909|添加是否下划线转换为驼峰的选择(感谢@youngking28 的pull request).|
|
|20191015|修复jdbcTemplates中insert语句第一个字段丢失的问题. |
|
||||||
|20190518|1.优化注释 2.修改 mybatis模板中 controller注解 3.修改 mybatis模板中 dao文件使用为 mapper文件 4.修改 mybatis模板中 service实现类中的一个 bug 5.修改 index.ftl文件中 mybatis模板的 dao -> mapper(感谢@unqin的pull request)|
|
|20190915|1.添加对象getset模板 2.添加sql模板 3.启动类添加日志输出,方便项目使用(感谢@gaohanghang 的pull request) |
|
||||||
|20190511|优化mybatis模块的dao和xml模板,修改dao接口注解为@Repository,所有dao参数改为包装类,删除update语句最后的UpdateTime = NOW(),修改dao接口文件的方法注释使其更符合javaDoc的标准,修改insert语句增加插入行主键的返回,修改load的方法名为selectByPrimaryKey,修改xml的update语句新增动态if判空,修改xml的insert语句新增动态插入判空,更符合mybatisGenerator标准(感谢@Archer-Wen的贡献 ).|
|
|20190910-2|优化以及更新Maven依赖,减少打包体积. |
|
||||||
|20190429|新增返回封装工具类设置,优化对oracle注释comment on column的支持(感谢@liukex反馈),优化对普通和特殊storage关键字的判断(感谢@AhHeadFloating的反馈 ).|
|
|20190910-1|1.修复mapper接口load方法,但是xml中方法不匹配问题 2.移除mapper中CRUD时的@param 注解,会影响xml的解析(感谢@caojiantao的反馈).3.优化MyBatis的xml文件对Oracle的支持.(感谢@wylove1992的反馈) 4.新增对boolean的处理(感谢@violinxsc的反馈)以及优化tinyint类型生成boolean类型问题(感谢@hahaYhui的反馈) |
|
||||||
|20190211|提交gitignore,解决StringUtils.lowerCaseFirst潜在的NPE异常,校验修改为@RequestParam参数校验,lombok之@Data和@Slf4j优化,fix JdbcDAO模板类名显示为中文问题,WebMvcConfig整合MessageConverter,模板代码分类(感谢@liutf和@tfgzs的pull request).|
|
|20190909|添加是否下划线转换为驼峰的选择(感谢@youngking28 的pull request).|
|
||||||
|20190210|实体生成规则切换为包装类型,不再采用基本数据类型,为实体类生成添加显示的默认构造方法(感谢@h2so的pull request).|
|
|20190518|1.优化注释 2.修改 mybatis模板中 controller注解 3.修改 mybatis模板中 dao文件使用为 mapper文件 4.修改 mybatis模板中 service实现类中的一个 bug 5.修改 index.ftl文件中 mybatis模板的 dao -> mapper(感谢@unqin的pull request)|
|
||||||
|20190106|修复处理number/decimal(x,x)类型的逻辑(感谢@arthaschan的反馈),修复JdbcTemplates模板两处错误(感谢@everflourish的反馈).|
|
|20190511|优化mybatis模块的dao和xml模板,修改dao接口注解为@Repository,所有dao参数改为包装类,删除update语句最后的UpdateTime = NOW(),修改dao接口文件的方法注释使其更符合javaDoc的标准,修改insert语句增加插入行主键的返回,修改load的方法名为selectByPrimaryKey,修改xml的update语句新增动态if判空,修改xml的insert语句新增动态插入判空,更符合mybatisGenerator标准(感谢@Archer-Wen的贡献 ).|
|
||||||
|20181212|首页UI优化,新增MybatisPlus模块(感谢@三叔同事的建议),修复作者名和包名获取失败问题(感谢@Yanch1994的反馈).|
|
|20190429|新增返回封装工具类设置,优化对oracle注释comment on column的支持(感谢@liukex反馈),优化对普通和特殊storage关键字的判断(感谢@AhHeadFloating的反馈 ).|
|
||||||
|20181122|优化正则表达式点号的处理,优化处理字段类型,对number类型增加int,long,BigDecimal的区分判断(感谢@lshz0088的指导).|
|
|20190211|提交gitignore,解决StringUtils.lowerCaseFirst潜在的NPE异常,校验修改为@RequestParam参数校验,lombok之@Data和@Slf4j优化,fix JdbcDAO模板类名显示为中文问题,WebMvcConfig整合MessageConverter,模板代码分类(感谢@liutf和@tfgzs的pull request).|
|
||||||
|20181108|修复非字段描述"KEY FK_xxxx (xxxx)"导致生成KEY字段情况(感谢@tornadoorz反馈).|
|
|20190210|实体生成规则切换为包装类型,不再采用基本数据类型,为实体类生成添加显示的默认构造方法(感谢@h2so的pull request).|
|
||||||
|20181018|支持double(x,x)的类型,以及comment里面包含一些特殊字符的处理(感谢@tanwubo的反馈).|
|
|20190106|修复处理number/decimal(x,x)类型的逻辑(感谢@arthaschan的反馈),修复JdbcTemplates模板两处错误(感谢@everflourish的反馈).|
|
||||||
|20181010|CDN变更,修复CDN不稳定导致网页js报错问题.|
|
|20181212|首页UI优化,新增MybatisPlus模块(感谢@三叔同事的建议),修复作者名和包名获取失败问题(感谢@Yanch1994的反馈).|
|
||||||
|20181003|新增element-ui/bootstrap生成.|
|
|20181122|优化正则表达式点号的处理,优化处理字段类型,对number类型增加int,long,BigDecimal的区分判断(感谢@lshz0088的指导).|
|
||||||
|20181002|修复公共CDN之Layer.js404问题,导致项目无法生成.|
|
|20181108|修复非字段描述"KEY FK_xxxx (xxxx)"导致生成KEY字段情况(感谢@tornadoorz反馈).|
|
||||||
|20180927|优化COMMENT提取逻辑,支持多种复杂情况的注释(感谢@raodeming的反馈).|
|
|20181018|支持double(x,x)的类型,以及comment里面包含一些特殊字符的处理(感谢@tanwubo的反馈).|
|
||||||
|20180926|全新BeetlSQL模块,以及一些小细节优化(感谢@三叔同事的建议).|
|
|20181010|CDN变更,修复CDN不稳定导致网页js报错问题.|
|
||||||
|20180925|优化SQL表和字段备注的推断,包括pgsql/oralce的comment on column/table情况处理等.|
|
|20181003|新增element-ui/bootstrap生成.|
|
||||||
|20180918|优化SQL类型推断.优化PrimaryKey判断.修复jpacontroller中Repository拼写错误问题.|
|
|20181002|修复公共CDN之Layer.js404问题,导致项目无法生成.|
|
||||||
|20180917|全新首页,静态文件全部采用CDN.新增jdbcTemplate模块.|
|
|20180927|优化COMMENT提取逻辑,支持多种复杂情况的注释(感谢@raodeming的反馈).|
|
||||||
|20180916|1.优化oracle支持,优化DDL语句中"或者'或者空格的支持. 2.补充char/clob/blob/json等类型,如果类型未知,默认为String.|
|
|20180926|全新BeetlSQL模块,以及一些小细节优化(感谢@三叔同事的建议).|
|
||||||
|20180915|新增Swagger-UI模板.修复一些命名和导入问题.JPA的Entity默认第一个字段为Id,如果不是请手工修改.|
|
|20180925|优化SQL表和字段备注的推断,包括pgsql/oralce的comment on column/table情况处理等.|
|
||||||
|20180913|修复字段没有描述以及类型为DATE型导致的问题.新增JPA的Controller模板.|
|
|20180918|优化SQL类型推断.优化PrimaryKey判断.修复jpacontroller中Repository拼写错误问题.|
|
||||||
|20180831|初始化项目.新增JPA系列Entity+Repository模板.|
|
|20180917|全新首页,静态文件全部采用CDN.新增jdbcTemplate模块.|
|
||||||
|
|20180916|1.优化oracle支持,优化DDL语句中"或者'或者空格的支持. 2.补充char/clob/blob/json等类型,如果类型未知,默认为String.|
|
||||||
# FieldName
|
|20180915|新增Swagger-UI模板.修复一些命名和导入问题.JPA的Entity默认第一个字段为Id,如果不是请手工修改.|
|
||||||
|字段名|说明|
|
|20180913|修复字段没有描述以及类型为DATE型导致的问题.新增JPA的Controller模板.|
|
||||||
|-|-|
|
|20180831|初始化项目.新增JPA系列Entity+Repository模板.|
|
||||||
|packageName|自定义的包名|
|
|
||||||
|authorName|自定义的作者名|
|
# FieldName
|
||||||
|returnUtil|自定义的返回Util|
|
|字段名|说明|
|
||||||
|tableName|sql中的表名|
|
|-|-|
|
||||||
|className|java类名|
|
|packageName|自定义的包名|
|
||||||
|classComment|sql表备注/java类备注|
|
|authorName|自定义的作者名|
|
||||||
|fieldName|字段名|
|
|returnUtil|自定义的返回Util|
|
||||||
|fieldComment|字段备注|
|
|tableName|sql中的表名|
|
||||||
|
|className|java类名|
|
||||||
|
|classComment|sql表备注/java类备注|
|
||||||
<img src="./codegenerator1.png">
|
|fieldName|字段名|
|
||||||
<img src="./codegenerator2.png">
|
|fieldComment|字段备注|
|
||||||
<img src="./codegenerator3.png">
|
|
||||||
<img src="./donate.jpg">
|
|
||||||
|
<img src="./codegenerator1.png">
|
||||||
|
<img src="./codegenerator2.png">
|
||||||
|
<img src="./codegenerator3.png">
|
||||||
|
<img src="./codegenerator4.png">
|
||||||
|
<img src="./donate.jpg">
|
||||||
|
|
||||||
|
|||||||
BIN
codegenerator4.png
Normal file
BIN
codegenerator4.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 147 KiB |
@@ -7,12 +7,12 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>com.softdev.system</groupId>
|
<groupId>com.softdev.system</groupId>
|
||||||
<artifactId>SpringBootCodeGenerator</artifactId>
|
<artifactId>SpringBootCodeGenerator</artifactId>
|
||||||
<version>0.0.1-SNAPSHOT</version>
|
<version>2.0</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<groupId>com.softdev.system</groupId>
|
<groupId>com.softdev.system</groupId>
|
||||||
<artifactId>generator-web</artifactId>
|
<artifactId>generator-web</artifactId>
|
||||||
<version>0.0.1-SNAPSHOT</version>
|
<version>2.0</version>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
@@ -38,10 +38,10 @@
|
|||||||
<artifactId>spring-boot-starter-data-jpa</artifactId>
|
<artifactId>spring-boot-starter-data-jpa</artifactId>
|
||||||
</dependency>-->
|
</dependency>-->
|
||||||
|
|
||||||
<dependency>
|
<!--<dependency>
|
||||||
<groupId>junit</groupId>
|
<groupId>junit</groupId>
|
||||||
<artifactId>junit</artifactId>
|
<artifactId>junit</artifactId>
|
||||||
</dependency>
|
</dependency>-->
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
@@ -65,7 +65,7 @@
|
|||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-compiler-plugin</artifactId>
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
<version>3.1</version>
|
<version>3.8.1</version>
|
||||||
<configuration>
|
<configuration>
|
||||||
<skip>true</skip>
|
<skip>true</skip>
|
||||||
<compilerId>javac</compilerId>
|
<compilerId>javac</compilerId>
|
||||||
@@ -87,25 +87,24 @@
|
|||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-resources-plugin</artifactId>
|
<artifactId>maven-resources-plugin</artifactId>
|
||||||
<version>3.0.1</version>
|
<version>3.1.0</version>
|
||||||
<configuration>
|
<configuration>
|
||||||
<!--<failOnMissingWebXml>false</failOnMissingWebXml>-->
|
<!--<failOnMissingWebXml>false</failOnMissingWebXml>-->
|
||||||
<includeEmptyDirs>true</includeEmptyDirs>
|
<includeEmptyDirs>true</includeEmptyDirs>
|
||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
<plugin>
|
<!--<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-war-plugin</artifactId>
|
<artifactId>maven-war-plugin</artifactId>
|
||||||
<version>2.1.1</version>
|
<version>3.2.3</version>
|
||||||
<configuration>
|
<configuration>
|
||||||
<failOnMissingWebXml>false</failOnMissingWebXml>
|
<failOnMissingWebXml>false</failOnMissingWebXml>
|
||||||
<warSourceExcludes>upload/**</warSourceExcludes>
|
<warSourceExcludes>upload/**</warSourceExcludes>
|
||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</plugin>-->
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||||
<version>2.0.4.RELEASE</version>
|
|
||||||
<executions>
|
<executions>
|
||||||
<execution>
|
<execution>
|
||||||
<goals>
|
<goals>
|
||||||
|
|||||||
@@ -5,10 +5,8 @@ import org.springframework.boot.SpringApplication;
|
|||||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||||
|
|
||||||
@SpringBootApplication
|
@SpringBootApplication
|
||||||
@Slf4j
|
|
||||||
public class GeneratorWebApplication {
|
public class GeneratorWebApplication {
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
SpringApplication.run(GeneratorWebApplication.class,args);
|
SpringApplication.run(GeneratorWebApplication.class,args);
|
||||||
log.info("项目启动启动成功!访问地址: http://localhost:1234/generator");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,30 @@
|
|||||||
|
package com.softdev.system.generator.config;
|
||||||
|
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.boot.web.context.WebServerInitializedEvent;
|
||||||
|
import org.springframework.context.ApplicationListener;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Description 动态获取tomcat启动端口,控制台打印项目访问地址
|
||||||
|
* @Author Gao Hang Hang
|
||||||
|
* @Date 2019-12-27 14:37
|
||||||
|
**/
|
||||||
|
@Component
|
||||||
|
@Slf4j
|
||||||
|
public class ServerConfig implements ApplicationListener<WebServerInitializedEvent> {
|
||||||
|
|
||||||
|
private int serverPort;
|
||||||
|
|
||||||
|
public int getPort() {
|
||||||
|
return this.serverPort;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onApplicationEvent(WebServerInitializedEvent event) {
|
||||||
|
this.serverPort = event.getWebServer().getPort();
|
||||||
|
//log.info("Get WebServer port {}", serverPort);
|
||||||
|
log.info("项目启动启动成功!访问地址: http://localhost:{}/generator", serverPort);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -1,49 +1,49 @@
|
|||||||
package com.softdev.system.generator.config;
|
package com.softdev.system.generator.config;
|
||||||
|
|
||||||
import com.alibaba.fastjson.support.config.FastJsonConfig;
|
import com.alibaba.fastjson.support.config.FastJsonConfig;
|
||||||
import com.alibaba.fastjson.support.spring.FastJsonHttpMessageConverter;
|
import com.alibaba.fastjson.support.spring.FastJsonHttpMessageConverter;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
import org.springframework.http.MediaType;
|
import org.springframework.http.MediaType;
|
||||||
import org.springframework.http.converter.HttpMessageConverter;
|
import org.springframework.http.converter.HttpMessageConverter;
|
||||||
import org.springframework.http.converter.StringHttpMessageConverter;
|
import org.springframework.http.converter.StringHttpMessageConverter;
|
||||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
||||||
|
|
||||||
import java.nio.charset.Charset;
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
/**
|
/**
|
||||||
* 2019-2-11 liutf WebMvcConfig 整合 cors 和 SpringMvc MessageConverter
|
* 2019-2-11 liutf WebMvcConfig 整合 cors 和 SpringMvc MessageConverter
|
||||||
*/
|
*/
|
||||||
@Configuration
|
@Configuration
|
||||||
public class WebMvcConfig implements WebMvcConfigurer {
|
public class WebMvcConfig implements WebMvcConfigurer {
|
||||||
|
|
||||||
/* @Override
|
/* @Override
|
||||||
public void addCorsMappings(CorsRegistry registry) {
|
public void addCorsMappings(CorsRegistry registry) {
|
||||||
registry.addMapping("/**")
|
registry.addMapping("/**")
|
||||||
.allowedOrigins("*")
|
.allowedOrigins("*")
|
||||||
.allowedHeaders("x-requested-with")
|
.allowedHeaders("x-requested-with")
|
||||||
.allowedMethods("GET", "POST", "PUT", "DELETE", "PATCH", "HEAD", "OPTIONS", "TRACE")
|
.allowedMethods("GET", "POST", "PUT", "DELETE", "PATCH", "HEAD", "OPTIONS", "TRACE")
|
||||||
.maxAge(3600);
|
.maxAge(3600);
|
||||||
}*/
|
}*/
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void configureMessageConverters(List<HttpMessageConverter<?>> converters) {
|
public void configureMessageConverters(List<HttpMessageConverter<?>> converters) {
|
||||||
//FastJsonHttpMessageConverter
|
//FastJsonHttpMessageConverter
|
||||||
FastJsonHttpMessageConverter fastConverter = new FastJsonHttpMessageConverter();
|
FastJsonHttpMessageConverter fastConverter = new FastJsonHttpMessageConverter();
|
||||||
|
|
||||||
List<MediaType> fastMediaTypes = new ArrayList<>();
|
List<MediaType> fastMediaTypes = new ArrayList<>();
|
||||||
fastMediaTypes.add(MediaType.APPLICATION_JSON_UTF8);
|
fastMediaTypes.add(MediaType.APPLICATION_JSON_UTF8);
|
||||||
fastConverter.setSupportedMediaTypes(fastMediaTypes);
|
fastConverter.setSupportedMediaTypes(fastMediaTypes);
|
||||||
|
|
||||||
FastJsonConfig fastJsonConfig = new FastJsonConfig();
|
FastJsonConfig fastJsonConfig = new FastJsonConfig();
|
||||||
fastJsonConfig.setCharset(Charset.forName("UTF-8"));
|
fastJsonConfig.setCharset(StandardCharsets.UTF_8);
|
||||||
fastConverter.setFastJsonConfig(fastJsonConfig);
|
fastConverter.setFastJsonConfig(fastJsonConfig);
|
||||||
|
|
||||||
//StringHttpMessageConverter
|
//StringHttpMessageConverter
|
||||||
StringHttpMessageConverter stringConverter = new StringHttpMessageConverter();
|
StringHttpMessageConverter stringConverter = new StringHttpMessageConverter();
|
||||||
stringConverter.setDefaultCharset(Charset.forName("UTF-8"));
|
stringConverter.setDefaultCharset(StandardCharsets.UTF_8);
|
||||||
stringConverter.setSupportedMediaTypes(fastMediaTypes);
|
stringConverter.setSupportedMediaTypes(fastMediaTypes);
|
||||||
converters.add(stringConverter);
|
converters.add(stringConverter);
|
||||||
converters.add(fastConverter);
|
converters.add(fastConverter);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,79 +1,84 @@
|
|||||||
package com.softdev.system.generator.controller;
|
package com.softdev.system.generator.controller;
|
||||||
|
|
||||||
import com.softdev.system.generator.entity.ClassInfo;
|
import com.softdev.system.generator.entity.ClassInfo;
|
||||||
import com.softdev.system.generator.entity.ParamInfo;
|
import com.softdev.system.generator.entity.ParamInfo;
|
||||||
import com.softdev.system.generator.entity.ReturnT;
|
import com.softdev.system.generator.entity.ReturnT;
|
||||||
import com.softdev.system.generator.service.GeneratorService;
|
import com.softdev.system.generator.service.GeneratorService;
|
||||||
import com.softdev.system.generator.util.CodeGenerateException;
|
import com.softdev.system.generator.util.CodeGenerateException;
|
||||||
import com.softdev.system.generator.util.FreemarkerTool;
|
import com.softdev.system.generator.util.TableParseUtil;
|
||||||
import com.softdev.system.generator.util.TableParseUtil;
|
import freemarker.template.TemplateException;
|
||||||
import freemarker.template.TemplateException;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.stereotype.Controller;
|
||||||
import org.springframework.stereotype.Controller;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
import java.io.IOException;
|
import org.springframework.web.bind.annotation.ResponseBody;
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
import java.io.IOException;
|
||||||
|
import java.util.HashMap;
|
||||||
/**
|
import java.util.Map;
|
||||||
* spring boot code generator
|
|
||||||
* @author zhengk/moshow
|
/**
|
||||||
*/
|
* spring boot code generator
|
||||||
@Controller
|
* @author zhengk/moshow
|
||||||
@Slf4j
|
*/
|
||||||
public class IndexController {
|
@Controller
|
||||||
|
@Slf4j
|
||||||
@Autowired
|
public class IndexController {
|
||||||
private GeneratorService generatorService;
|
|
||||||
|
@Autowired
|
||||||
@GetMapping("/")
|
private GeneratorService generatorService;
|
||||||
public String index() {
|
|
||||||
return "index";
|
@GetMapping("/")
|
||||||
}
|
public String index() {
|
||||||
|
return "index";
|
||||||
@PostMapping("/genCode")
|
}
|
||||||
@ResponseBody
|
|
||||||
public ReturnT<Map<String, String>> codeGenerate( ParamInfo paramInfo ) {
|
@PostMapping("/genCode")
|
||||||
|
@ResponseBody
|
||||||
try {
|
public ReturnT<Map<String, String>> codeGenerate(@RequestBody ParamInfo paramInfo ) {
|
||||||
|
|
||||||
if (StringUtils.isBlank(paramInfo.getTableSql())) {
|
try {
|
||||||
return new ReturnT<>(ReturnT.FAIL_CODE, "表结构信息不可为空");
|
|
||||||
}
|
if (StringUtils.isBlank(paramInfo.getTableSql())) {
|
||||||
|
return new ReturnT<>(ReturnT.FAIL_CODE, "表结构信息不可为空");
|
||||||
// parse table
|
}
|
||||||
ClassInfo classInfo = null;
|
|
||||||
switch (paramInfo.getDataType()){
|
// parse table
|
||||||
//parse json
|
ClassInfo classInfo = null;
|
||||||
case "json":classInfo = TableParseUtil.processJsonToClassInfo(paramInfo);break;
|
switch (paramInfo.getDataType()){
|
||||||
//parse sql by regex
|
//parse json
|
||||||
case "sql-regex":classInfo = TableParseUtil.processTableToClassInfoByRegex(paramInfo);break;
|
case "json":classInfo = TableParseUtil.processJsonToClassInfo(paramInfo);break;
|
||||||
//default parse sql by java
|
//parse sql by regex
|
||||||
default : classInfo = TableParseUtil.processTableIntoClassInfo(paramInfo);break;
|
case "sql-regex":classInfo = TableParseUtil.processTableToClassInfoByRegex(paramInfo);break;
|
||||||
}
|
//default parse sql by java
|
||||||
|
default : classInfo = TableParseUtil.processTableIntoClassInfo(paramInfo);break;
|
||||||
// process the param
|
}
|
||||||
Map<String, Object> params = new HashMap<String, Object>(8);
|
|
||||||
params.put("classInfo", classInfo);
|
// process the param
|
||||||
params.put("authorName", paramInfo.getAuthorName());
|
Map<String, Object> params = new HashMap<String, Object>(8);
|
||||||
params.put("packageName", paramInfo.getPackageName());
|
params.put("classInfo", classInfo);
|
||||||
params.put("returnUtil", paramInfo.getReturnUtil());
|
params.put("authorName", paramInfo.getAuthorName());
|
||||||
|
params.put("packageName", paramInfo.getPackageName());
|
||||||
// generate the code 需要加新的模板请在里面改
|
params.put("returnUtil", paramInfo.getReturnUtil());
|
||||||
Map<String, String> result = generatorService.getResultByParams(params);
|
|
||||||
|
log.info("generator table:"+(classInfo==null?"":classInfo.getTableName())
|
||||||
return new ReturnT<>(result);
|
+",field size:"+((classInfo==null||classInfo.getFieldList()==null)?"":classInfo.getFieldList().size()));
|
||||||
} catch (IOException | TemplateException e) {
|
|
||||||
log.error(e.getMessage(), e);
|
// generate the code 需要加新的模板请在里面改
|
||||||
return new ReturnT<>(ReturnT.FAIL_CODE, e.getMessage());
|
Map<String, String> result = generatorService.getResultByParams(params);
|
||||||
} catch (CodeGenerateException e) {
|
|
||||||
log.error(e.getMessage(), e);
|
return new ReturnT<>(result);
|
||||||
return new ReturnT<>(ReturnT.FAIL_CODE, e.getMessage());
|
} catch (IOException | TemplateException e) {
|
||||||
}
|
log.error(e.getMessage(), e);
|
||||||
|
return new ReturnT<>(ReturnT.FAIL_CODE, e.getMessage());
|
||||||
}
|
} catch (CodeGenerateException e) {
|
||||||
|
log.error(e.getMessage(), e);
|
||||||
}
|
return new ReturnT<>(ReturnT.FAIL_CODE, e.getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,425 +1,421 @@
|
|||||||
package com.softdev.system.generator.util;
|
package com.softdev.system.generator.util;
|
||||||
|
|
||||||
|
|
||||||
import cn.hutool.core.util.XmlUtil;
|
import com.alibaba.fastjson.JSON;
|
||||||
import com.alibaba.fastjson.JSON;
|
import com.alibaba.fastjson.JSONArray;
|
||||||
import com.alibaba.fastjson.JSONArray;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
import com.alibaba.fastjson.JSONObject;
|
import com.softdev.system.generator.entity.ClassInfo;
|
||||||
import com.softdev.system.generator.entity.ClassInfo;
|
import com.softdev.system.generator.entity.FieldInfo;
|
||||||
import com.softdev.system.generator.entity.FieldInfo;
|
import com.softdev.system.generator.entity.ParamInfo;
|
||||||
import com.softdev.system.generator.entity.ParamInfo;
|
|
||||||
import org.w3c.dom.Document;
|
import java.io.IOException;
|
||||||
|
import java.math.BigDecimal;
|
||||||
import java.io.IOException;
|
import java.util.ArrayList;
|
||||||
import java.math.BigDecimal;
|
import java.util.Date;
|
||||||
import java.util.ArrayList;
|
import java.util.List;
|
||||||
import java.util.Date;
|
import java.util.regex.Matcher;
|
||||||
import java.util.List;
|
import java.util.regex.Pattern;
|
||||||
import java.util.regex.Matcher;
|
|
||||||
import java.util.regex.Pattern;
|
/**
|
||||||
|
* @author zhengkai.blog.csdn.net
|
||||||
/**
|
*/
|
||||||
* @author zhengkai.blog.csdn.net
|
public class TableParseUtil {
|
||||||
*/
|
|
||||||
public class TableParseUtil {
|
/**
|
||||||
|
* 解析建表SQL生成代码(model-dao-xml)
|
||||||
/**
|
*
|
||||||
* 解析建表SQL生成代码(model-dao-xml)
|
* @param paramInfo
|
||||||
*
|
* @return
|
||||||
* @param paramInfo
|
*/
|
||||||
* @return
|
public static ClassInfo processTableIntoClassInfo(ParamInfo paramInfo)
|
||||||
*/
|
throws IOException {
|
||||||
public static ClassInfo processTableIntoClassInfo(ParamInfo paramInfo)
|
//process the param
|
||||||
throws IOException {
|
String tableSql=paramInfo.getTableSql();
|
||||||
//process the param
|
String nameCaseType=paramInfo.getNameCaseType();
|
||||||
String tableSql=paramInfo.getTableSql();
|
String tinyintTransType=paramInfo.getTinyintTransType();
|
||||||
String nameCaseType=paramInfo.getNameCaseType();
|
|
||||||
String tinyintTransType=paramInfo.getTinyintTransType();
|
if (tableSql==null || tableSql.trim().length()==0) {
|
||||||
|
throw new CodeGenerateException("Table structure can not be empty.");
|
||||||
if (tableSql==null || tableSql.trim().length()==0) {
|
}
|
||||||
throw new CodeGenerateException("Table structure can not be empty.");
|
//deal with special character
|
||||||
}
|
tableSql = tableSql.trim().replaceAll("'","`").replaceAll("\"","`").replaceAll(",",",").toLowerCase();
|
||||||
//deal with special character
|
//deal with java string copy \n"
|
||||||
tableSql = tableSql.trim().replaceAll("'","`").replaceAll("\"","`").replaceAll(",",",").toLowerCase();
|
tableSql = tableSql.trim().replaceAll("\\\\n`","").replaceAll("\\+","").replaceAll("``","`").replaceAll("\\\\","");
|
||||||
//deal with java string copy \n"
|
// table Name
|
||||||
System.out.println(tableSql);
|
String tableName = null;
|
||||||
tableSql = tableSql.trim().replaceAll("n`","").replaceAll("\\+","").replaceAll("``","`").replaceAll("\\\\","");
|
if (tableSql.contains("TABLE") && tableSql.contains("(")) {
|
||||||
System.out.println(tableSql);
|
tableName = tableSql.substring(tableSql.indexOf("TABLE")+5, tableSql.indexOf("("));
|
||||||
// table Name
|
} else if (tableSql.contains("table") && tableSql.contains("(")) {
|
||||||
String tableName = null;
|
tableName = tableSql.substring(tableSql.indexOf("table")+5, tableSql.indexOf("("));
|
||||||
if (tableSql.contains("TABLE") && tableSql.contains("(")) {
|
} else {
|
||||||
tableName = tableSql.substring(tableSql.indexOf("TABLE")+5, tableSql.indexOf("("));
|
throw new CodeGenerateException("Table structure anomaly.");
|
||||||
} else if (tableSql.contains("table") && tableSql.contains("(")) {
|
}
|
||||||
tableName = tableSql.substring(tableSql.indexOf("table")+5, tableSql.indexOf("("));
|
|
||||||
} else {
|
//新增处理create table if not exists members情况
|
||||||
throw new CodeGenerateException("Table structure anomaly.");
|
if (tableName.contains("if not exists")) {
|
||||||
}
|
tableName=tableName.replaceAll("if not exists","");
|
||||||
|
}
|
||||||
//新增处理create table if not exists members情况
|
|
||||||
if (tableName.contains("if not exists")) {
|
if (tableName.contains("`")) {
|
||||||
tableName=tableName.replaceAll("if not exists","");
|
tableName = tableName.substring(tableName.indexOf("`")+1, tableName.lastIndexOf("`"));
|
||||||
}
|
}else{
|
||||||
|
//空格开头的,需要替换掉\n\t空格
|
||||||
if (tableName.contains("`")) {
|
tableName=tableName.replaceAll(" ","").replaceAll("\n","").replaceAll("\t","");
|
||||||
tableName = tableName.substring(tableName.indexOf("`")+1, tableName.lastIndexOf("`"));
|
}
|
||||||
}else{
|
//优化对byeas`.`ct_bd_customerdiscount这种命名的支持
|
||||||
//空格开头的,需要替换掉\n\t空格
|
if(tableName.contains("`.`")){
|
||||||
tableName=tableName.replaceAll(" ","").replaceAll("\n","").replaceAll("\t","");
|
tableName=tableName.substring(tableName.indexOf("`.`")+3);
|
||||||
}
|
}else if(tableName.contains(".")){
|
||||||
//优化对byeas`.`ct_bd_customerdiscount这种命名的支持
|
//优化对likeu.members这种命名的支持
|
||||||
if(tableName.contains("`.`")){
|
tableName=tableName.substring(tableName.indexOf(".")+1);
|
||||||
tableName=tableName.substring(tableName.indexOf("`.`")+3);
|
}
|
||||||
}else if(tableName.contains(".")){
|
// class Name
|
||||||
//优化对likeu.members这种命名的支持
|
String className = StringUtils.upperCaseFirst(StringUtils.underlineToCamelCase(tableName));
|
||||||
tableName=tableName.substring(tableName.indexOf(".")+1);
|
if (className.contains("_")) {
|
||||||
}
|
className = className.replaceAll("_", "");
|
||||||
// class Name
|
}
|
||||||
String className = StringUtils.upperCaseFirst(StringUtils.underlineToCamelCase(tableName));
|
|
||||||
if (className.contains("_")) {
|
// class Comment
|
||||||
className = className.replaceAll("_", "");
|
String classComment = null;
|
||||||
}
|
//mysql是comment=,pgsql/oracle是comment on table,
|
||||||
|
if (tableSql.contains("comment=")) {
|
||||||
// class Comment
|
String classCommentTmp = tableSql.substring(tableSql.lastIndexOf("comment=")+8).replaceAll("`","").trim();
|
||||||
String classComment = null;
|
if (classCommentTmp.indexOf(" ")!=classCommentTmp.lastIndexOf(" ")) {
|
||||||
//mysql是comment=,pgsql/oracle是comment on table,
|
classCommentTmp = classCommentTmp.substring(classCommentTmp.indexOf(" ")+1, classCommentTmp.lastIndexOf(" "));
|
||||||
if (tableSql.contains("comment=")) {
|
}
|
||||||
String classCommentTmp = tableSql.substring(tableSql.lastIndexOf("comment=")+8).replaceAll("`","").trim();
|
if (classCommentTmp!=null && classCommentTmp.trim().length()>0) {
|
||||||
if (classCommentTmp.indexOf(" ")!=classCommentTmp.lastIndexOf(" ")) {
|
classComment = classCommentTmp;
|
||||||
classCommentTmp = classCommentTmp.substring(classCommentTmp.indexOf(" ")+1, classCommentTmp.lastIndexOf(" "));
|
}else{
|
||||||
}
|
//修复表备注为空问题
|
||||||
if (classCommentTmp!=null && classCommentTmp.trim().length()>0) {
|
classComment = className;
|
||||||
classComment = classCommentTmp;
|
}
|
||||||
}else{
|
}else if(tableSql.contains("comment on table")) {
|
||||||
//修复表备注为空问题
|
//COMMENT ON TABLE CT_BAS_FEETYPE IS 'CT_BAS_FEETYPE';
|
||||||
classComment = className;
|
String classCommentTmp = tableSql.substring(tableSql.lastIndexOf("comment on table")+17).trim();
|
||||||
}
|
//证明这是一个常规的COMMENT ON TABLE xxx IS 'xxxx'
|
||||||
}else if(tableSql.contains("comment on table")) {
|
if (classCommentTmp.contains("`")) {
|
||||||
//COMMENT ON TABLE CT_BAS_FEETYPE IS 'CT_BAS_FEETYPE';
|
classCommentTmp = classCommentTmp.substring(classCommentTmp.indexOf("`")+1);
|
||||||
String classCommentTmp = tableSql.substring(tableSql.lastIndexOf("comment on table")+17).trim();
|
classCommentTmp = classCommentTmp.substring(0,classCommentTmp.indexOf("`"));
|
||||||
//证明这是一个常规的COMMENT ON TABLE xxx IS 'xxxx'
|
classComment = classCommentTmp;
|
||||||
if (classCommentTmp.contains("`")) {
|
}else{
|
||||||
classCommentTmp = classCommentTmp.substring(classCommentTmp.indexOf("`")+1);
|
//非常规的没法分析
|
||||||
classCommentTmp = classCommentTmp.substring(0,classCommentTmp.indexOf("`"));
|
classComment = tableName;
|
||||||
classComment = classCommentTmp;
|
}
|
||||||
}else{
|
}else{
|
||||||
//非常规的没法分析
|
//修复表备注为空问题
|
||||||
classComment = tableName;
|
classComment = tableName;
|
||||||
}
|
}
|
||||||
}else{
|
//如果备注跟;混在一起,需要替换掉
|
||||||
//修复表备注为空问题
|
classComment=classComment.replaceAll(";","");
|
||||||
classComment = tableName;
|
// field List
|
||||||
}
|
List<FieldInfo> fieldList = new ArrayList<FieldInfo>();
|
||||||
//如果备注跟;混在一起,需要替换掉
|
|
||||||
classComment=classComment.replaceAll(";","");
|
// 正常( ) 内的一定是字段相关的定义。
|
||||||
// field List
|
String fieldListTmp = tableSql.substring(tableSql.indexOf("(")+1, tableSql.lastIndexOf(")"));
|
||||||
List<FieldInfo> fieldList = new ArrayList<FieldInfo>();
|
|
||||||
|
// 匹配 comment,替换备注里的小逗号, 防止不小心被当成切割符号切割
|
||||||
// 正常( ) 内的一定是字段相关的定义。
|
String commentPattenStr1="comment `(.*?)\\`";
|
||||||
String fieldListTmp = tableSql.substring(tableSql.indexOf("(")+1, tableSql.lastIndexOf(")"));
|
Matcher matcher1 = Pattern.compile(commentPattenStr1).matcher(fieldListTmp);
|
||||||
|
while(matcher1.find()){
|
||||||
// 匹配 comment,替换备注里的小逗号, 防止不小心被当成切割符号切割
|
|
||||||
String commentPattenStr1="comment `(.*?)\\`";
|
String commentTmp = matcher1.group();
|
||||||
Matcher matcher1 = Pattern.compile(commentPattenStr1).matcher(fieldListTmp);
|
//2018-9-27 zhengk 不替换,只处理,支持COMMENT评论里面多种注释
|
||||||
while(matcher1.find()){
|
//commentTmp = commentTmp.replaceAll("\\ comment `|\\`", " "); // "\\{|\\}"
|
||||||
|
|
||||||
String commentTmp = matcher1.group();
|
if (commentTmp.contains(",")) {
|
||||||
//2018-9-27 zhengk 不替换,只处理,支持COMMENT评论里面多种注释
|
String commentTmpFinal = commentTmp.replaceAll(",", ",");
|
||||||
//commentTmp = commentTmp.replaceAll("\\ comment `|\\`", " "); // "\\{|\\}"
|
fieldListTmp = fieldListTmp.replace(matcher1.group(), commentTmpFinal);
|
||||||
|
}
|
||||||
if (commentTmp.contains(",")) {
|
}
|
||||||
String commentTmpFinal = commentTmp.replaceAll(",", ",");
|
//2018-10-18 zhengkai 新增支持double(10, 2)等类型中有英文逗号的特殊情况
|
||||||
fieldListTmp = fieldListTmp.replace(matcher1.group(), commentTmpFinal);
|
String commentPattenStr2="\\`(.*?)\\`";
|
||||||
}
|
Matcher matcher2 = Pattern.compile(commentPattenStr2).matcher(fieldListTmp);
|
||||||
}
|
while(matcher2.find()){
|
||||||
//2018-10-18 zhengkai 新增支持double(10, 2)等类型中有英文逗号的特殊情况
|
String commentTmp2 = matcher2.group();
|
||||||
String commentPattenStr2="\\`(.*?)\\`";
|
if (commentTmp2.contains(",")) {
|
||||||
Matcher matcher2 = Pattern.compile(commentPattenStr2).matcher(fieldListTmp);
|
String commentTmpFinal = commentTmp2.replaceAll(",", ",").replaceAll("\\(", "(").replaceAll("\\)", ")");
|
||||||
while(matcher2.find()){
|
fieldListTmp = fieldListTmp.replace(matcher2.group(), commentTmpFinal);
|
||||||
String commentTmp2 = matcher2.group();
|
}
|
||||||
if (commentTmp2.contains(",")) {
|
}
|
||||||
String commentTmpFinal = commentTmp2.replaceAll(",", ",").replaceAll("\\(", "(").replaceAll("\\)", ")");
|
//2018-10-18 zhengkai 新增支持double(10, 2)等类型中有英文逗号的特殊情况
|
||||||
fieldListTmp = fieldListTmp.replace(matcher2.group(), commentTmpFinal);
|
String commentPattenStr3="\\((.*?)\\)";
|
||||||
}
|
Matcher matcher3 = Pattern.compile(commentPattenStr3).matcher(fieldListTmp);
|
||||||
}
|
while(matcher3.find()){
|
||||||
//2018-10-18 zhengkai 新增支持double(10, 2)等类型中有英文逗号的特殊情况
|
String commentTmp3 = matcher3.group();
|
||||||
String commentPattenStr3="\\((.*?)\\)";
|
if (commentTmp3.contains(",")) {
|
||||||
Matcher matcher3 = Pattern.compile(commentPattenStr3).matcher(fieldListTmp);
|
String commentTmpFinal = commentTmp3.replaceAll(",", ",");
|
||||||
while(matcher3.find()){
|
fieldListTmp = fieldListTmp.replace(matcher3.group(), commentTmpFinal);
|
||||||
String commentTmp3 = matcher3.group();
|
}
|
||||||
if (commentTmp3.contains(",")) {
|
}
|
||||||
String commentTmpFinal = commentTmp3.replaceAll(",", ",");
|
String[] fieldLineList = fieldListTmp.split(",");
|
||||||
fieldListTmp = fieldListTmp.replace(matcher3.group(), commentTmpFinal);
|
if (fieldLineList.length > 0) {
|
||||||
}
|
int i=0;
|
||||||
}
|
//i为了解决primary key关键字出现的地方,出现在前3行,一般和id有关
|
||||||
String[] fieldLineList = fieldListTmp.split(",");
|
for (String columnLine :fieldLineList) {
|
||||||
if (fieldLineList.length > 0) {
|
i++;
|
||||||
int i=0;
|
columnLine = columnLine.replaceAll("\n","").replaceAll("\t","").trim();
|
||||||
//i为了解决primary key关键字出现的地方,出现在前3行,一般和id有关
|
// `userid` int(11) NOT NULL AUTO_INCREMENT COMMENT '用户ID',
|
||||||
for (String columnLine :fieldLineList) {
|
// 2018-9-18 zhengk 修改为contains,提升匹配率和匹配不按照规矩出牌的语句
|
||||||
i++;
|
// 2018-11-8 zhengkai 修复tornadoorz反馈的KEY FK_permission_id (permission_id),KEY FK_role_id (role_id)情况
|
||||||
columnLine = columnLine.replaceAll("\n","").replaceAll("\t","").trim();
|
// 2019-2-22 zhengkai 要在条件中使用复杂的表达式
|
||||||
// `userid` int(11) NOT NULL AUTO_INCREMENT COMMENT '用户ID',
|
// 2019-4-29 zhengkai 优化对普通和特殊storage关键字的判断(感谢@AhHeadFloating的反馈 )
|
||||||
// 2018-9-18 zhengk 修改为contains,提升匹配率和匹配不按照规矩出牌的语句
|
boolean specialFlag=(!columnLine.contains("key ")&&!columnLine.contains("constraint")&&!columnLine.contains("using")&&!columnLine.contains("unique")
|
||||||
// 2018-11-8 zhengkai 修复tornadoorz反馈的KEY FK_permission_id (permission_id),KEY FK_role_id (role_id)情况
|
&&!(columnLine.contains("primary ")&&columnLine.indexOf("storage")+3>columnLine.indexOf("("))
|
||||||
// 2019-2-22 zhengkai 要在条件中使用复杂的表达式
|
&&!columnLine.contains("pctincrease")
|
||||||
// 2019-4-29 zhengkai 优化对普通和特殊storage关键字的判断(感谢@AhHeadFloating的反馈 )
|
&&!columnLine.contains("buffer_pool")&&!columnLine.contains("tablespace")
|
||||||
boolean specialFlag=(!columnLine.contains("key ")&&!columnLine.contains("constraint")&&!columnLine.contains("using")&&!columnLine.contains("unique")
|
&&!(columnLine.contains("primary ")&&i>3));
|
||||||
&&!(columnLine.contains("primary ")&&columnLine.indexOf("storage")+3>columnLine.indexOf("("))
|
if (specialFlag){
|
||||||
&&!columnLine.contains("pctincrease")
|
//如果是oracle的number(x,x),可能出现最后分割残留的,x),这里做排除处理
|
||||||
&&!columnLine.contains("buffer_pool")&&!columnLine.contains("tablespace")
|
if(columnLine.length()<5) {continue;}
|
||||||
&&!(columnLine.contains("primary ")&&i>3));
|
//2018-9-16 zhengkai 支持'符号以及空格的oracle语句// userid` int(11) NOT NULL AUTO_INCREMENT COMMENT '用户ID',
|
||||||
if (specialFlag){
|
String columnName = "";
|
||||||
//如果是oracle的number(x,x),可能出现最后分割残留的,x),这里做排除处理
|
columnLine=columnLine.replaceAll("`"," ").replaceAll("\""," ").replaceAll("'","").replaceAll(" "," ").trim();
|
||||||
if(columnLine.length()<5) {continue;}
|
//如果遇到username varchar(65) default '' not null,这种情况,判断第一个空格是否比第一个引号前
|
||||||
//2018-9-16 zhengkai 支持'符号以及空格的oracle语句// userid` int(11) NOT NULL AUTO_INCREMENT COMMENT '用户ID',
|
columnName = columnLine.substring(0, columnLine.indexOf(" "));
|
||||||
String columnName = "";
|
// field Name
|
||||||
columnLine=columnLine.replaceAll("`"," ").replaceAll("\""," ").replaceAll("'","").replaceAll(" "," ").trim();
|
// 2019-09-08 yj 添加是否下划线转换为驼峰的判断
|
||||||
//如果遇到username varchar(65) default '' not null,这种情况,判断第一个空格是否比第一个引号前
|
String fieldName=null;
|
||||||
columnName = columnLine.substring(0, columnLine.indexOf(" "));
|
if(ParamInfo.NAME_CASE_TYPE.CAMEL_CASE.equals(nameCaseType)){
|
||||||
// field Name
|
fieldName = StringUtils.lowerCaseFirst(StringUtils.underlineToCamelCase(columnName));
|
||||||
// 2019-09-08 yj 添加是否下划线转换为驼峰的判断
|
if (fieldName.contains("_")) {
|
||||||
String fieldName=null;
|
fieldName = fieldName.replaceAll("_", "");
|
||||||
if(ParamInfo.NAME_CASE_TYPE.CAMEL_CASE.equals(nameCaseType)){
|
}
|
||||||
fieldName = StringUtils.lowerCaseFirst(StringUtils.underlineToCamelCase(columnName));
|
}else if(ParamInfo.NAME_CASE_TYPE.UNDER_SCORE_CASE.equals(nameCaseType)){
|
||||||
if (fieldName.contains("_")) {
|
fieldName = StringUtils.lowerCaseFirst(columnName);
|
||||||
fieldName = fieldName.replaceAll("_", "");
|
}else if(ParamInfo.NAME_CASE_TYPE.UPPER_UNDER_SCORE_CASE.equals(nameCaseType)){
|
||||||
}
|
fieldName = StringUtils.lowerCaseFirst(columnName.toUpperCase());
|
||||||
}else if(ParamInfo.NAME_CASE_TYPE.UNDER_SCORE_CASE.equals(nameCaseType)){
|
}else{
|
||||||
fieldName = StringUtils.lowerCaseFirst(columnName);
|
fieldName=columnName;
|
||||||
}else if(ParamInfo.NAME_CASE_TYPE.UPPER_UNDER_SCORE_CASE.equals(nameCaseType)){
|
}
|
||||||
fieldName = StringUtils.lowerCaseFirst(columnName.toUpperCase());
|
|
||||||
}else{
|
// field class
|
||||||
fieldName=columnName;
|
columnLine = columnLine.substring(columnLine.indexOf("`")+1).trim();
|
||||||
}
|
// int(11) NOT NULL AUTO_INCREMENT COMMENT '用户ID',
|
||||||
|
String fieldClass = Object.class.getSimpleName();
|
||||||
// field class
|
//2018-9-16 zhengk 补充char/clob/blob/json等类型,如果类型未知,默认为String
|
||||||
columnLine = columnLine.substring(columnLine.indexOf("`")+1).trim();
|
//2018-11-22 lshz0088 处理字段类型的时候,不严谨columnLine.contains(" int") 类似这种的,可在前后适当加一些空格之类的加以区分,否则当我的字段包含这些字符的时候,产生类型判断问题。
|
||||||
// int(11) NOT NULL AUTO_INCREMENT COMMENT '用户ID',
|
if (columnLine.contains(" int") || columnLine.contains("smallint")) {
|
||||||
String fieldClass = Object.class.getSimpleName();
|
fieldClass = Integer.class.getSimpleName();
|
||||||
//2018-9-16 zhengk 补充char/clob/blob/json等类型,如果类型未知,默认为String
|
} else if (columnLine.contains("bigint")) {
|
||||||
//2018-11-22 lshz0088 处理字段类型的时候,不严谨columnLine.contains(" int") 类似这种的,可在前后适当加一些空格之类的加以区分,否则当我的字段包含这些字符的时候,产生类型判断问题。
|
fieldClass = Long.class.getSimpleName();
|
||||||
if (columnLine.contains(" int") || columnLine.contains("smallint")) {
|
} else if (columnLine.contains("float")) {
|
||||||
fieldClass = Integer.class.getSimpleName();
|
fieldClass = Float.class.getSimpleName();
|
||||||
} else if (columnLine.contains("bigint")) {
|
} else if (columnLine.contains("double")) {
|
||||||
fieldClass = Long.class.getSimpleName();
|
fieldClass = Double.class.getSimpleName();
|
||||||
} else if (columnLine.contains("float")) {
|
} else if (columnLine.contains("time") || columnLine.contains(" date") || columnLine.contains("datetime") || columnLine.contains("timestamp")) {
|
||||||
fieldClass = Float.class.getSimpleName();
|
fieldClass = Date.class.getSimpleName();
|
||||||
} else if (columnLine.contains("double")) {
|
} else if (columnLine.contains("varchar") || columnLine.contains(" text")|| columnLine.contains("char")
|
||||||
fieldClass = Double.class.getSimpleName();
|
|| columnLine.contains("clob")||columnLine.contains("blob")||columnLine.contains("json")) {
|
||||||
} else if (columnLine.contains("time") || columnLine.contains("date") || columnLine.contains("datetime") || columnLine.contains("timestamp")) {
|
fieldClass = String.class.getSimpleName();
|
||||||
fieldClass = Date.class.getSimpleName();
|
} else if (columnLine.contains("decimal")||columnLine.contains(" number")) {
|
||||||
} else if (columnLine.contains("varchar") || columnLine.contains(" text")|| columnLine.contains("char")
|
//2018-11-22 lshz0088 建议对number类型增加int,long,BigDecimal的区分判断
|
||||||
|| columnLine.contains("clob")||columnLine.contains("blob")||columnLine.contains("json")) {
|
//如果startKh大于等于0,则表示有设置取值范围
|
||||||
fieldClass = String.class.getSimpleName();
|
int startKh=columnLine.indexOf("(");
|
||||||
} else if (columnLine.contains("decimal")||columnLine.contains(" number")) {
|
if(startKh>=0){
|
||||||
//2018-11-22 lshz0088 建议对number类型增加int,long,BigDecimal的区分判断
|
int endKh=columnLine.indexOf(")",startKh);
|
||||||
//如果startKh大于等于0,则表示有设置取值范围
|
String[] fanwei=columnLine.substring(startKh+1,endKh).split(",");
|
||||||
int startKh=columnLine.indexOf("(");
|
//2019-1-5 zhengk 修复@arthaschan反馈的超出范围错误
|
||||||
if(startKh>=0){
|
//System.out.println("fanwei"+ JSON.toJSONString(fanwei));
|
||||||
int endKh=columnLine.indexOf(")",startKh);
|
// //number(20,6) fanwei["20","6"]
|
||||||
String[] fanwei=columnLine.substring(startKh+1,endKh).split(",");
|
// //number(0,6) fanwei["0","6"]
|
||||||
//2019-1-5 zhengk 修复@arthaschan反馈的超出范围错误
|
// //number(20,0) fanwei["20","0"]
|
||||||
//System.out.println("fanwei"+ JSON.toJSONString(fanwei));
|
// //number(20) fanwei["20"]
|
||||||
// //number(20,6) fanwei["20","6"]
|
//如果括号里是1位或者2位且第二位为0,则进行特殊处理。只有有小数位,都设置为BigDecimal。
|
||||||
// //number(0,6) fanwei["0","6"]
|
if((fanwei.length>1&&"0".equals(fanwei[1]))||fanwei.length==1){
|
||||||
// //number(20,0) fanwei["20","0"]
|
int length=Integer.parseInt(fanwei[0]);
|
||||||
// //number(20) fanwei["20"]
|
if(fanwei.length>1) {
|
||||||
//如果括号里是1位或者2位且第二位为0,则进行特殊处理。只有有小数位,都设置为BigDecimal。
|
length=Integer.valueOf(fanwei[1]);
|
||||||
if((fanwei.length>1&&"0".equals(fanwei[1]))||fanwei.length==1){
|
}
|
||||||
int length=Integer.parseInt(fanwei[0]);
|
//数字范围9位及一下用Integer,大的用Long
|
||||||
if(fanwei.length>1) {
|
if(length<=9){
|
||||||
length=Integer.valueOf(fanwei[1]);
|
fieldClass = Integer.class.getSimpleName();
|
||||||
}
|
}else{
|
||||||
//数字范围9位及一下用Integer,大的用Long
|
fieldClass = Long.class.getSimpleName();
|
||||||
if(length<=9){
|
}
|
||||||
fieldClass = Integer.class.getSimpleName();
|
}else{
|
||||||
}else{
|
//有小数位数一律使用BigDecimal
|
||||||
fieldClass = Long.class.getSimpleName();
|
fieldClass = BigDecimal.class.getSimpleName();
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
//有小数位数一律使用BigDecimal
|
fieldClass = BigDecimal.class.getSimpleName();
|
||||||
fieldClass = BigDecimal.class.getSimpleName();
|
}
|
||||||
}
|
} else if (columnLine.contains("boolean")) {
|
||||||
}else{
|
//20190910 MOSHOW.K.ZHENG 新增对boolean的处理(感谢@violinxsc的反馈)以及修复tinyint类型字段无法生成boolean类型问题(感谢@hahaYhui的反馈)
|
||||||
fieldClass = BigDecimal.class.getSimpleName();
|
fieldClass = Boolean.class.getSimpleName();
|
||||||
}
|
} else if (columnLine.contains("tinyint") ) {
|
||||||
} else if (columnLine.contains("boolean")) {
|
//20191115 MOSHOW.K.ZHENG 支持对tinyint的特殊处理
|
||||||
//20190910 MOSHOW.K.ZHENG 新增对boolean的处理(感谢@violinxsc的反馈)以及修复tinyint类型字段无法生成boolean类型问题(感谢@hahaYhui的反馈)
|
fieldClass=tinyintTransType;
|
||||||
fieldClass = Boolean.class.getSimpleName();
|
} else {
|
||||||
} else if (columnLine.contains("tinyint") ) {
|
fieldClass = String.class.getSimpleName();
|
||||||
//20191115 MOSHOW.K.ZHENG 支持对tinyint的特殊处理
|
}
|
||||||
fieldClass=tinyintTransType;
|
|
||||||
} else {
|
// field comment,MySQL的一般位于field行,而pgsql和oralce多位于后面。
|
||||||
fieldClass = String.class.getSimpleName();
|
String fieldComment = null;
|
||||||
}
|
if(tableSql.contains("comment on column")&&(tableSql.contains("."+columnName+" is ")||tableSql.contains(".`"+columnName+"` is"))){
|
||||||
|
//新增对pgsql/oracle的字段备注支持
|
||||||
// field comment,MySQL的一般位于field行,而pgsql和oralce多位于后面。
|
//COMMENT ON COLUMN public.check_info.check_name IS '检查者名称';
|
||||||
String fieldComment = null;
|
//2018-11-22 lshz0088 正则表达式的点号前面应该加上两个反斜杠,否则会认为是任意字符
|
||||||
if(tableSql.contains("comment on column")&&(tableSql.contains("."+columnName+" is ")||tableSql.contains(".`"+columnName+"` is"))){
|
//2019-4-29 zhengkai 优化对oracle注释comment on column的支持(@liukex)
|
||||||
//新增对pgsql/oracle的字段备注支持
|
tableSql=tableSql.replaceAll(".`"+columnName+"` is","."+columnName+" is");
|
||||||
//COMMENT ON COLUMN public.check_info.check_name IS '检查者名称';
|
Matcher columnCommentMatcher = Pattern.compile("\\."+columnName+" is `").matcher(tableSql);
|
||||||
//2018-11-22 lshz0088 正则表达式的点号前面应该加上两个反斜杠,否则会认为是任意字符
|
fieldComment=columnName;
|
||||||
//2019-4-29 zhengkai 优化对oracle注释comment on column的支持(@liukex)
|
while(columnCommentMatcher.find()){
|
||||||
tableSql=tableSql.replaceAll(".`"+columnName+"` is","."+columnName+" is");
|
String columnCommentTmp = columnCommentMatcher.group();
|
||||||
Matcher columnCommentMatcher = Pattern.compile("\\."+columnName+" is `").matcher(tableSql);
|
System.out.println(columnCommentTmp);
|
||||||
fieldComment=columnName;
|
fieldComment = tableSql.substring(tableSql.indexOf(columnCommentTmp)+columnCommentTmp.length()).trim();
|
||||||
while(columnCommentMatcher.find()){
|
fieldComment = fieldComment.substring(0,fieldComment.indexOf("`")).trim();
|
||||||
String columnCommentTmp = columnCommentMatcher.group();
|
}
|
||||||
System.out.println(columnCommentTmp);
|
}else if (columnLine.contains("comment")) {
|
||||||
fieldComment = tableSql.substring(tableSql.indexOf(columnCommentTmp)+columnCommentTmp.length()).trim();
|
String commentTmp = columnLine.substring(columnLine.indexOf("comment")+7).trim();
|
||||||
fieldComment = fieldComment.substring(0,fieldComment.indexOf("`")).trim();
|
// '用户ID',
|
||||||
}
|
if (commentTmp.contains("`") || commentTmp.indexOf("`")!=commentTmp.lastIndexOf("`")) {
|
||||||
}else if (columnLine.contains("comment")) {
|
commentTmp = commentTmp.substring(commentTmp.indexOf("`")+1, commentTmp.lastIndexOf("`"));
|
||||||
String commentTmp = columnLine.substring(columnLine.indexOf("comment")+7).trim();
|
}
|
||||||
// '用户ID',
|
//解决最后一句是评论,无主键且连着)的问题:album_id int(3) default '1' null comment '相册id:0 代表头像 1代表照片墙')
|
||||||
if (commentTmp.contains("`") || commentTmp.indexOf("`")!=commentTmp.lastIndexOf("`")) {
|
if(commentTmp.contains(")")){
|
||||||
commentTmp = commentTmp.substring(commentTmp.indexOf("`")+1, commentTmp.lastIndexOf("`"));
|
commentTmp = commentTmp.substring(0, commentTmp.lastIndexOf(")")+1);
|
||||||
}
|
}
|
||||||
//解决最后一句是评论,无主键且连着)的问题:album_id int(3) default '1' null comment '相册id:0 代表头像 1代表照片墙')
|
fieldComment = commentTmp;
|
||||||
if(commentTmp.contains(")")){
|
}else{
|
||||||
commentTmp = commentTmp.substring(0, commentTmp.lastIndexOf(")")+1);
|
//修复comment不存在导致报错的问题
|
||||||
}
|
fieldComment = columnName;
|
||||||
fieldComment = commentTmp;
|
}
|
||||||
}else{
|
|
||||||
//修复comment不存在导致报错的问题
|
FieldInfo fieldInfo = new FieldInfo();
|
||||||
fieldComment = columnName;
|
fieldInfo.setColumnName(columnName);
|
||||||
}
|
fieldInfo.setFieldName(fieldName);
|
||||||
|
fieldInfo.setFieldClass(fieldClass);
|
||||||
FieldInfo fieldInfo = new FieldInfo();
|
fieldInfo.setFieldComment(fieldComment);
|
||||||
fieldInfo.setColumnName(columnName);
|
|
||||||
fieldInfo.setFieldName(fieldName);
|
fieldList.add(fieldInfo);
|
||||||
fieldInfo.setFieldClass(fieldClass);
|
}
|
||||||
fieldInfo.setFieldComment(fieldComment);
|
}
|
||||||
|
}
|
||||||
fieldList.add(fieldInfo);
|
|
||||||
}
|
if (fieldList.size() < 1) {
|
||||||
}
|
throw new CodeGenerateException("表结构分析失败,请检查语句或者提交issue给我");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fieldList.size() < 1) {
|
ClassInfo codeJavaInfo = new ClassInfo();
|
||||||
throw new CodeGenerateException("表结构分析失败,请检查语句或者提交issue给我");
|
codeJavaInfo.setTableName(tableName);
|
||||||
}
|
codeJavaInfo.setClassName(className);
|
||||||
|
codeJavaInfo.setClassComment(classComment);
|
||||||
ClassInfo codeJavaInfo = new ClassInfo();
|
codeJavaInfo.setFieldList(fieldList);
|
||||||
codeJavaInfo.setTableName(tableName);
|
|
||||||
codeJavaInfo.setClassName(className);
|
return codeJavaInfo;
|
||||||
codeJavaInfo.setClassComment(classComment);
|
}
|
||||||
codeJavaInfo.setFieldList(fieldList);
|
/**
|
||||||
|
* parse JSON
|
||||||
return codeJavaInfo;
|
* @param paramInfo
|
||||||
}
|
* @return
|
||||||
/**
|
*/
|
||||||
* parse JSON
|
public static ClassInfo processJsonToClassInfo(ParamInfo paramInfo){
|
||||||
* @param paramInfo
|
ClassInfo codeJavaInfo = new ClassInfo();
|
||||||
* @return
|
codeJavaInfo.setTableName("JsonDto");
|
||||||
*/
|
codeJavaInfo.setClassName("JsonDto");
|
||||||
public static ClassInfo processJsonToClassInfo(ParamInfo paramInfo){
|
codeJavaInfo.setClassComment("JsonDto");
|
||||||
ClassInfo codeJavaInfo = new ClassInfo();
|
|
||||||
codeJavaInfo.setTableName("JsonDto");
|
//support children json if forget to add '{' in front of json
|
||||||
codeJavaInfo.setClassName("JsonDto");
|
if(paramInfo.getTableSql().trim().startsWith("\"")){
|
||||||
codeJavaInfo.setClassComment("JsonDto");
|
paramInfo.setTableSql("{"+paramInfo.getTableSql());
|
||||||
|
}
|
||||||
//support children json if forget to add '{' in front of json
|
if(JSON.isValid(paramInfo.getTableSql())){
|
||||||
if(paramInfo.getTableSql().trim().startsWith("\"")){
|
if(paramInfo.getTableSql().trim().startsWith("{")){
|
||||||
paramInfo.setTableSql("{"+paramInfo.getTableSql());
|
JSONObject jsonObject = JSONObject.parseObject(paramInfo.getTableSql().trim());
|
||||||
}
|
//parse FieldList by JSONObject
|
||||||
if(JSON.isValid(paramInfo.getTableSql())){
|
codeJavaInfo.setFieldList(processJsonObjectToFieldList(jsonObject));
|
||||||
if(paramInfo.getTableSql().trim().startsWith("{")){
|
}else if(paramInfo.getTableSql().trim().startsWith("[")){
|
||||||
JSONObject jsonObject = JSONObject.parseObject(paramInfo.getTableSql().trim());
|
JSONArray jsonArray=JSONArray.parseArray(paramInfo.getTableSql().trim());
|
||||||
//parse FieldList by JSONObject
|
//parse FieldList by JSONObject
|
||||||
codeJavaInfo.setFieldList(processJsonObjectToFieldList(jsonObject));
|
codeJavaInfo.setFieldList(processJsonObjectToFieldList(jsonArray.getJSONObject(0)));
|
||||||
}else if(paramInfo.getTableSql().trim().startsWith("[")){
|
}
|
||||||
JSONArray jsonArray=JSONArray.parseArray(paramInfo.getTableSql().trim());
|
}
|
||||||
//parse FieldList by JSONObject
|
|
||||||
codeJavaInfo.setFieldList(processJsonObjectToFieldList(jsonArray.getJSONObject(0)));
|
return codeJavaInfo;
|
||||||
}
|
}
|
||||||
}
|
/**
|
||||||
|
* parse SQL by regex
|
||||||
return codeJavaInfo;
|
* @author https://github.com/ydq
|
||||||
}
|
* @param paramInfo
|
||||||
/**
|
* @return
|
||||||
* parse SQL by regex
|
*/
|
||||||
* @author https://github.com/ydq
|
public static ClassInfo processTableToClassInfoByRegex(ParamInfo paramInfo){
|
||||||
* @param paramInfo
|
// field List
|
||||||
* @return
|
List<FieldInfo> fieldList = new ArrayList<FieldInfo>();
|
||||||
*/
|
//return classInfo
|
||||||
public static ClassInfo processTableToClassInfoByRegex(ParamInfo paramInfo){
|
ClassInfo codeJavaInfo = new ClassInfo();
|
||||||
// field List
|
|
||||||
List<FieldInfo> fieldList = new ArrayList<FieldInfo>();
|
//匹配整个ddl,将ddl分为表名,列sql部分,表注释
|
||||||
//return classInfo
|
String DDL_PATTEN_STR="\\s*create\\s+table\\s+(?<tableName>\\S+)[^\\(]*\\((?<columnsSQL>[\\s\\S]+)\\)[^\\)]+?(comment\\s*(=|on\\s+table)\\s*'(?<tableComment>.*?)'\\s*;?)?$";
|
||||||
ClassInfo codeJavaInfo = new ClassInfo();
|
|
||||||
|
Pattern DDL_PATTERN = Pattern.compile(DDL_PATTEN_STR, Pattern.CASE_INSENSITIVE);
|
||||||
//匹配整个ddl,将ddl分为表名,列sql部分,表注释
|
|
||||||
String DDL_PATTEN_STR="\\s*create\\s+table\\s+(?<tableName>\\S+)[^\\(]*\\((?<columnsSQL>[\\s\\S]+)\\)[^\\)]+?(comment\\s*(=|on\\s+table)\\s*'(?<tableComment>.*?)'\\s*;?)?$";
|
//匹配列sql部分,分别解析每一列的列名 类型 和列注释
|
||||||
|
String COL_PATTERN_STR="\\s*(?<fieldName>\\S+)\\s+(?<fieldType>\\w+)\\s*(?:\\([\\s\\d,]+\\))?((?!comment).)*(comment\\s*'(?<fieldComment>.*?)')?\\s*(,|$)";
|
||||||
Pattern DDL_PATTERN = Pattern.compile(DDL_PATTEN_STR, Pattern.CASE_INSENSITIVE);
|
|
||||||
|
Pattern COL_PATTERN = Pattern.compile(COL_PATTERN_STR, Pattern.CASE_INSENSITIVE);
|
||||||
//匹配列sql部分,分别解析每一列的列名 类型 和列注释
|
|
||||||
String COL_PATTERN_STR="\\s*(?<fieldName>\\S+)\\s+(?<fieldType>\\w+)\\s*(?:\\([\\s\\d,]+\\))?((?!comment).)*(comment\\s*'(?<fieldComment>.*?)')?\\s*(,|$)";
|
Matcher matcher = DDL_PATTERN.matcher(paramInfo.getTableSql().trim());
|
||||||
|
if (matcher.find()){
|
||||||
Pattern COL_PATTERN = Pattern.compile(COL_PATTERN_STR, Pattern.CASE_INSENSITIVE);
|
String tableName = matcher.group("tableName");
|
||||||
|
String tableComment = matcher.group("tableComment");
|
||||||
Matcher matcher = DDL_PATTERN.matcher(paramInfo.getTableSql().trim());
|
codeJavaInfo.setTableName(tableName.replaceAll("'",""));
|
||||||
if (matcher.find()){
|
codeJavaInfo.setClassName(tableName.replaceAll("'",""));
|
||||||
String tableName = matcher.group("tableName");
|
codeJavaInfo.setClassComment(tableComment.replaceAll("'",""));
|
||||||
String tableComment = matcher.group("tableComment");
|
String columnsSQL = matcher.group("columnsSQL");
|
||||||
codeJavaInfo.setTableName(tableName.replaceAll("'",""));
|
if (columnsSQL != null && columnsSQL.length() > 0){
|
||||||
codeJavaInfo.setClassName(tableName.replaceAll("'",""));
|
Matcher colMatcher = COL_PATTERN.matcher(columnsSQL);
|
||||||
codeJavaInfo.setClassComment(tableComment.replaceAll("'",""));
|
while (colMatcher.find()){
|
||||||
String columnsSQL = matcher.group("columnsSQL");
|
String fieldName = colMatcher.group("fieldName");
|
||||||
if (columnsSQL != null && columnsSQL.length() > 0){
|
String fieldType = colMatcher.group("fieldType");
|
||||||
Matcher colMatcher = COL_PATTERN.matcher(columnsSQL);
|
String fieldComment = colMatcher.group("fieldComment");
|
||||||
while (colMatcher.find()){
|
if (!"key".equalsIgnoreCase(fieldType)){
|
||||||
String fieldName = colMatcher.group("fieldName");
|
FieldInfo fieldInfo = new FieldInfo();
|
||||||
String fieldType = colMatcher.group("fieldType");
|
fieldInfo.setFieldName(fieldName.replaceAll("'",""));
|
||||||
String fieldComment = colMatcher.group("fieldComment");
|
fieldInfo.setColumnName(fieldName.replaceAll("'",""));
|
||||||
if (!"key".equalsIgnoreCase(fieldType)){
|
fieldInfo.setFieldClass(fieldType.replaceAll("'",""));
|
||||||
FieldInfo fieldInfo = new FieldInfo();
|
fieldInfo.setFieldComment(fieldComment.replaceAll("'",""));
|
||||||
fieldInfo.setFieldName(fieldName.replaceAll("'",""));
|
fieldList.add(fieldInfo);
|
||||||
fieldInfo.setColumnName(fieldName.replaceAll("'",""));
|
}
|
||||||
fieldInfo.setFieldClass(fieldType.replaceAll("'",""));
|
}
|
||||||
fieldInfo.setFieldComment(fieldComment.replaceAll("'",""));
|
}
|
||||||
fieldList.add(fieldInfo);
|
codeJavaInfo.setFieldList(fieldList);
|
||||||
}
|
}
|
||||||
}
|
return codeJavaInfo;
|
||||||
}
|
}
|
||||||
codeJavaInfo.setFieldList(fieldList);
|
public static List<FieldInfo> processJsonObjectToFieldList(JSONObject jsonObject){
|
||||||
}
|
// field List
|
||||||
return codeJavaInfo;
|
List<FieldInfo> fieldList = new ArrayList<FieldInfo>();
|
||||||
}
|
jsonObject.keySet().stream().forEach(jsonField->{
|
||||||
public static List<FieldInfo> processJsonObjectToFieldList(JSONObject jsonObject){
|
FieldInfo fieldInfo = new FieldInfo();
|
||||||
// field List
|
fieldInfo.setFieldName(jsonField);
|
||||||
List<FieldInfo> fieldList = new ArrayList<FieldInfo>();
|
fieldInfo.setColumnName(jsonField);
|
||||||
jsonObject.keySet().stream().forEach(jsonField->{
|
fieldInfo.setFieldClass(String.class.getSimpleName());
|
||||||
FieldInfo fieldInfo = new FieldInfo();
|
fieldInfo.setFieldComment("father:"+jsonField);
|
||||||
fieldInfo.setFieldName(jsonField);
|
fieldList.add(fieldInfo);
|
||||||
fieldInfo.setColumnName(jsonField);
|
if(jsonObject.get(jsonField) instanceof JSONArray){
|
||||||
fieldInfo.setFieldClass(String.class.getSimpleName());
|
jsonObject.getJSONArray(jsonField).stream().forEach(arrayObject->{
|
||||||
fieldInfo.setFieldComment("father:"+jsonField);
|
FieldInfo fieldInfo2 = new FieldInfo();
|
||||||
fieldList.add(fieldInfo);
|
fieldInfo2.setFieldName(arrayObject.toString());
|
||||||
if(jsonObject.get(jsonField) instanceof JSONArray){
|
fieldInfo2.setColumnName(arrayObject.toString());
|
||||||
jsonObject.getJSONArray(jsonField).stream().forEach(arrayObject->{
|
fieldInfo2.setFieldClass(String.class.getSimpleName());
|
||||||
FieldInfo fieldInfo2 = new FieldInfo();
|
fieldInfo2.setFieldComment("children:"+arrayObject.toString());
|
||||||
fieldInfo2.setFieldName(arrayObject.toString());
|
fieldList.add(fieldInfo2);
|
||||||
fieldInfo2.setColumnName(arrayObject.toString());
|
});
|
||||||
fieldInfo2.setFieldClass(String.class.getSimpleName());
|
}else if(jsonObject.get(jsonField) instanceof JSONObject){
|
||||||
fieldInfo2.setFieldComment("children:"+arrayObject.toString());
|
jsonObject.getJSONObject(jsonField).keySet().stream().forEach(arrayObject->{
|
||||||
fieldList.add(fieldInfo2);
|
FieldInfo fieldInfo2 = new FieldInfo();
|
||||||
});
|
fieldInfo2.setFieldName(arrayObject.toString());
|
||||||
}else if(jsonObject.get(jsonField) instanceof JSONObject){
|
fieldInfo2.setColumnName(arrayObject.toString());
|
||||||
jsonObject.getJSONObject(jsonField).keySet().stream().forEach(arrayObject->{
|
fieldInfo2.setFieldClass(String.class.getSimpleName());
|
||||||
FieldInfo fieldInfo2 = new FieldInfo();
|
fieldInfo2.setFieldComment("children:"+arrayObject.toString());
|
||||||
fieldInfo2.setFieldName(arrayObject.toString());
|
fieldList.add(fieldInfo2);
|
||||||
fieldInfo2.setColumnName(arrayObject.toString());
|
});
|
||||||
fieldInfo2.setFieldClass(String.class.getSimpleName());
|
}
|
||||||
fieldInfo2.setFieldComment("children:"+arrayObject.toString());
|
});
|
||||||
fieldList.add(fieldInfo2);
|
if(fieldList.size()<1){
|
||||||
});
|
throw new CodeGenerateException("JSON解析失败");
|
||||||
}
|
}
|
||||||
});
|
return fieldList;
|
||||||
if(fieldList.size()<1){
|
}
|
||||||
throw new CodeGenerateException("JSON解析失败");
|
}
|
||||||
}
|
|
||||||
return fieldList;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -2,17 +2,25 @@ server:
|
|||||||
port: 1234
|
port: 1234
|
||||||
servlet:
|
servlet:
|
||||||
context-path: /generator
|
context-path: /generator
|
||||||
tomcat:
|
#tomcat:
|
||||||
remote-ip-header: x-forward-for
|
# remote-ip-header: x-forward-for
|
||||||
uri-encoding: UTF-8
|
# uri-encoding: UTF-8
|
||||||
max-threads: 10
|
# max-threads: 10
|
||||||
background-processor-delay: 30
|
# background-processor-delay: 30
|
||||||
basedir: ${user.home}/tomcat/
|
# basedir: ${user.home}/tomcat/
|
||||||
|
undertow:
|
||||||
|
# 设置IO线程数, 它主要执行非阻塞的任务,它们会负责多个连接, 默认设置每个CPU核心一个线程
|
||||||
|
# 不要设置过大,如果过大,启动项目会报错:打开文件数过多
|
||||||
|
io-threads: 4
|
||||||
|
# 阻塞任务线程池, 当执行类似servlet请求阻塞IO操作, undertow会从这个线程池中取得线程
|
||||||
|
# 它的值设置取决于系统线程执行任务的阻塞系数,默认值是IO线程数*8
|
||||||
|
worker-threads: 64
|
||||||
|
# 以下的配置会影响buffer,这些buffer会用于服务器连接的IO操作,有点类似netty的池化内存管理
|
||||||
|
# 每块buffer的空间大小,越小的空间被利用越充分,不要设置太大,以免影响其他应用,合适即可
|
||||||
|
buffer-size: 1024
|
||||||
|
# 是否分配的直接内存(NIO直接分配的堆外内存)
|
||||||
|
direct-buffers: true
|
||||||
spring:
|
spring:
|
||||||
cloud:
|
|
||||||
nacos:
|
|
||||||
discovery:
|
|
||||||
server-addr: 127.0.0.1:8848
|
|
||||||
banner:
|
banner:
|
||||||
charset: UTF-8
|
charset: UTF-8
|
||||||
http:
|
http:
|
||||||
|
|||||||
1
generator-web/src/main/resources/static/version.json
Normal file
1
generator-web/src/main/resources/static/version.json
Normal file
@@ -0,0 +1 @@
|
|||||||
|
{"version": "20191229"}
|
||||||
@@ -9,6 +9,7 @@ import java.util.List;
|
|||||||
*/
|
*/
|
||||||
@Data
|
@Data
|
||||||
public class ${classInfo.className} implements Serializable {
|
public class ${classInfo.className} implements Serializable {
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
<#if classInfo.fieldList?exists && classInfo.fieldList?size gt 0>
|
<#if classInfo.fieldList?exists && classInfo.fieldList?size gt 0>
|
||||||
@@ -23,4 +24,4 @@ public class ${classInfo.className} implements Serializable {
|
|||||||
}
|
}
|
||||||
</#if>
|
</#if>
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,8 +1,16 @@
|
|||||||
import java.io.Serializable;
|
package ${packageName}.entity;
|
||||||
import javax.persistence.*;
|
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.io.Serializable;
|
||||||
|
import javax.persistence.Column;
|
||||||
|
import javax.persistence.Entity;
|
||||||
|
import javax.persistence.Id;
|
||||||
|
import javax.persistence.Table;
|
||||||
|
import javax.persistence.GeneratedValue;
|
||||||
|
import io.swagger.annotations.ApiModel;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ${classInfo.classComment}
|
* ${classInfo.classComment}
|
||||||
@@ -11,8 +19,11 @@ import java.util.List;
|
|||||||
@Entity
|
@Entity
|
||||||
@Data
|
@Data
|
||||||
@Table(name="${classInfo.tableName}")
|
@Table(name="${classInfo.tableName}")
|
||||||
|
@ApiModel("${classInfo.classComment}")
|
||||||
public class ${classInfo.className} implements Serializable {
|
public class ${classInfo.className} implements Serializable {
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
@Id
|
@Id
|
||||||
@GeneratedValue
|
@GeneratedValue
|
||||||
<#if classInfo.fieldList?exists && classInfo.fieldList?size gt 0>
|
<#if classInfo.fieldList?exists && classInfo.fieldList?size gt 0>
|
||||||
@@ -20,6 +31,8 @@ public class ${classInfo.className} implements Serializable {
|
|||||||
/**
|
/**
|
||||||
* ${fieldItem.fieldComment}
|
* ${fieldItem.fieldComment}
|
||||||
*/
|
*/
|
||||||
|
@ApiModelProperty("${fieldItem.fieldComment}")
|
||||||
|
@Column("${fieldItem.columnName}")
|
||||||
private ${fieldItem.fieldClass} ${fieldItem.fieldName};
|
private ${fieldItem.fieldClass} ${fieldItem.fieldName};
|
||||||
|
|
||||||
</#list>
|
</#list>
|
||||||
@@ -27,4 +40,4 @@ public class ${classInfo.className} implements Serializable {
|
|||||||
}
|
}
|
||||||
</#if>
|
</#if>
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import java.util.List;
|
|||||||
* @author ${authorName} ${.now?string('yyyy-MM-dd')}
|
* @author ${authorName} ${.now?string('yyyy-MM-dd')}
|
||||||
*/
|
*/
|
||||||
public class ${classInfo.className} implements Serializable {
|
public class ${classInfo.className} implements Serializable {
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
<#if classInfo.fieldList?exists && classInfo.fieldList?size gt 0>
|
<#if classInfo.fieldList?exists && classInfo.fieldList?size gt 0>
|
||||||
@@ -34,4 +35,4 @@ public class ${classInfo.className} implements Serializable {
|
|||||||
|
|
||||||
</#list>
|
</#list>
|
||||||
</#if>
|
</#if>
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,331 +1,371 @@
|
|||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
<title>SQL转Java JPA、MYBATIS实现类代码生成平台</title>
|
<title>SQL转Java JPA、MYBATIS实现类代码生成平台</title>
|
||||||
<meta name="keywords" content="sql转实体类,sql转DAO,SQL转service,SQL转JPA实现,SQL转MYBATIS实现">
|
<meta name="keywords" content="sql转实体类,sql转DAO,SQL转service,SQL转JPA实现,SQL转MYBATIS实现">
|
||||||
|
|
||||||
<#import "common/common-import.ftl" as netCommon>
|
<#import "common/common-import.ftl" as netCommon>
|
||||||
<@netCommon.commonStyle />
|
<@netCommon.commonStyle />
|
||||||
<@netCommon.commonScript />
|
<@netCommon.commonScript />
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
|
||||||
<@netCommon.viewerCounter />
|
<@netCommon.viewerCounter />
|
||||||
|
|
||||||
$(function () {
|
$(function () {
|
||||||
/**
|
/**
|
||||||
* 初始化 table sql 3
|
* 初始化 table sql 3
|
||||||
*/
|
*/
|
||||||
var ddlSqlArea = CodeMirror.fromTextArea(document.getElementById("ddlSqlArea"), {
|
var ddlSqlArea = CodeMirror.fromTextArea(document.getElementById("ddlSqlArea"), {
|
||||||
lineNumbers: true,
|
lineNumbers: true,
|
||||||
matchBrackets: true,
|
matchBrackets: true,
|
||||||
mode: "text/x-sql",
|
mode: "text/x-sql",
|
||||||
lineWrapping:false,
|
lineWrapping:false,
|
||||||
readOnly:false,
|
readOnly:false,
|
||||||
foldGutter: true,
|
foldGutter: true,
|
||||||
//keyMap:"sublime",
|
//keyMap:"sublime",
|
||||||
gutters:["CodeMirror-linenumbers", "CodeMirror-foldgutter"]
|
gutters:["CodeMirror-linenumbers", "CodeMirror-foldgutter"]
|
||||||
});
|
});
|
||||||
ddlSqlArea.setSize('auto','auto');
|
ddlSqlArea.setSize('auto','auto');
|
||||||
// controller_ide
|
// controller_ide
|
||||||
var genCodeArea = CodeMirror.fromTextArea(document.getElementById("genCodeArea"), {
|
var genCodeArea = CodeMirror.fromTextArea(document.getElementById("genCodeArea"), {
|
||||||
lineNumbers: true,
|
lineNumbers: true,
|
||||||
matchBrackets: true,
|
matchBrackets: true,
|
||||||
mode: "text/x-java",
|
mode: "text/x-java",
|
||||||
lineWrapping:true,
|
lineWrapping:true,
|
||||||
readOnly:false,
|
readOnly:false,
|
||||||
foldGutter: true,
|
foldGutter: true,
|
||||||
//keyMap:"sublime",
|
//keyMap:"sublime",
|
||||||
gutters:["CodeMirror-linenumbers", "CodeMirror-foldgutter"]
|
gutters:["CodeMirror-linenumbers", "CodeMirror-foldgutter"]
|
||||||
});
|
});
|
||||||
genCodeArea.setSize('auto','auto');
|
genCodeArea.setSize('auto','auto');
|
||||||
|
|
||||||
var codeData;
|
var codeData;
|
||||||
|
// 使用:var jsonObj = $("#formId").serializeObject();
|
||||||
/**
|
$.fn.serializeObject = function()
|
||||||
* 生成代码
|
{
|
||||||
*/
|
var o = {};
|
||||||
$('#btnGenCode').click(function () {
|
var a = this.serializeArray();
|
||||||
var tableSql = ddlSqlArea.getValue();
|
$.each(a, function() {
|
||||||
$.ajax({
|
if (o[this.name]) {
|
||||||
type: 'POST',
|
if (!o[this.name].push) {
|
||||||
url: base_url + "/genCode",
|
o[this.name] = [o[this.name]];
|
||||||
data: {
|
}
|
||||||
"tableSql": tableSql,
|
o[this.name].push(this.value || '');
|
||||||
"packageName":$("#packageName").val(),
|
} else {
|
||||||
"returnUtil":$("#returnUtil").val(),
|
o[this.name] = this.value || '';
|
||||||
"authorName":$("#authorName").val(),
|
}
|
||||||
"dataType":$("#dataType").val(),
|
});
|
||||||
"tinyintTransType":$("#tinyintTransType").val(),
|
return o;
|
||||||
"nameCaseType":$("#nameCaseType").val()
|
};
|
||||||
},
|
/**
|
||||||
dataType: "json",
|
* 生成代码
|
||||||
success: function (data) {
|
*/
|
||||||
if (data.code == 200) {
|
$('#btnGenCode').click(function () {
|
||||||
codeData = data.data;
|
var jsonData = {
|
||||||
genCodeArea.setValue(codeData.beetlentity);
|
"tableSql": ddlSqlArea.getValue(),
|
||||||
genCodeArea.setSize('auto', 'auto');
|
"packageName":$("#packageName").val(),
|
||||||
$.toast("√ 代码生成成功");
|
"returnUtil":$("#returnUtil").val(),
|
||||||
} else {
|
"authorName":$("#authorName").val(),
|
||||||
$.toast("× 代码生成失败 :"+data.msg);
|
"dataType":$("#dataType").val(),
|
||||||
}
|
"tinyintTransType":$("#tinyintTransType").val(),
|
||||||
}
|
"nameCaseType":$("#nameCaseType").val()
|
||||||
});
|
};
|
||||||
});
|
$.ajax({
|
||||||
/**
|
type: 'POST',
|
||||||
* 按钮事件组
|
url: base_url + "/genCode",
|
||||||
*/
|
data:(JSON.stringify(jsonData)),
|
||||||
$('.generator').bind('click', function () {
|
dataType: "json",
|
||||||
if (!$.isEmptyObject(codeData)) {
|
contentType: "application/json",
|
||||||
var id = this.id;
|
success: function (data) {
|
||||||
genCodeArea.setValue(codeData[id]);
|
if (data.code === 200) {
|
||||||
genCodeArea.setSize('auto', 'auto');
|
codeData = data.data;
|
||||||
}
|
genCodeArea.setValue(codeData.beetlentity);
|
||||||
});
|
genCodeArea.setSize('auto', 'auto');
|
||||||
/**
|
$.toast("√ 代码生成成功");
|
||||||
* 捐赠
|
} else {
|
||||||
*/
|
$.toast("× 代码生成失败 :"+data.msg);
|
||||||
function donate(){
|
}
|
||||||
if($("#donate").attr("show")=="no"){
|
}
|
||||||
$("#donate").html('<img src="http://upyun.bejson.com/img/zhengkai.png"></img>');
|
});
|
||||||
$("#donate").attr("show","yes");
|
return false;
|
||||||
}else{
|
});
|
||||||
$("#donate").html('<p>谢谢赞赏!</p>');
|
/**
|
||||||
$("#donate").attr("show","no");
|
* 按钮事件组
|
||||||
}
|
*/
|
||||||
}
|
$('.generator').bind('click', function () {
|
||||||
$('#donate1').on('click', function(){
|
if (!$.isEmptyObject(codeData)) {
|
||||||
donate();
|
var id = this.id;
|
||||||
});
|
genCodeArea.setValue(codeData[id]);
|
||||||
$('#donate2').on('click', function(){
|
genCodeArea.setSize('auto', 'auto');
|
||||||
donate();
|
}
|
||||||
});
|
});
|
||||||
$('#btnCopy').on('click', function(){
|
/**
|
||||||
if(!$.isEmptyObject(genCodeArea.getValue())&&!$.isEmptyObject(navigator)&&!$.isEmptyObject(navigator.clipboard)){
|
* 捐赠
|
||||||
navigator.clipboard.writeText(genCodeArea.getValue());
|
*/
|
||||||
$.toast("√ 复制成功");
|
function donate(){
|
||||||
}
|
if($("#donate").attr("show")=="no"){
|
||||||
});
|
$("#donate").html('<img src="http://upyun.bejson.com/img/zhengkai.png"></img>');
|
||||||
|
$("#donate").attr("show","yes");
|
||||||
});
|
}else{
|
||||||
</script>
|
$("#donate").html('<p>谢谢赞赏!</p>');
|
||||||
</head>
|
$("#donate").attr("show","no");
|
||||||
<body style="background-color: #e9ecef">
|
}
|
||||||
|
}
|
||||||
<div class="container">
|
$('#donate1').on('click', function(){
|
||||||
<nav class="navbar navbar-dark bg-primary btn-lg">
|
donate();
|
||||||
<a class="navbar-brand" href="http://www.bejson.com">BeJSON在线工具站</a>
|
});
|
||||||
<ul class="nav navbar-nav">
|
$('#donate2').on('click', function(){
|
||||||
<li class="nav-item active">
|
donate();
|
||||||
<a class="nav-link" href="http://zhengkai.blog.csdn.net">大狼狗CSDN</a>
|
});
|
||||||
</li>
|
$('#btnCopy').on('click', function(){
|
||||||
</ul>
|
if(!$.isEmptyObject(genCodeArea.getValue())&&!$.isEmptyObject(navigator)&&!$.isEmptyObject(navigator.clipboard)){
|
||||||
</nav>
|
navigator.clipboard.writeText(genCodeArea.getValue());
|
||||||
</div>
|
$.toast("√ 复制成功");
|
||||||
|
}
|
||||||
<!-- Main jumbotron for a primary marketing message or call to action -->
|
});
|
||||||
<div class="jumbotron">
|
|
||||||
<div class="container">
|
function getVersion(){
|
||||||
<h2>Spring Boot Code Generator!</h2>
|
var gitVersion ;
|
||||||
<p class="lead">
|
$.ajax({
|
||||||
√基于SpringBoot2+Freemarker的代码生成器,√以释放双手为目的,√支持mysql/oracle/pgsql三大数据库,<br>
|
type: 'GET',
|
||||||
√用DDL-SQL语句生成JPA/JdbcTemplate/Mybatis/MybatisPlus/BeetlSQL相关代码。<br>
|
url: "https://raw.githubusercontent.com/moshowgame/SpringBootCodeGenerator/master/generator-web/src/main/resources/static/version.json",
|
||||||
欢迎大家多多提交模板和交流想法,如果发现有SQL语句不能识别,请<a href="https://github.com/moshowgame/SpringBootCodeGenerator/issues">留言</a>,同时欢迎大家提<a href="https://github.com/moshowgame/SpringBootCodeGenerator/pulls">PR</a>和<a href="#" id="donate1">点击赞赏</a>,谢谢!
|
dataType: "json",
|
||||||
</p>
|
success: function (data) {
|
||||||
<div id="donate" class="container" show="no"></div>
|
gitVersion = data.version;
|
||||||
<hr>
|
$.ajax({
|
||||||
<div class="input-group mb-3">
|
type: 'GET',
|
||||||
<div class="input-group-prepend">
|
url: base_url + "/static/version.json",
|
||||||
<span class="input-group-text">作者名称</span>
|
dataType: "json",
|
||||||
</div>
|
success: function (data) {
|
||||||
<input type="text" class="form-control" id="authorName" name="authorName" placeholder="大狼狗">
|
$.toast("#当前版本:"+data.version+" | github:"+gitVersion);
|
||||||
<div class="input-group-prepend">
|
}
|
||||||
<span class="input-group-text">返回封装</span>
|
});
|
||||||
</div>
|
}
|
||||||
<input type="text" class="form-control" id="returnUtil" name="returnUtil" placeholder="ApiReturnObject">
|
});
|
||||||
<div class="input-group-prepend">
|
}
|
||||||
<span class="input-group-text">包名路径</span>
|
$('#version').on('click', function(){
|
||||||
</div>
|
getVersion();
|
||||||
<input type="text" class="form-control" id="packageName" name="packageName" placeholder="com.softdev.system">
|
});
|
||||||
</div>
|
});
|
||||||
<div class="input-group mb-3">
|
</script>
|
||||||
<div class="input-group-prepend">
|
</head>
|
||||||
<span class="input-group-text">数据类型</span>
|
<body style="background-color: #e9ecef">
|
||||||
</div>
|
|
||||||
<select type="text" class="form-control" id="dataType"
|
<div class="container">
|
||||||
name="dataType">
|
<nav class="navbar navbar-dark bg-primary btn-lg">
|
||||||
<option value="sql">sql</option>
|
<a class="navbar-brand" href="http://www.bejson.com">BeJSON在线工具站</a>
|
||||||
<option value="json">json</option>
|
<ul class="nav navbar-nav">
|
||||||
<option value="sql-regex">sql-regex</option>
|
<li class="nav-item active">
|
||||||
</select>
|
<a class="nav-link" href="http://zhengkai.blog.csdn.net">大狼狗CSDN</a>
|
||||||
<div class="input-group-prepend">
|
</li>
|
||||||
<span class="input-group-text">tinyint转换类型</span>
|
</ul>
|
||||||
</div>
|
</nav>
|
||||||
<select type="text" class="form-control" id="tinyintTransType"
|
</div>
|
||||||
name="tinyintTransType">
|
|
||||||
<option value="boolean">boolean</option>
|
<!-- Main jumbotron for a primary marketing message or call to action -->
|
||||||
<option value="Boolean">Boolean</option>
|
<div class="jumbotron">
|
||||||
<option value="Integer">Integer</option>
|
<div class="container">
|
||||||
<option value="int">int</option>
|
<h2>Spring Boot Code Generator!</h2>
|
||||||
<option value="String">String</option>
|
<p class="lead">
|
||||||
</select>
|
√基于SpringBoot2+Freemarker的代码生成器,√以释放双手为目的,√支持mysql/oracle/pgsql三大数据库,<br>
|
||||||
<div class="input-group-prepend">
|
√用DDL-SQL语句生成JPA/JdbcTemplate/Mybatis/MybatisPlus/BeetlSQL相关代码。<br>
|
||||||
<span class="input-group-text">命名转换规则</span>
|
如果发现有SQL语句不能识别,请<a href="https://github.com/moshowgame/SpringBootCodeGenerator/issues">留言</a>,同时欢迎大家提<a href="https://github.com/moshowgame/SpringBootCodeGenerator/pulls">PR</a>和<a href="#" id="donate1">赞赏</a>,谢谢!<a id="version" href="#">查看版本</a>
|
||||||
</div>
|
</p>
|
||||||
<select type="text" class="form-control" id="nameCaseType"
|
<div id="donate" class="container" show="no"></div>
|
||||||
name="nameCaseType">
|
<hr>
|
||||||
<option value="CamelCase">驼峰</option>
|
<div class="input-group mb-3">
|
||||||
<option value="UnderScoreCase">下划线</option>
|
<div class="input-group-prepend">
|
||||||
<#--<option value="UpperUnderScoreCase">大写下划线</option>-->
|
<span class="input-group-text">作者名称</span>
|
||||||
</select>
|
</div>
|
||||||
</div>
|
<input type="text" class="form-control" id="authorName" name="authorName" value="大狼狗">
|
||||||
<textarea id="ddlSqlArea" placeholder="请输入表结构信息..." class="form-control btn-lg" style="height: 250px;">
|
<div class="input-group-prepend">
|
||||||
CREATE TABLE 'userinfo' (
|
<span class="input-group-text">返回封装</span>
|
||||||
'user_id' int(11) NOT NULL AUTO_INCREMENT COMMENT '用户ID',
|
</div>
|
||||||
'username' varchar(255) NOT NULL COMMENT '用户名',
|
<input type="text" class="form-control" id="returnUtil" name="returnUtil" value="ApiReturnObject">
|
||||||
'addtime' datetime NOT NULL COMMENT '创建时间',
|
<div class="input-group-prepend">
|
||||||
PRIMARY KEY ('user_id')
|
<span class="input-group-text">包名路径</span>
|
||||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='用户信息'
|
</div>
|
||||||
</textarea><br>
|
<input type="text" class="form-control" id="packageName" name="packageName" value="com.softdev.system">
|
||||||
<p><button class="btn btn-primary btn-lg disabled" id="btnGenCode" role="button" data-toggle="popover" data-content="">开始生成 »</button> <button class="btn alert-secondary" id="btnCopy">一键复制</button></p>
|
</div>
|
||||||
<hr>
|
<div class="input-group mb-3">
|
||||||
<!-- Example row of columns -->
|
<div class="input-group-prepend">
|
||||||
<div class="row" style="margin-top: 10px;">
|
<span class="input-group-text">数据类型</span>
|
||||||
<div class="btn-toolbar col-md-5" role="toolbar" aria-label="Toolbar with button groups">
|
</div>
|
||||||
<div class="input-group">
|
<select type="text" class="form-control" id="dataType"
|
||||||
<div class="input-group-prepend">
|
name="dataType">
|
||||||
<div class="btn btn-secondary disabled setWidth" id="btnGroupAddon">通用实体</div>
|
<option value="sql">sql</option>
|
||||||
</div>
|
<option value="json">json</option>
|
||||||
</div>
|
<option value="sql-regex">sql-regex</option>
|
||||||
<div class="btn-group" role="group" aria-label="First group">
|
</select>
|
||||||
<button type="button" class="btn btn-default generator" id="model">entity(set/get)</button>
|
<div class="input-group-prepend">
|
||||||
<button type="button" class="btn btn-default generator" id="beetlentity">entity(lombok)</button>
|
<span class="input-group-text">tinyint转换类型</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
<select type="text" class="form-control" id="tinyintTransType"
|
||||||
<div class="btn-toolbar col-md-7" role="toolbar" aria-label="Toolbar with button groups">
|
name="tinyintTransType">
|
||||||
<div class="input-group">
|
<option value="boolean">boolean</option>
|
||||||
<div class="input-group-prepend">
|
<option value="Boolean">Boolean</option>
|
||||||
<div class="btn btn-secondary disabled setWidth" id="btnGroupAddon">Mybatis</div>
|
<option value="Integer">Integer</option>
|
||||||
</div>
|
<option value="int">int</option>
|
||||||
</div>
|
<option value="String">String</option>
|
||||||
<div class="btn-group" role="group" aria-label="First group">
|
</select>
|
||||||
<button type="button" class="btn btn-default generator" id="mybatis">mybatis</button>
|
<div class="input-group-prepend">
|
||||||
<button type="button" class="btn btn-default generator" id="mapper">mapper</button>
|
<span class="input-group-text">命名转换规则</span>
|
||||||
<button type="button" class="btn btn-default generator" id="service">service</button>
|
</div>
|
||||||
<button type="button" class="btn btn-default generator" id="service_impl">service_impl</button>
|
<select type="text" class="form-control" id="nameCaseType"
|
||||||
<button type="button" class="btn btn-default generator" id="controller">controller</button>
|
name="nameCaseType">
|
||||||
</div>
|
<option value="CamelCase">驼峰</option>
|
||||||
</div>
|
<option value="UnderScoreCase">下划线</option>
|
||||||
</div>
|
<#--<option value="UpperUnderScoreCase">大写下划线</option>-->
|
||||||
<!-- Example row of columns -->
|
</select>
|
||||||
<div class="row" style="margin-top: 10px;">
|
</div>
|
||||||
<div class="btn-toolbar col-md-5" role="toolbar" aria-label="Toolbar with button groups">
|
<textarea id="ddlSqlArea" placeholder="请输入表结构信息..." class="form-control btn-lg" style="height: 250px;">
|
||||||
<div class="input-group">
|
CREATE TABLE 'userinfo' (
|
||||||
<div class="input-group-prepend">
|
'user_id' int(11) NOT NULL AUTO_INCREMENT COMMENT '用户ID',
|
||||||
<div class="btn btn-secondary disabled setWidth" id="btnGroupAddon">MybatisPlus</div>
|
'username' varchar(255) NOT NULL COMMENT '用户名',
|
||||||
</div>
|
'addtime' datetime NOT NULL COMMENT '创建时间',
|
||||||
</div>
|
PRIMARY KEY ('user_id')
|
||||||
<div class="btn-group" role="group" aria-label="First group">
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='用户信息'
|
||||||
<button type="button" class="btn btn-default generator" id="plusmapper">mapper</button>
|
</textarea><br>
|
||||||
<button type="button" class="btn btn-default generator" id="pluscontroller">controller</button>
|
<p><button class="btn btn-primary btn-lg disabled" id="btnGenCode" role="button" data-toggle="popover" data-content="">开始生成 »</button> <button class="btn alert-secondary" id="btnCopy">一键复制</button></p>
|
||||||
</div>
|
<hr>
|
||||||
</div>
|
<!-- Example row of columns -->
|
||||||
|
<div class="row" style="margin-top: 10px;">
|
||||||
<div class="btn-toolbar col-md-5" role="toolbar" aria-label="Toolbar with button groups">
|
<div class="btn-toolbar col-md-5" role="toolbar" aria-label="Toolbar with button groups">
|
||||||
<div class="input-group">
|
<div class="input-group">
|
||||||
<div class="input-group-prepend">
|
<div class="input-group-prepend">
|
||||||
<div class="btn btn-secondary disabled setWidth" id="btnGroupAddon">UI</div>
|
<div class="btn btn-secondary disabled setWidth" id="btnGroupAddon">通用实体</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="btn-group" role="group" aria-label="First group">
|
<div class="btn-group" role="group" aria-label="First group">
|
||||||
<button type="button" class="btn btn-default generator" id="swagger-ui">swagger-ui</button>
|
<button type="button" class="btn btn-default generator" id="model">entity(set/get)</button>
|
||||||
<button type="button" class="btn btn-default generator" id="element-ui">element-ui</button>
|
<button type="button" class="btn btn-default generator" id="beetlentity">entity(lombok)</button>
|
||||||
<button type="button" class="btn btn-default generator" id="bootstrap-ui">bootstrap-ui</button>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
<div class="btn-toolbar col-md-7" role="toolbar" aria-label="Toolbar with button groups">
|
||||||
</div>
|
<div class="input-group">
|
||||||
|
<div class="input-group-prepend">
|
||||||
<div class="row" style="margin-top: 10px;">
|
<div class="btn btn-secondary disabled setWidth" id="btnGroupAddon">Mybatis</div>
|
||||||
<div class="btn-toolbar col-md-5" role="toolbar" aria-label="Toolbar with button groups">
|
</div>
|
||||||
<div class="input-group">
|
</div>
|
||||||
<div class="input-group-prepend">
|
<div class="btn-group" role="group" aria-label="First group">
|
||||||
<div class="btn btn-secondary disabled setWidth" id="btnGroupAddon">BeetlSQL</div>
|
<button type="button" class="btn btn-default generator" id="mybatis">mybatis</button>
|
||||||
</div>
|
<button type="button" class="btn btn-default generator" id="mapper">mapper</button>
|
||||||
</div>
|
<button type="button" class="btn btn-default generator" id="service">service</button>
|
||||||
<div class="btn-group" role="group" aria-label="First group">
|
<button type="button" class="btn btn-default generator" id="service_impl">service_impl</button>
|
||||||
<button type="button" class="btn btn-default generator" id="beetlmd">beetlmd</button>
|
<button type="button" class="btn btn-default generator" id="controller">controller</button>
|
||||||
<button type="button" class="btn btn-default generator" id="beetlcontroller">beetlcontroller</button>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="btn-toolbar col-md-5" role="toolbar" aria-label="Toolbar with button groups">
|
<!-- Example row of columns -->
|
||||||
<div class="input-group">
|
<div class="row" style="margin-top: 10px;">
|
||||||
<div class="input-group-prepend">
|
<div class="btn-toolbar col-md-5" role="toolbar" aria-label="Toolbar with button groups">
|
||||||
<div class="btn btn-secondary disabled setWidth" id="btnGroupAddon">JPA</div>
|
<div class="input-group">
|
||||||
</div>
|
<div class="input-group-prepend">
|
||||||
</div>
|
<div class="btn btn-secondary disabled setWidth" id="btnGroupAddon">MybatisPlus</div>
|
||||||
<div class="btn-group" role="group" aria-label="First group">
|
</div>
|
||||||
<button type="button" class="btn btn-default generator" id="entity">jpa-entity</button>
|
</div>
|
||||||
<button type="button" class="btn btn-default generator" id="repository">repository</button>
|
<div class="btn-group" role="group" aria-label="First group">
|
||||||
<button type="button" class="btn btn-default generator" id="jpacontroller">controller</button>
|
<button type="button" class="btn btn-default generator" id="plusmapper">mapper</button>
|
||||||
</div>
|
<button type="button" class="btn btn-default generator" id="pluscontroller">controller</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="row" style="margin-top: 10px;">
|
|
||||||
<div class="btn-toolbar col-md-5" role="toolbar" aria-label="Toolbar with button groups">
|
<div class="btn-toolbar col-md-5" role="toolbar" aria-label="Toolbar with button groups">
|
||||||
<div class="input-group">
|
<div class="input-group">
|
||||||
<div class="input-group-prepend">
|
<div class="input-group-prepend">
|
||||||
<div class="btn btn-secondary disabled setWidth" id="btnGroupAddon">JdbcTemplate</div>
|
<div class="btn btn-secondary disabled setWidth" id="btnGroupAddon">UI</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="btn-group" role="group" aria-label="First group">
|
<div class="btn-group" role="group" aria-label="First group">
|
||||||
<button type="button" class="btn btn-default generator" id="jtdaoimpl">daoimpl</button>
|
<button type="button" class="btn btn-default generator" id="swagger-ui">swagger-ui</button>
|
||||||
<button type="button" class="btn btn-default generator" id="jtdao">dao</button>
|
<button type="button" class="btn btn-default generator" id="element-ui">element-ui</button>
|
||||||
</div>
|
<button type="button" class="btn btn-default generator" id="bootstrap-ui">bootstrap-ui</button>
|
||||||
</div>
|
</div>
|
||||||
<div class="btn-toolbar col-md-7" role="toolbar" aria-label="Toolbar with button groups">
|
</div>
|
||||||
<div class="input-group">
|
</div>
|
||||||
<div class="input-group-prepend">
|
|
||||||
<div class="btn btn-secondary disabled setWidth" id="btnGroupAddon">SQL</div>
|
<div class="row" style="margin-top: 10px;">
|
||||||
</div>
|
<div class="btn-toolbar col-md-5" role="toolbar" aria-label="Toolbar with button groups">
|
||||||
</div>
|
<div class="input-group">
|
||||||
<div class="btn-group" role="group" aria-label="First group">
|
<div class="input-group-prepend">
|
||||||
<button type="button" class="btn btn-default generator" id="select">select</button>
|
<div class="btn btn-secondary disabled setWidth" id="btnGroupAddon">BeetlSQL</div>
|
||||||
<button type="button" class="btn btn-default generator" id="insert">insert</button>
|
</div>
|
||||||
<button type="button" class="btn btn-default generator" id="update">update</button>
|
</div>
|
||||||
<button type="button" class="btn btn-default generator" id="delete">delete</button>
|
<div class="btn-group" role="group" aria-label="First group">
|
||||||
</div>
|
<button type="button" class="btn btn-default generator" id="beetlmd">beetlmd</button>
|
||||||
</div>
|
<button type="button" class="btn btn-default generator" id="beetlcontroller">beetlcontroller</button>
|
||||||
</div>
|
</div>
|
||||||
<div class="row" style="margin-top: 10px;">
|
</div>
|
||||||
<div class="btn-toolbar col-md-5" role="toolbar" aria-label="Toolbar with button groups">
|
<div class="btn-toolbar col-md-5" role="toolbar" aria-label="Toolbar with button groups">
|
||||||
<div class="input-group">
|
<div class="input-group">
|
||||||
<div class="input-group-prepend">
|
<div class="input-group-prepend">
|
||||||
<div class="btn btn-secondary disabled setWidth" id="btnGroupAddon">DTO</div>
|
<div class="btn btn-secondary disabled setWidth" id="btnGroupAddon">JPA</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="btn-group" role="group" aria-label="First group">
|
<div class="btn-group" role="group" aria-label="First group">
|
||||||
<button type="button" class="btn btn-default generator" id="beetlentitydto">entitydto(lombok+swagger)</button>
|
<button type="button" class="btn btn-default generator" id="entity">jpa-entity</button>
|
||||||
</div>
|
<button type="button" class="btn btn-default generator" id="repository">repository</button>
|
||||||
</div>
|
<button type="button" class="btn btn-default generator" id="jpacontroller">controller</button>
|
||||||
<div class="btn-toolbar col-md-5" role="toolbar" aria-label="Toolbar with button groups">
|
</div>
|
||||||
<div class="input-group">
|
</div>
|
||||||
<div class="input-group-prepend">
|
</div>
|
||||||
<div class="btn btn-secondary disabled setWidth" id="btnGroupAddon">Util</div>
|
<div class="row" style="margin-top: 10px;">
|
||||||
</div>
|
<div class="btn-toolbar col-md-5" role="toolbar" aria-label="Toolbar with button groups">
|
||||||
</div>
|
<div class="input-group">
|
||||||
<div class="btn-group" role="group" aria-label="First group">
|
<div class="input-group-prepend">
|
||||||
<button type="button" class="btn btn-default generator" id="util">bean get set</button>
|
<div class="btn btn-secondary disabled setWidth" id="btnGroupAddon">JdbcTemplate</div>
|
||||||
<button type="button" class="btn btn-default generator" id="json">json</button>
|
</div>
|
||||||
<button type="button" class="btn btn-default generator" id="xml">xml</button>
|
</div>
|
||||||
</div>
|
<div class="btn-group" role="group" aria-label="First group">
|
||||||
</div>
|
<button type="button" class="btn btn-default generator" id="jtdaoimpl">daoimpl</button>
|
||||||
</div>
|
<button type="button" class="btn btn-default generator" id="jtdao">dao</button>
|
||||||
<hr>
|
</div>
|
||||||
<textarea id="genCodeArea" class="form-control btn-lg" ></textarea>
|
</div>
|
||||||
</div>
|
<div class="btn-toolbar col-md-7" role="toolbar" aria-label="Toolbar with button groups">
|
||||||
</div>
|
<div class="input-group">
|
||||||
|
<div class="input-group-prepend">
|
||||||
<@netCommon.commonFooter />
|
<div class="btn btn-secondary disabled setWidth" id="btnGroupAddon">SQL</div>
|
||||||
</body>
|
</div>
|
||||||
</html>
|
</div>
|
||||||
|
<div class="btn-group" role="group" aria-label="First group">
|
||||||
|
<button type="button" class="btn btn-default generator" id="select">select</button>
|
||||||
|
<button type="button" class="btn btn-default generator" id="insert">insert</button>
|
||||||
|
<button type="button" class="btn btn-default generator" id="update">update</button>
|
||||||
|
<button type="button" class="btn btn-default generator" id="delete">delete</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row" style="margin-top: 10px;">
|
||||||
|
<div class="btn-toolbar col-md-5" role="toolbar" aria-label="Toolbar with button groups">
|
||||||
|
<div class="input-group">
|
||||||
|
<div class="input-group-prepend">
|
||||||
|
<div class="btn btn-secondary disabled setWidth" id="btnGroupAddon">DTO</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="btn-group" role="group" aria-label="First group">
|
||||||
|
<button type="button" class="btn btn-default generator" id="beetlentitydto">entitydto(lombok+swagger)</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="btn-toolbar col-md-5" role="toolbar" aria-label="Toolbar with button groups">
|
||||||
|
<div class="input-group">
|
||||||
|
<div class="input-group-prepend">
|
||||||
|
<div class="btn btn-secondary disabled setWidth" id="btnGroupAddon">Util</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="btn-group" role="group" aria-label="First group">
|
||||||
|
<button type="button" class="btn btn-default generator" id="util">bean get set</button>
|
||||||
|
<button type="button" class="btn btn-default generator" id="json">json</button>
|
||||||
|
<button type="button" class="btn btn-default generator" id="xml">xml</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<hr>
|
||||||
|
<textarea id="genCodeArea" class="form-control btn-lg" ></textarea>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<@netCommon.commonFooter />
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
|||||||
24
pom.xml
24
pom.xml
@@ -5,7 +5,7 @@
|
|||||||
|
|
||||||
<groupId>com.softdev.system</groupId>
|
<groupId>com.softdev.system</groupId>
|
||||||
<artifactId>SpringBootCodeGenerator</artifactId>
|
<artifactId>SpringBootCodeGenerator</artifactId>
|
||||||
<version>0.0.1-SNAPSHOT</version>
|
<version>2.0</version>
|
||||||
<packaging>pom</packaging>
|
<packaging>pom</packaging>
|
||||||
|
|
||||||
<parent>
|
<parent>
|
||||||
@@ -31,6 +31,18 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>spring-boot-starter-web</artifactId>
|
<artifactId>spring-boot-starter-web</artifactId>
|
||||||
|
<!-- 排除Tomcat依赖 -->
|
||||||
|
<exclusions>
|
||||||
|
<exclusion>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-tomcat</artifactId>
|
||||||
|
</exclusion>
|
||||||
|
</exclusions>
|
||||||
|
</dependency>
|
||||||
|
<!-- 添加 Undertow依赖 -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-undertow</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- https://mvnrepository.com/artifact/com.alibaba/fastjson -->
|
<!-- https://mvnrepository.com/artifact/com.alibaba/fastjson -->
|
||||||
@@ -67,7 +79,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>cn.hutool</groupId>
|
<groupId>cn.hutool</groupId>
|
||||||
<artifactId>hutool-all</artifactId>
|
<artifactId>hutool-all</artifactId>
|
||||||
<version>4.6.1</version>
|
<version>5.0.6</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- lombok -->
|
<!-- lombok -->
|
||||||
@@ -134,7 +146,7 @@
|
|||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-compiler-plugin</artifactId>
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
<version>3.1</version>
|
<version>3.8.1</version>
|
||||||
<configuration>
|
<configuration>
|
||||||
<skip>true</skip>
|
<skip>true</skip>
|
||||||
<compilerId>javac</compilerId>
|
<compilerId>javac</compilerId>
|
||||||
@@ -156,13 +168,13 @@
|
|||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-resources-plugin</artifactId>
|
<artifactId>maven-resources-plugin</artifactId>
|
||||||
<version>3.0.1</version>
|
<version>3.1.0</version>
|
||||||
<configuration>
|
<configuration>
|
||||||
<!--<failOnMissingWebXml>false</failOnMissingWebXml>-->
|
<!--<failOnMissingWebXml>false</failOnMissingWebXml>-->
|
||||||
<includeEmptyDirs>true</includeEmptyDirs>
|
<includeEmptyDirs>true</includeEmptyDirs>
|
||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
<plugin>
|
<!--<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-war-plugin</artifactId>
|
<artifactId>maven-war-plugin</artifactId>
|
||||||
<version>2.1.1</version>
|
<version>2.1.1</version>
|
||||||
@@ -170,7 +182,7 @@
|
|||||||
<failOnMissingWebXml>false</failOnMissingWebXml>
|
<failOnMissingWebXml>false</failOnMissingWebXml>
|
||||||
<warSourceExcludes>upload/**</warSourceExcludes>
|
<warSourceExcludes>upload/**</warSourceExcludes>
|
||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</plugin>-->
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||||
|
|||||||
Reference in New Issue
Block a user