Merge pull request #5 from moshowgame/master

merge
This commit is contained in:
gaohang
2019-11-29 20:19:56 +08:00
committed by GitHub
10 changed files with 998 additions and 940 deletions

View File

@@ -18,6 +18,7 @@
|-|-|
|在线地址|http://java.bejson.com/generator|
|CSDN博客|http://zhengkai.blog.csdn.net|
|最新Jar包|https://github.com/moshowgame/SpringBootCodeGenerator/releases|
感谢bejson三叔将他部署在[BEJSON](www.bejson.com)上目前是besjon专供工具(线上版本不一定是最新的,会有延迟,请谅解,谢谢).
@@ -26,6 +27,8 @@
|更新日期|更新内容|
|-|-|
|20191128|1.修复支持string-copy导致的以n结尾的字母不显示问题 2.jpa-entity新增swagger@ApiModel@ApiModelProperty注解和SQL字段@Column注解(感谢@yjq907的建议) |
|20191126|1.springboot2内置tomcat更换为性能更强大的undertow 2.修复tinyintTransType参数丢失问题 |
|20191124|1.java代码结构优化. 2.新增简单的json生成模式 3.新增简单的正则表达式匹配模式(感谢@ydq的贡献) 4.新增对复制String代码中的乱SQL代码的支持 5.优化对JSON的父子节点/处理JSONObject和JSONArray节点处理子节点缺失'{'头处理|
|20191123|1.移除频繁出错和被过滤的layer,改为jquery-toast. 2.Util功能优化,新增json和xml.|
|20191116|优化对primary关键字的处理(感谢@liujiansgit的反馈). |
@@ -74,5 +77,6 @@
<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

Binary file not shown.

After

Width:  |  Height:  |  Size: 147 KiB

View File

@@ -7,12 +7,12 @@
<parent>
<groupId>com.softdev.system</groupId>
<artifactId>SpringBootCodeGenerator</artifactId>
<version>0.0.1-SNAPSHOT</version>
<version>2.0</version>
</parent>
<groupId>com.softdev.system</groupId>
<artifactId>generator-web</artifactId>
<version>0.0.1-SNAPSHOT</version>
<version>2.0</version>
<packaging>jar</packaging>
<properties>
@@ -38,10 +38,10 @@
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>-->
<dependency>
<!--<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
</dependency>
</dependency>-->
</dependencies>
@@ -65,7 +65,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<version>3.8.1</version>
<configuration>
<skip>true</skip>
<compilerId>javac</compilerId>
@@ -87,25 +87,24 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>3.0.1</version>
<version>3.1.0</version>
<configuration>
<!--<failOnMissingWebXml>false</failOnMissingWebXml>-->
<includeEmptyDirs>true</includeEmptyDirs>
</configuration>
</plugin>
<plugin>
<!--<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.1.1</version>
<version>3.2.3</version>
<configuration>
<failOnMissingWebXml>false</failOnMissingWebXml>
<warSourceExcludes>upload/**</warSourceExcludes>
</configuration>
</plugin>
</plugin>-->
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>2.0.4.RELEASE</version>
<executions>
<execution>
<goals>

View File

@@ -5,14 +5,15 @@ import com.softdev.system.generator.entity.ParamInfo;
import com.softdev.system.generator.entity.ReturnT;
import com.softdev.system.generator.service.GeneratorService;
import com.softdev.system.generator.util.CodeGenerateException;
import com.softdev.system.generator.util.FreemarkerTool;
import com.softdev.system.generator.util.TableParseUtil;
import freemarker.template.TemplateException;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import java.io.IOException;
import java.util.HashMap;
@@ -62,6 +63,9 @@ public class IndexController {
params.put("packageName", paramInfo.getPackageName());
params.put("returnUtil", paramInfo.getReturnUtil());
log.info("generator table:"+(classInfo==null?"":classInfo.getTableName())
+",field size:"+((classInfo==null||classInfo.getFieldList()==null)?"":classInfo.getFieldList().size()));
// generate the code 需要加新的模板请在里面改
Map<String, String> result = generatorService.getResultByParams(params);

View File

@@ -1,14 +1,12 @@
package com.softdev.system.generator.util;
import cn.hutool.core.util.XmlUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.softdev.system.generator.entity.ClassInfo;
import com.softdev.system.generator.entity.FieldInfo;
import com.softdev.system.generator.entity.ParamInfo;
import org.w3c.dom.Document;
import java.io.IOException;
import java.math.BigDecimal;
@@ -42,9 +40,7 @@ public class TableParseUtil {
//deal with special character
tableSql = tableSql.trim().replaceAll("'","`").replaceAll("\"","`").replaceAll("",",").toLowerCase();
//deal with java string copy \n"
System.out.println(tableSql);
tableSql = tableSql.trim().replaceAll("n`","").replaceAll("\\+","").replaceAll("``","`").replaceAll("\\\\","");
System.out.println(tableSql);
tableSql = tableSql.trim().replaceAll("\\\\n`","").replaceAll("\\+","").replaceAll("``","`").replaceAll("\\\\","");
// table Name
String tableName = null;
if (tableSql.contains("TABLE") && tableSql.contains("(")) {

View File

@@ -2,17 +2,25 @@ server:
port: 1234
servlet:
context-path: /generator
tomcat:
remote-ip-header: x-forward-for
uri-encoding: UTF-8
max-threads: 10
background-processor-delay: 30
basedir: ${user.home}/tomcat/
#tomcat:
# remote-ip-header: x-forward-for
# uri-encoding: UTF-8
# max-threads: 10
# background-processor-delay: 30
# 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:
cloud:
nacos:
discovery:
server-addr: 127.0.0.1:8848
banner:
charset: UTF-8
http:

View File

@@ -0,0 +1 @@
{"version": "20191128"}

View File

@@ -1,8 +1,16 @@
import java.io.Serializable;
import javax.persistence.*;
package ${packageName}.entity;
import lombok.Data;
import java.util.Date;
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}
@@ -11,6 +19,7 @@ import java.util.List;
@Entity
@Data
@Table(name="${classInfo.tableName}")
@ApiModel("${classInfo.classComment}")
public class ${classInfo.className} implements Serializable {
private static final long serialVersionUID = 1L;
@@ -22,6 +31,8 @@ public class ${classInfo.className} implements Serializable {
/**
* ${fieldItem.fieldComment}
*/
@ApiModelProperty("${fieldItem.fieldComment}")
@Column("${fieldItem.columnName}")
private ${fieldItem.fieldClass} ${fieldItem.fieldName};
</#list>

