40
README.md
@ -6,36 +6,37 @@
|
||||
|
||||
SpringBootCodeGenerator
|
||||
----
|
||||
基于SpringBoot2+Freemarker的代码生成器,用DDL SQL语句生成JPA/JdbcTemplate/Mybatis/BeetlSQL相关代码,支持mysql/oracle/pgsql等三大数据库。以释放双手为目的,各大模板也在陆续补充和优化。欢迎大家Issue提交模板和交流想法,也欢迎提交PullRequest!
|
||||
<br><br>
|
||||
√基于SpringBoot2+Freemarker的代码生成器,√以释放双手为目的,√支持mysql/oracle/pgsql三大数据库,<br>
|
||||
√用DDL-SQL语句生成JPA/JdbcTemplate/Mybatis/MybatisPlus/BeetlSQL相关代码。<br><br>
|
||||
另外,感谢bejson三叔将他部署在 http://java.bejson.com/generator 上,目前是besjon专供工具(线上版本不一定是最新的,会有延迟,请谅解,谢谢)。
|
||||
<br><br>
|
||||
<table><tbody>
|
||||
<tr><td>访问路径</td> <td>http://127.0.0.1:1234/generator</td></tr>
|
||||
<tr><td>在线地址</td> <td>http://java.bejson.com/generator</td></tr>
|
||||
<tr><td>CSDN博客</td> <td>http://blog.csdn.net/moshowgame</td></tr>
|
||||
<tr><td>CSDN博客</td> <td>http://zhengkai.blog.csdn.net</td></tr>
|
||||
<tr><td></td> <td></td></tr>
|
||||
<tr><td>更新日期</td> <td>更新内容</td></tr>
|
||||
<tr><td>20191115<td>1.添加tinyint类型转换(感谢@lixiliang&@liujiansgit的Suggestion) 2.添加一键复制功能(感谢@gaohanghang的Suggestion) 3.Mybatis的insert增加keyProperty="id"用于返回自增id(感谢@88888888888888888888的Suggestion) 4.优化date类型的支持(感谢@SteveLsf的反馈) 5.其他一些优化. </td></tr>
|
||||
<tr><td>20191015<td>修复jdbcTemplates中insert语句第一个字段丢失的问题。 </td></tr>
|
||||
<tr><td>20190915<td>1.添加对象getset模板 2.添加sql模板 3.启动类添加日志输出,方便项目使用(感谢@gaohanghang 的pull request) </td></tr>
|
||||
<tr><td>20190915<td>1.添加对象getset模板 2.添加sql模板 3.启动类添加日志输出,方便项目使用(感谢@gaohanghang 的pull request) </td></tr>
|
||||
<tr><td>20190910-2<td>优化以及更新Maven依赖,减少打包体积。 </td></tr>
|
||||
<tr><td>20190910-1<td>1.修复mapper接口load方法,但是xml中方法不匹配问题 2.移除mapper中CRUD时的@param 注解,会影响xml的解析(感谢@caojiantao的反馈)。3.优化MyBatis的xml文件对Oracle的支持。(感谢@wylove1992的反馈) 4.新增对boolean的处理(感谢@violinxsc的反馈)以及优化tinyint类型生成boolean类型问题(感谢@hahaYhui的反馈) </td></tr>
|
||||
<tr><td>20190909<td>添加是否下划线转换为驼峰的选择(感谢@youngking28 的pull request)。</td></tr>
|
||||
<tr><td>20190518<td>1.优化注释 2.修改 mybatis模板中 controller注解 3.修改 mybatis模板中 dao文件使用为 mapper文件 4.修改 mybatis模板中 service实现类中的一个 bug 5.修改 index.ftl文件中 mybatis模板的 dao -> mapper(感谢@unqin的pull request)</td></tr>
|
||||
<tr><td>20190511<td>优化mybatis模块的dao和xml模板,修改dao接口注解为@Repository,所有dao参数改为包装类,删除update语句最后的UpdateTime = NOW(),修改dao接口文件的方法注释使其更符合javaDoc的标准,修改insert语句增加插入行主键的返回,修改load的方法名为selectByPrimaryKey,修改xml的update语句新增动态if判空,修改xml的insert语句新增动态插入判空,更符合mybatisGenerator标准(感谢@Archer-Wen的贡献 )。</td></tr>
|
||||
<tr><td>20190429<td>新增返回封装工具类设置,优化对oracle注释comment on column的支持(感谢@liukex反馈),优化对普通和特殊storage关键字的判断(感谢@AhHeadFloating的反馈 )。</td></tr>
|
||||
<tr><td>20190211<td>提交gitignore,解决StringUtils.lowerCaseFirst潜在的NPE异常,校验修改为@RequestParam参数校验,lombok之@Data和@Slf4j优化,fix JdbcDAO模板类名显示为中文问题,WebMvcConfig整合MessageConverter,模板代码分类(感谢@liutf和@tfgzs的pull request)。</td></tr>
|
||||
<tr><td>20190210<td>实体生成规则切换为包装类型,不再采用基本数据类型,为实体类生成添加显示的默认构造方法(感谢@h2so的pull request)。</td></tr>
|
||||
<tr><td>20190106<td>修复处理number/decimal(x,x)类型的逻辑(感谢@arthaschan的反馈),修复JdbcTemplates模板两处错误(感谢@everflourish的反馈)。</td></tr>
|
||||
<tr><td>20181212<td>首页UI优化,新增MybatisPlus模块(感谢@三叔同事的建议),修复作者名和包名获取失败问题(感谢@Yanch1994的反馈)。</td></tr>
|
||||
<tr><td>20181122<td>优化正则表达式点号的处理,优化处理字段类型,对number类型增加int,long,BigDecimal的区分判断(感谢@lshz0088的指导)。</td></tr>
|
||||
<tr><td>20181108<td>修复非字段描述"KEY FK_xxxx (xxxx)"导致生成KEY字段情况(感谢@tornadoorz反馈)。</td></tr>
|
||||
<tr><td>20181018<td>支持double(x,x)的类型,以及comment里面包含一些特殊字符的处理(感谢@tanwubo的反馈)。</td></tr>
|
||||
<tr><td>20190910-1<td>1.修复mapper接口load方法,但是xml中方法不匹配问题 2.移除mapper中CRUD时的@param 注解,会影响xml的解析(感谢@caojiantao的反馈)。3.优化MyBatis的xml文件对Oracle的支持。(感谢@wylove1992的反馈) 4.新增对boolean的处理(感谢@violinxsc的反馈)以及优化tinyint类型生成boolean类型问题(感谢@hahaYhui的反馈) </td></tr>
|
||||
<tr><td>20190909<td>添加是否下划线转换为驼峰的选择(感谢@youngking28 的pull request)。</td></tr>
|
||||
<tr><td>20190518<td>1.优化注释 2.修改 mybatis模板中 controller注解 3.修改 mybatis模板中 dao文件使用为 mapper文件 4.修改 mybatis模板中 service实现类中的一个 bug 5.修改 index.ftl文件中 mybatis模板的 dao -> mapper(感谢@unqin的pull request)</td></tr>
|
||||
<tr><td>20190511<td>优化mybatis模块的dao和xml模板,修改dao接口注解为@Repository,所有dao参数改为包装类,删除update语句最后的UpdateTime = NOW(),修改dao接口文件的方法注释使其更符合javaDoc的标准,修改insert语句增加插入行主键的返回,修改load的方法名为selectByPrimaryKey,修改xml的update语句新增动态if判空,修改xml的insert语句新增动态插入判空,更符合mybatisGenerator标准(感谢@Archer-Wen的贡献 )。</td></tr>
|
||||
<tr><td>20190429<td>新增返回封装工具类设置,优化对oracle注释comment on column的支持(感谢@liukex反馈),优化对普通和特殊storage关键字的判断(感谢@AhHeadFloating的反馈 )。</td></tr>
|
||||
<tr><td>20190211<td>提交gitignore,解决StringUtils.lowerCaseFirst潜在的NPE异常,校验修改为@RequestParam参数校验,lombok之@Data和@Slf4j优化,fix JdbcDAO模板类名显示为中文问题,WebMvcConfig整合MessageConverter,模板代码分类(感谢@liutf和@tfgzs的pull request)。</td></tr>
|
||||
<tr><td>20190210<td>实体生成规则切换为包装类型,不再采用基本数据类型,为实体类生成添加显示的默认构造方法(感谢@h2so的pull request)。</td></tr>
|
||||
<tr><td>20190106<td>修复处理number/decimal(x,x)类型的逻辑(感谢@arthaschan的反馈),修复JdbcTemplates模板两处错误(感谢@everflourish的反馈)。</td></tr>
|
||||
<tr><td>20181212<td>首页UI优化,新增MybatisPlus模块(感谢@三叔同事的建议),修复作者名和包名获取失败问题(感谢@Yanch1994的反馈)。</td></tr>
|
||||
<tr><td>20181122<td>优化正则表达式点号的处理,优化处理字段类型,对number类型增加int,long,BigDecimal的区分判断(感谢@lshz0088的指导)。</td></tr>
|
||||
<tr><td>20181108<td>修复非字段描述"KEY FK_xxxx (xxxx)"导致生成KEY字段情况(感谢@tornadoorz反馈)。</td></tr>
|
||||
<tr><td>20181018<td>支持double(x,x)的类型,以及comment里面包含一些特殊字符的处理(感谢@tanwubo的反馈)。</td></tr>
|
||||
<tr><td>20181010<td>CDN变更,修复CDN不稳定导致网页js报错问题。</td></tr>
|
||||
<tr><td>20181003<td>新增element-ui/bootstrap生成。</td></tr>
|
||||
<tr><td>20181002<td>修复公共CDN之Layer.js404问题,导致项目无法生成。</td></tr>
|
||||
<tr><td>20180927<td>优化COMMENT提取逻辑,支持多种复杂情况的注释(感谢@raodeming的反馈)。</td></tr>
|
||||
<tr><td>20180926<td>全新BeetlSQL模块,以及一些小细节优化(感谢@三叔同事的建议)。</td></tr>
|
||||
<tr><td>20180927<td>优化COMMENT提取逻辑,支持多种复杂情况的注释(感谢@raodeming的反馈)。</td></tr>
|
||||
<tr><td>20180926<td>全新BeetlSQL模块,以及一些小细节优化(感谢@三叔同事的建议)。</td></tr>
|
||||
<tr><td>20180925<td>优化SQL表和字段备注的推断,包括pgsql/oralce的comment on column/table情况处理等。</td></tr>
|
||||
<tr><td>20180918<td>优化SQL类型推断。优化PrimaryKey判断。修复jpacontroller中Repository拼写错误问题。</td></tr>
|
||||
<tr><td>20180917<td>全新首页,静态文件全部采用CDN。新增jdbcTemplate模块。</td></tr>
|
||||
@ -61,6 +62,5 @@ SpringBootCodeGenerator
|
||||
<img src="./codegenerator1.png">
|
||||
<img src="./codegenerator2.png">
|
||||
<img src="./codegenerator3.png">
|
||||
<img src="./codegenerator4.png">
|
||||
<img src="./donate.jpg">
|
||||
<table>
|
||||
|
||||
|
||||
|
Before Width: | Height: | Size: 183 KiB After Width: | Height: | Size: 203 KiB |
|
Before Width: | Height: | Size: 26 KiB After Width: | Height: | Size: 52 KiB |
|
Before Width: | Height: | Size: 129 KiB After Width: | Height: | Size: 125 KiB |
|
Before Width: | Height: | Size: 9.5 KiB |
@ -2,8 +2,8 @@ package com.softdev.system.generator.controller;
|
||||
|
||||
import com.softdev.system.generator.entity.ClassInfo;
|
||||
import com.softdev.system.generator.entity.ReturnT;
|
||||
import com.softdev.system.generator.util.CodeGeneratorTool;
|
||||
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;
|
||||
@ -40,8 +40,9 @@ public class IndexController {
|
||||
@RequestParam(required = false, defaultValue = "大狼狗") String authorName,
|
||||
@RequestParam(required = false, defaultValue = "com.softdev.system")String packageName,
|
||||
@RequestParam(required = false, defaultValue = "ApiReturnUtil")String returnUtil,
|
||||
@RequestParam(required = false, defaultValue = "true")boolean isUnderLineToCamelCase
|
||||
) {
|
||||
@RequestParam(required = false, defaultValue = "true")boolean isUnderLineToCamelCase,
|
||||
@RequestParam(required = false, defaultValue = "boolean")String tinyintTransType
|
||||
) {
|
||||
|
||||
|
||||
try {
|
||||
@ -51,17 +52,17 @@ public class IndexController {
|
||||
}
|
||||
|
||||
// parse table
|
||||
ClassInfo classInfo = CodeGeneratorTool.processTableIntoClassInfo(tableSql, isUnderLineToCamelCase);
|
||||
ClassInfo classInfo = TableParseUtil.processTableIntoClassInfo(tableSql, isUnderLineToCamelCase, tinyintTransType);
|
||||
|
||||
// code genarete
|
||||
Map<String, Object> params = new HashMap<String, Object>();
|
||||
Map<String, Object> params = new HashMap<String, Object>(8);
|
||||
params.put("classInfo", classInfo);
|
||||
params.put("authorName", authorName);
|
||||
params.put("packageName", packageName);
|
||||
params.put("returnUtil", returnUtil);
|
||||
|
||||
// result
|
||||
Map<String, String> result = new HashMap<String, String>();
|
||||
Map<String, String> result = new HashMap<String, String>(32);
|
||||
|
||||
//UI
|
||||
result.put("swagger-ui", freemarkerTool.processString("code-generator/ui/swagger-ui.ftl", params));
|
||||
|
||||
@ -1,26 +0,0 @@
|
||||
package com.softdev.system.generator.util;
|
||||
|
||||
|
||||
|
||||
import com.softdev.system.generator.entity.ClassInfo;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* code generate tool
|
||||
*
|
||||
* @author xuxueli 2018-04-25 16:29:58
|
||||
*/
|
||||
public class CodeGeneratorTool {
|
||||
|
||||
/**
|
||||
* process Table Into ClassInfo
|
||||
*
|
||||
* @param tableSql
|
||||
* @return
|
||||
*/
|
||||
public static ClassInfo processTableIntoClassInfo(String tableSql, boolean isUnderLineToCamelCase) throws IOException {
|
||||
return TableParseUtil.processTableIntoClassInfo(tableSql, isUnderLineToCamelCase);
|
||||
}
|
||||
|
||||
}
|
||||
@ -4,8 +4,7 @@ import freemarker.template.Configuration;
|
||||
import freemarker.template.Template;
|
||||
import freemarker.template.TemplateException;
|
||||
import freemarker.template.TemplateExceptionHandler;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
@ -18,8 +17,8 @@ import java.util.Map;
|
||||
*
|
||||
* @author xuxueli 2018-05-02 19:56:00
|
||||
*/
|
||||
@Slf4j
|
||||
public class FreemarkerUtil {
|
||||
private static final Logger logger = LoggerFactory.getLogger(CodeGeneratorTool.class);
|
||||
|
||||
/**
|
||||
* freemarker config
|
||||
@ -40,7 +39,7 @@ public class FreemarkerUtil {
|
||||
freemarkerConfig.setLocale(Locale.CHINA);
|
||||
freemarkerConfig.setTemplateExceptionHandler(TemplateExceptionHandler.RETHROW_HANDLER);
|
||||
} catch (IOException e) {
|
||||
logger.error(e.getMessage(), e);
|
||||
log.error(e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -24,7 +24,8 @@ public class TableParseUtil {
|
||||
* @param tableSql
|
||||
* @return
|
||||
*/
|
||||
public static ClassInfo processTableIntoClassInfo(String tableSql, boolean isUnderLineToCamelCase) throws IOException {
|
||||
public static ClassInfo processTableIntoClassInfo(String tableSql, boolean isUnderLineToCamelCase,String tinyintTransType)
|
||||
throws IOException {
|
||||
if (tableSql==null || tableSql.trim().length()==0) {
|
||||
throw new CodeGenerateException("Table structure can not be empty.");
|
||||
}
|
||||
@ -41,7 +42,9 @@ public class TableParseUtil {
|
||||
}
|
||||
|
||||
//新增处理create table if not exists members情况
|
||||
if (tableName.contains("if not exists")) tableName=tableName.replaceAll("if not exists","");
|
||||
if (tableName.contains("if not exists")) {
|
||||
tableName=tableName.replaceAll("if not exists","");
|
||||
}
|
||||
|
||||
if (tableName.contains("`")) {
|
||||
tableName = tableName.substring(tableName.indexOf("`")+1, tableName.lastIndexOf("`"));
|
||||
@ -101,20 +104,22 @@ public class TableParseUtil {
|
||||
String fieldListTmp = tableSql.substring(tableSql.indexOf("(")+1, tableSql.lastIndexOf(")"));
|
||||
|
||||
// 匹配 comment,替换备注里的小逗号, 防止不小心被当成切割符号切割
|
||||
Matcher matcher = Pattern.compile("comment `(.*?)\\`").matcher(fieldListTmp); // "\\{(.*?)\\}"
|
||||
while(matcher.find()){
|
||||
String commentPattenStr1="comment `(.*?)\\`";
|
||||
Matcher matcher1 = Pattern.compile(commentPattenStr1).matcher(fieldListTmp);
|
||||
while(matcher1.find()){
|
||||
|
||||
String commentTmp = matcher.group();
|
||||
String commentTmp = matcher1.group();
|
||||
//2018-9-27 zhengk 不替换,只处理,支持COMMENT评论里面多种注释
|
||||
//commentTmp = commentTmp.replaceAll("\\ comment `|\\`", " "); // "\\{|\\}"
|
||||
|
||||
if (commentTmp.contains(",")) {
|
||||
String commentTmpFinal = commentTmp.replaceAll(",", ",");
|
||||
fieldListTmp = fieldListTmp.replace(matcher.group(), commentTmpFinal);
|
||||
fieldListTmp = fieldListTmp.replace(matcher1.group(), commentTmpFinal);
|
||||
}
|
||||
}
|
||||
//2018-10-18 zhengkai 新增支持double(10, 2)等类型中有英文逗号的特殊情况
|
||||
Matcher matcher2 = Pattern.compile("\\`(.*?)\\`").matcher(fieldListTmp); // "\\{(.*?)\\}"
|
||||
String commentPattenStr2="\\`(.*?)\\`";
|
||||
Matcher matcher2 = Pattern.compile(commentPattenStr2).matcher(fieldListTmp);
|
||||
while(matcher2.find()){
|
||||
String commentTmp2 = matcher2.group();
|
||||
if (commentTmp2.contains(",")) {
|
||||
@ -123,7 +128,8 @@ public class TableParseUtil {
|
||||
}
|
||||
}
|
||||
//2018-10-18 zhengkai 新增支持double(10, 2)等类型中有英文逗号的特殊情况
|
||||
Matcher matcher3 = Pattern.compile("\\((.*?)\\)").matcher(fieldListTmp); // "\\{(.*?)\\}"
|
||||
String commentPattenStr3="\\((.*?)\\)";
|
||||
Matcher matcher3 = Pattern.compile(commentPattenStr3).matcher(fieldListTmp);
|
||||
while(matcher3.find()){
|
||||
String commentTmp3 = matcher3.group();
|
||||
if (commentTmp3.contains(",")) {
|
||||
@ -148,7 +154,6 @@ public class TableParseUtil {
|
||||
&&!columnLine.contains("pctincrease")
|
||||
&&!columnLine.contains("buffer_pool")&&!columnLine.contains("tablespace")
|
||||
&&!(columnLine.contains("primary")&&i>3));
|
||||
|
||||
if (specialFlag){
|
||||
//如果是oracle的number(x,x),可能出现最后分割残留的,x),这里做排除处理
|
||||
if(columnLine.length()<5) {continue;}
|
||||
@ -157,9 +162,8 @@ public class TableParseUtil {
|
||||
columnLine=columnLine.replaceAll("`"," ").replaceAll("\""," ").replaceAll("'","").replaceAll(" "," ").trim();
|
||||
//如果遇到username varchar(65) default '' not null,这种情况,判断第一个空格是否比第一个引号前
|
||||
columnName = columnLine.substring(0, columnLine.indexOf(" "));
|
||||
|
||||
// field Name
|
||||
// 2019-09-08 yj 添加是否下划线转换为驼峰的判断
|
||||
// 2019-09-08 yj 添加是否下划线转换为驼峰的判断
|
||||
String fieldName;
|
||||
if(isUnderLineToCamelCase){
|
||||
fieldName = StringUtils.lowerCaseFirst(StringUtils.underlineToCamelCase(columnName));
|
||||
@ -184,7 +188,7 @@ public class TableParseUtil {
|
||||
fieldClass = Float.class.getSimpleName();
|
||||
} else if (columnLine.contains("double")) {
|
||||
fieldClass = Double.class.getSimpleName();
|
||||
} else if (columnLine.contains("datetime") || columnLine.contains("timestamp")) {
|
||||
} else if (columnLine.contains("time") || columnLine.contains("date") || columnLine.contains("datetime") || columnLine.contains("timestamp")) {
|
||||
fieldClass = Date.class.getSimpleName();
|
||||
} else if (columnLine.contains("varchar") || columnLine.contains(" text")|| columnLine.contains("char")
|
||||
|| columnLine.contains("clob")||columnLine.contains("blob")||columnLine.contains("json")) {
|
||||
@ -221,9 +225,12 @@ public class TableParseUtil {
|
||||
}else{
|
||||
fieldClass = BigDecimal.class.getSimpleName();
|
||||
}
|
||||
} else if (columnLine.contains("boolean")|| columnLine.contains("tinyint") ) {
|
||||
} else if (columnLine.contains("boolean")) {
|
||||
//20190910 MOSHOW.K.ZHENG 新增对boolean的处理(感谢@violinxsc的反馈)以及修复tinyint类型字段无法生成boolean类型问题(感谢@hahaYhui的反馈)
|
||||
fieldClass = Boolean.class.getSimpleName();
|
||||
} else if (columnLine.contains("tinyint") ) {
|
||||
//20191115 MOSHOW.K.ZHENG 支持对tinyint的特殊处理
|
||||
fieldClass=tinyintTransType;
|
||||
} else {
|
||||
fieldClass = String.class.getSimpleName();
|
||||
}
|
||||
|
||||
@ -19,7 +19,7 @@
|
||||
</#if>
|
||||
</sql>
|
||||
|
||||
<insert id="insert" useGeneratedKeys="true" keyColumn="id" parameterType="${packageName}.entity.${classInfo.className}Entity">
|
||||
<insert id="insert" useGeneratedKeys="true" keyColumn="id" keyProperty="id" parameterType="${packageName}.entity.${classInfo.className}Entity">
|
||||
INSERT INTO ${classInfo.tableName}
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<#if classInfo.fieldList?exists && classInfo.fieldList?size gt 0>
|
||||
|
||||
@ -8,13 +8,13 @@
|
||||
<!-- Tell the browser to be responsive to screen width -->
|
||||
<meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
|
||||
<!-- Bootstrap 4 -->
|
||||
<link href="//cdn.staticfile.org/twitter-bootstrap/4.1.1/css/bootstrap.min.css" rel="stylesheet">
|
||||
<link href="//cdn.staticfile.org/twitter-bootstrap/4.3.1/css/bootstrap.min.css" rel="stylesheet">
|
||||
<!-- Font Awesome -->
|
||||
<link href="//cdn.staticfile.org/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet">
|
||||
<link href="//cdn.staticfile.org/font-awesome/5.11.2/css/fontawesome.min.css" rel="stylesheet">
|
||||
<!-- Ionicons -->
|
||||
<link href="//cdn.staticfile.org/ionicons/4.1.2/css/ionicons.min.css" rel="stylesheet">
|
||||
<link href="//cdn.staticfile.org/ionicons/4.5.6/css/ionicons.min.css" rel="stylesheet">
|
||||
|
||||
<link href="//cdn.staticfile.org/codemirror/5.42.0/codemirror.min.css" rel="stylesheet">
|
||||
<link href="//cdn.staticfile.org/codemirror/5.48.4/codemirror.min.css" rel="stylesheet">
|
||||
|
||||
<!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
|
||||
<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
|
||||
@ -28,33 +28,43 @@
|
||||
</#macro>
|
||||
|
||||
<#macro commonScript>
|
||||
|
||||
<!-- jQuery -->
|
||||
<script src="//cdn.staticfile.org/jquery/3.3.1/jquery.min.js"></script>
|
||||
<script src="//cdn.staticfile.org/jquery/3.4.1/jquery.min.js"></script>
|
||||
<!-- Bootstrap -->
|
||||
<script src="//cdn.staticfile.org/twitter-bootstrap/4.1.1/js/bootstrap.min.js"></script>
|
||||
<script src="//cdn.staticfile.org/twitter-bootstrap/4.3.1/js/bootstrap.min.js"></script>
|
||||
<!-- FastClick -->
|
||||
<script src="//cdn.staticfile.org/fastclick/1.0.6/fastclick.min.js"></script>
|
||||
<script src="//cdn.staticfile.org/jQuery-slimScroll/1.3.8/jquery.slimscroll.min.js"></script>
|
||||
<script src="//cdn.staticfile.org/layer/2.3/layer.js"></script>
|
||||
<script src="//cdn.staticfile.org/codemirror/5.42.0/codemirror.min.js"></script>
|
||||
<script src="//cdn.staticfile.org/codemirror/5.42.0/addon/display/placeholder.min.js"></script>
|
||||
<script src="//cdn.staticfile.org/codemirror/5.42.0/mode/clike/clike.min.js"></script>
|
||||
<script src="//cdn.staticfile.org/codemirror/5.42.0/mode/sql/sql.min.js"></script>
|
||||
<script src="//cdn.staticfile.org/codemirror/5.42.0/mode/xml/xml.min.js"></script>
|
||||
<script src="//cdn.staticfile.org/codemirror/5.48.4/codemirror.min.js"></script>
|
||||
<script src="//cdn.staticfile.org/codemirror/5.48.4/addon/display/placeholder.min.js"></script>
|
||||
<script src="//cdn.staticfile.org/codemirror/5.48.4/mode/clike/clike.min.js"></script>
|
||||
<script src="//cdn.staticfile.org/codemirror/5.48.4/mode/sql/sql.min.js"></script>
|
||||
<script src="//cdn.staticfile.org/codemirror/5.48.4/mode/xml/xml.min.js"></script>
|
||||
</#macro>
|
||||
|
||||
|
||||
<#macro commonFooter >
|
||||
<footer class="main-footer">
|
||||
<div class="container">
|
||||
Powered by <b>Spring Boot Code Generator</b> base on XXL Code Generator
|
||||
<div class="pull-right hidden-xs">
|
||||
<strong>Copyright © 2018-${.now?string('yyyy')}
|
||||
<a href="https://github.com/moshowgame/SpringBootCodeGenerator" target="_blank" >SpringBootCodeGenerator</a>
|
||||
<a href="https://github.com/xuxueli/xxl-code-generator" target="_blank" >xxl-code-generator</a>
|
||||
</strong><!-- All rights reserved. -->
|
||||
</div>
|
||||
</div>
|
||||
</footer>
|
||||
<hr>
|
||||
<footer>
|
||||
<footer class="bd-footer text-muted" role="contentinfo">
|
||||
<div class="container">
|
||||
<strong>Copyright © ${.now?string('yyyy')}-2022
|
||||
<p><a href="https://github.com/moshowgame/SpringBootCodeGenerator">SpringBootCodeGenerator</a>由<a href="https://blog.csdn.net/moshowgame" target="_blank">@Moshow/大狼狗/郑锴</a> 开发维护。 由 <a href="https://www.bejson.com">BeJson三叔 </a> 提供在线版本。点击<a href="#" id="donate2">赞赏</a>。</p>
|
||||
</div>
|
||||
</footer>
|
||||
</footer>
|
||||
</div> <!-- /container -->
|
||||
</#macro>
|
||||
|
||||
<#macro viewerCounter>
|
||||
var _hmt = _hmt || [];
|
||||
(function() {
|
||||
//百度统计一下
|
||||
var hm = document.createElement("script");
|
||||
hm.src = "https://hm.baidu.com/hm.js?97fd5ca1a4298ac8349c7e0de9029a0f";
|
||||
var s = document.getElementsByTagName("script")[0];
|
||||
s.parentNode.insertBefore(hm, s);
|
||||
})();
|
||||
</#macro>
|
||||
@ -4,14 +4,17 @@
|
||||
<meta charset="UTF-8">
|
||||
<title>SQL转Java JPA、MYBATIS实现类代码生成平台</title>
|
||||
<meta name="keywords" content="sql转实体类,sql转DAO,SQL转service,SQL转JPA实现,SQL转MYBATIS实现">
|
||||
|
||||
<#import "common/common-import.ftl" as netCommon>
|
||||
<@netCommon.commonStyle />
|
||||
|
||||
<@netCommon.commonScript />
|
||||
|
||||
<#--<script src="${request.contextPath}/static/js/index-new.js"></script>-->
|
||||
<script>
|
||||
$(function () {
|
||||
|
||||
<@netCommon.viewerCounter />
|
||||
|
||||
$(function () {
|
||||
/**
|
||||
* 初始化 table sql 3
|
||||
*/
|
||||
@ -58,15 +61,10 @@
|
||||
dataType: "json",
|
||||
success: function (data) {
|
||||
if (data.code == 200) {
|
||||
layer.open({
|
||||
icon: '1',
|
||||
content: "代码生成成功",
|
||||
end: function () {
|
||||
codeData = data.data;
|
||||
genCodeArea.setValue(codeData.beetlentity);
|
||||
genCodeArea.setSize('auto', 'auto');
|
||||
}
|
||||
});
|
||||
layer.msg("代码生成成功");
|
||||
codeData = data.data;
|
||||
genCodeArea.setValue(codeData.beetlentity);
|
||||
genCodeArea.setSize('auto', 'auto');
|
||||
} else {
|
||||
layer.open({
|
||||
icon: '2',
|
||||
@ -86,6 +84,9 @@
|
||||
genCodeArea.setSize('auto', 'auto');
|
||||
}
|
||||
});
|
||||
/**
|
||||
* 捐赠
|
||||
*/
|
||||
function donate(){
|
||||
layer.open({
|
||||
type: 1,
|
||||
@ -100,6 +101,13 @@
|
||||
$('#donate2').on('click', function(){
|
||||
donate();
|
||||
});
|
||||
$('#btnCopy').on('click', function(){
|
||||
if(!$.isEmptyObject(genCodeArea.getValue())&&!$.isEmptyObject(navigator)&&!$.isEmptyObject(navigator.clipboard)){
|
||||
navigator.clipboard.writeText(genCodeArea.getValue());
|
||||
layer.msg("复制成功");
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
</script>
|
||||
</head>
|
||||
@ -110,7 +118,7 @@
|
||||
<a class="navbar-brand" href="http://www.bejson.com">BeJSON在线工具站</a>
|
||||
<ul class="nav navbar-nav">
|
||||
<li class="nav-item active">
|
||||
<a class="nav-link" href="http://blog.csdn.net/moshowgame">大狼狗CSDN</a>
|
||||
<a class="nav-link" href="http://zhengkai.blog.csdn.net">大狼狗CSDN</a>
|
||||
</li>
|
||||
</ul>
|
||||
</nav>
|
||||
@ -121,13 +129,20 @@
|
||||
<div class="container">
|
||||
<h2>Spring Boot Code Generator!</h2>
|
||||
<p class="lead">
|
||||
基于<code>SpringBoot2</code>+<code>Freemarker</code>的代码生成器,用<code>DDL SQL</code>语句生成<code>JPA</code>/<code>JdbcTemplate</code>/<code>Mybatis</code>/<code>MybatisPlus</code>/<code>BeetlSQL</code>相关代码,支持<code>mysql</code>/<code>oracle</code>/<code>pgsql</code>三大数据库。以<code>释放双手</code>为目的,各大模板也在陆续补充和优化。欢迎大家多多提交模板和交流想法,如果发现有SQL语句不能识别,请<a href="https://github.com/moshowgame/SpringBootCodeGenerator/issues">留言</a>给我分析,同时欢迎大家进行<a href="https://github.com/moshowgame/SpringBootCodeGenerator/pulls">PullRequest</a>和<a href="#" id="donate1">赞赏</a>,谢谢!
|
||||
√基于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>,谢谢!
|
||||
</p>
|
||||
<hr>
|
||||
<div class="input-group mb-3">
|
||||
<div class="input-group-prepend">
|
||||
<span class="input-group-text">作者名称</span>
|
||||
</div>
|
||||
<input type="text" class="form-control" id="authorName" name="authorName" placeholder="大狼狗">
|
||||
<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>
|
||||
</div>
|
||||
@ -135,11 +150,17 @@
|
||||
</div>
|
||||
<div class="input-group mb-3">
|
||||
<div class="input-group-prepend">
|
||||
<span class="input-group-text">返回封装</span>
|
||||
<span class="input-group-text">tinyint转换类型</span>
|
||||
</div>
|
||||
<input type="text" class="form-control" id="returnUtil" name="returnUtil" placeholder="ApiReturnObject">
|
||||
<select type="text" class="form-control" id="tinyintTransType"
|
||||
name="tinyintTransType">
|
||||
<option value="boolean">boolean</option>
|
||||
<option value="Boolean">Boolean</option>
|
||||
<option value="Integer">Integer</option>
|
||||
<option value="int">int</option>
|
||||
</select>
|
||||
<div class="input-group-prepend">
|
||||
<span class="input-group-text">是否下划线转换为驼峰</span>
|
||||
<span class="input-group-text">是否转换下划线为驼峰</span>
|
||||
</div>
|
||||
<select type="text" class="form-control" id="isUnderLineToCamelCase"
|
||||
name="isUnderLineToCamelCase">
|
||||
@ -155,7 +176,7 @@ CREATE TABLE `userinfo` (
|
||||
PRIMARY KEY (`user_id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='用户信息'
|
||||
</textarea><br>
|
||||
<p><button class="btn btn-primary btn-lg disabled" id="btnGenCode" role="button">开始生成 »</button></p>
|
||||
<p><button class="btn btn-primary btn-lg disabled" id="btnGenCode" role="button">开始生成 »</button> <button class="btn alert-secondary" id="btnCopy">一键复制</button></p>
|
||||
<hr>
|
||||
<!-- Example row of columns -->
|
||||
<div class="row" style="margin-top: 10px;">
|
||||
@ -290,20 +311,6 @@ CREATE TABLE `userinfo` (
|
||||
<textarea id="genCodeArea" class="form-control btn-lg" ></textarea>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="container">
|
||||
|
||||
<hr>
|
||||
<footer>
|
||||
<footer class="bd-footer text-muted" role="contentinfo">
|
||||
<div class="container">
|
||||
<strong>Copyright © ${.now?string('yyyy')}-2022
|
||||
<p><a href="https://github.com/moshowgame/SpringBootCodeGenerator">SpringBootCodeGenerator</a>由<a href="https://blog.csdn.net/moshowgame" target="_blank">@Moshow/大狼狗/郑锴</a> 开发维护。 由 <a href="https://www.bejson.com">BeJson三叔 </a> 提供在线版本。点击<a href="#" id="donate2">赞赏</a>。</p>
|
||||
</div>
|
||||
</footer>
|
||||
</footer>
|
||||
</div> <!-- /container -->
|
||||
|
||||
|
||||
<@netCommon.commonFooter />
|
||||
</body>
|
||||
</html>
|
||||
|
||||