View File

@@ -57,6 +57,7 @@
"returnUtil":$("#returnUtil").val(),
"authorName":$("#authorName").val(),
"dataType":$("#dataType").val(),
"tinyintTransType":$("#tinyintTransType").val(),
"nameCaseType":$("#nameCaseType").val()
},
dataType: "json",
@@ -107,6 +108,28 @@
}
});
function getVersion(){
var gitVersion ;
$.ajax({
type: 'GET',
url: "https://raw.githubusercontent.com/moshowgame/SpringBootCodeGenerator/master/generator-web/src/main/resources/static/version.json",
dataType: "json",
success: function (data) {
gitVersion = data.version;
$.ajax({
type: 'GET',
url: base_url + "/static/version.json",
dataType: "json",
success: function (data) {
$.toast("#当前版本:"+data.version+" | github:"+gitVersion);
}
});
}
});
}
$('#version').on('click', function(){
getVersion();
});
});
</script>
</head>
@@ -130,7 +153,7 @@
<p class="lead">
√基于SpringBoot2+Freemarker的代码生成器√以释放双手为目的√支持mysql/oracle/pgsql三大数据库<br>
√用DDL-SQL语句生成JPA/JdbcTemplate/Mybatis/MybatisPlus/BeetlSQL相关代码。<br>
欢迎大家多多提交模板和交流想法,如果发现有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>,谢谢!
如果发现有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>
</p>
<div id="donate" class="container" show="no"></div>
<hr>
@@ -138,15 +161,15 @@
<div class="input-group-prepend">
<span class="input-group-text">作者名称</span>
</div>
<input type="text" class="form-control" id="authorName" name="authorName" placeholder="大狼狗">
<input type="text" class="form-control" id="authorName" name="authorName" value="大狼狗">
<div class="input-group-prepend">
<span class="input-group-text">返回封装</span>
</div>
<input type="text" class="form-control" id="returnUtil" name="returnUtil" placeholder="ApiReturnObject">
<input type="text" class="form-control" id="returnUtil" name="returnUtil" value="ApiReturnObject">
<div class="input-group-prepend">
<span class="input-group-text">包名路径</span>
</div>
<input type="text" class="form-control" id="packageName" name="packageName" placeholder="com.softdev.system">
<input type="text" class="form-control" id="packageName" name="packageName" value="com.softdev.system">
</div>
<div class="input-group mb-3">
<div class="input-group-prepend">

24
pom.xml
View File

@@ -5,7 +5,7 @@
<groupId>com.softdev.system</groupId>
<artifactId>SpringBootCodeGenerator</artifactId>
<version>0.0.1-SNAPSHOT</version>
<version>2.0</version>
<packaging>pom</packaging>
<parent>
@@ -31,6 +31,18 @@
<dependency>
<groupId>org.springframework.boot</groupId>
<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>
<!-- https://mvnrepository.com/artifact/com.alibaba/fastjson -->
@@ -67,7 +79,7 @@
<dependency>
<groupId>cn.hutool</groupId>
<artifactId>hutool-all</artifactId>
<version>4.6.1</version>
<version>5.0.6</version>
</dependency>
<!-- lombok -->
@@ -134,7 +146,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<version>3.8.1</version>
<configuration>
<skip>true</skip>
<compilerId>javac</compilerId>
@@ -156,13 +168,13 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>3.0.1</version>
<version>3.1.0</version>
<configuration>
<!--<failOnMissingWebXml>false</failOnMissingWebXml>-->
<includeEmptyDirs>true</includeEmptyDirs>
</configuration>
</plugin>
<plugin>
<!--<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.1.1</version>
@@ -170,7 +182,7 @@
<failOnMissingWebXml>false</failOnMissingWebXml>
<warSourceExcludes>upload/**</warSourceExcludes>
</configuration>
</plugin>
</plugin>-->
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>