mirror of
https://github.com/moshowgame/SpringBootCodeGenerator.git
synced 2025-12-26 05:48:33 +08:00
commit
9b6562b773
@ -27,6 +27,7 @@
|
||||
|
||||
|更新日期|更新内容|
|
||||
|-|-|
|
||||
|20200206|1.新增历史记录功能,自动保存最近生成的对象 2.新增swagger开关选项和修复@Column带name参数(感谢@liuyu-struggle的建议) 3.去除mybatis模板中的方括号[]和修改模板里的类注释样式(感谢@gaohanghang的PR)|
|
||||
|20191229|1.修复bejson安全防护策略拦截问题(感谢@liangbintao和@1808083642的反馈) 2.优化字段名含date字符串的处理(感谢@smilexzh的反馈) 3.控制台动态输出项目访问地址(感谢@gaohanghang的提交)|
|
||||
|20191128|1.修复支持string-copy导致的以n结尾的字母不显示问题 2.jpa-entity新增swagger@ApiModel@ApiModelProperty注解和SQL字段@Column注解(感谢@yjq907的建议) |
|
||||
|20191126|1.springboot2内置tomcat更换为性能更强大的undertow 2.修复tinyintTransType参数丢失问题 |
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
package com.softdev.system.generator.controller;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.softdev.system.generator.entity.ClassInfo;
|
||||
import com.softdev.system.generator.entity.ParamInfo;
|
||||
import com.softdev.system.generator.entity.ReturnT;
|
||||
@ -60,9 +61,14 @@ public class IndexController {
|
||||
// process the param
|
||||
Map<String, Object> params = new HashMap<String, Object>(8);
|
||||
params.put("classInfo", classInfo);
|
||||
params.put("tableName", classInfo==null?System.currentTimeMillis():classInfo.getTableName());
|
||||
params.put("authorName", paramInfo.getAuthorName());
|
||||
params.put("packageName", paramInfo.getPackageName());
|
||||
params.put("returnUtil", paramInfo.getReturnUtil());
|
||||
params.put("swagger", paramInfo.isSwagger());
|
||||
|
||||
//log the params
|
||||
//log.info(JSON.toJSONString(paramInfo));
|
||||
|
||||
log.info("generator table:"+(classInfo==null?"":classInfo.getTableName())
|
||||
+",field size:"+((classInfo==null||classInfo.getFieldList()==null)?"":classInfo.getFieldList().size()));
|
||||
|
||||
@ -15,6 +15,7 @@ public class ParamInfo {
|
||||
private String nameCaseType;
|
||||
private String tinyintTransType;
|
||||
private String dataType;
|
||||
private boolean swagger;
|
||||
|
||||
@Data
|
||||
public static class NAME_CASE_TYPE{
|
||||
|
||||
@ -25,7 +25,7 @@ public class GeneratorServiceImpl implements GeneratorService {
|
||||
public Map<String, String> getResultByParams(Map<String, Object> params) throws IOException, TemplateException {
|
||||
// result
|
||||
Map<String, String> result = new HashMap<String, String>(32);
|
||||
|
||||
result.put("tableName",params.get("tableName")+"");
|
||||
//UI
|
||||
result.put("swagger-ui", freemarkerTool.processString("code-generator/ui/swagger-ui.ftl", params));
|
||||
result.put("element-ui", freemarkerTool.processString("code-generator/ui/element-ui.ftl", params));
|
||||
|
||||
@ -1 +1 @@
|
||||
{"version": "20191229"}
|
||||
{"version": "20200206"}
|
||||
@ -19,8 +19,8 @@ import io.swagger.annotations.ApiModelProperty;
|
||||
*/
|
||||
@Entity
|
||||
@Data
|
||||
@Table(name="${classInfo.tableName}")
|
||||
@ApiModel("${classInfo.classComment}")
|
||||
@Table(name="${classInfo.tableName}")<#if swagger?exists && swagger==true>
|
||||
@ApiModel("${classInfo.classComment}")</#if>
|
||||
public class ${classInfo.className} implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
@ -31,9 +31,9 @@ public class ${classInfo.className} implements Serializable {
|
||||
<#list classInfo.fieldList as fieldItem >
|
||||
/**
|
||||
* ${fieldItem.fieldComment}
|
||||
*/
|
||||
@ApiModelProperty("${fieldItem.fieldComment}")
|
||||
@Column("${fieldItem.columnName}")
|
||||
*/<#if swagger?exists && swagger==true>
|
||||
@ApiModelProperty("${fieldItem.fieldComment}")</#if>
|
||||
@Column(name="${fieldItem.columnName}")
|
||||
private ${fieldItem.fieldClass} ${fieldItem.fieldName};
|
||||
|
||||
</#list>
|
||||
|
||||
@ -59,6 +59,12 @@
|
||||
});
|
||||
return o;
|
||||
};
|
||||
var historyCount=0;
|
||||
//初始化清除session
|
||||
if (window.sessionStorage){
|
||||
//修复当F5刷新的时候,session没有清空各个值,但是页面的button没了。
|
||||
sessionStorage.clear();
|
||||
}
|
||||
/**
|
||||
* 生成代码
|
||||
*/
|
||||
@ -70,7 +76,8 @@
|
||||
"authorName":$("#authorName").val(),
|
||||
"dataType":$("#dataType").val(),
|
||||
"tinyintTransType":$("#tinyintTransType").val(),
|
||||
"nameCaseType":$("#nameCaseType").val()
|
||||
"nameCaseType":$("#nameCaseType").val(),
|
||||
"swagger":$("#isSwagger").val()
|
||||
};
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
@ -81,9 +88,11 @@
|
||||
success: function (data) {
|
||||
if (data.code === 200) {
|
||||
codeData = data.data;
|
||||
genCodeArea.setValue(codeData.beetlentity);
|
||||
genCodeArea.setValue(codeData.entity);
|
||||
genCodeArea.setSize('auto', 'auto');
|
||||
$.toast("√ 代码生成成功");
|
||||
//添加历史记录
|
||||
addHistory(codeData);
|
||||
} else {
|
||||
$.toast("× 代码生成失败 :"+data.msg);
|
||||
}
|
||||
@ -91,6 +100,45 @@
|
||||
});
|
||||
return false;
|
||||
});
|
||||
/**
|
||||
* 切换历史记录
|
||||
*/
|
||||
function getHistory(tableName){
|
||||
if (window.sessionStorage){
|
||||
var valueSession = sessionStorage.getItem(tableName);
|
||||
codeData = JSON.parse(valueSession);
|
||||
$.toast("$ 切换历史记录成功:"+tableName);
|
||||
genCodeArea.setValue(codeData.entity);
|
||||
}else{
|
||||
console.log("浏览器不支持sessionStorage");
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 添加历史记录
|
||||
*/
|
||||
function addHistory(data){
|
||||
if (window.sessionStorage){
|
||||
//console.log(historyCount);
|
||||
if(historyCount>=9){
|
||||
$("#history").find(".btn:last").remove();
|
||||
historyCount--;
|
||||
}
|
||||
var tableName=data.tableName;
|
||||
var valueSession = sessionStorage.getItem(tableName);
|
||||
if(valueSession!==undefined && valueSession!=null){
|
||||
sessionStorage.removeItem(tableName);
|
||||
}else{
|
||||
$("#history").prepend('<button id="his-'+tableName+'" type="button" class="btn">'+tableName+'</button>');
|
||||
//$("#history").prepend('<button id="his-'+tableName+'" onclick="getHistory(\''+tableName+'\');" type="button" class="btn">'+tableName+'</button>');
|
||||
$("#his-"+tableName).bind('click', function () {getHistory(tableName)});
|
||||
}
|
||||
sessionStorage.setItem(tableName,JSON.stringify(data));
|
||||
historyCount++;
|
||||
}else{
|
||||
console.log("浏览器不支持sessionStorage");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 按钮事件组
|
||||
*/
|
||||
@ -169,7 +217,7 @@
|
||||
<div class="container">
|
||||
<h2>Spring Boot Code Generator!</h2>
|
||||
<p class="lead">
|
||||
√基于SpringBoot2+Freemarker的代码生成器,√以释放双手为目的,√支持mysql/oracle/pgsql三大数据库,<br>
|
||||
√基于SpringBoot2+Freemarker的<a class="lead" href="https://github.com/moshowgame/SpringBootCodeGenerator">代码生成器</a>,√以释放双手为目的,√支持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>,谢谢!<a id="version" href="#">查看版本</a>
|
||||
</p>
|
||||
@ -219,6 +267,14 @@
|
||||
<option value="UnderScoreCase">下划线</option>
|
||||
<#--<option value="UpperUnderScoreCase">大写下划线</option>-->
|
||||
</select>
|
||||
<div class="input-group-prepend">
|
||||
<span class="input-group-text">swagger-ui</span>
|
||||
</div>
|
||||
<select type="text" class="form-control" id="isSwagger"
|
||||
name="isSwagger">
|
||||
<option value="false">关闭</option>
|
||||
<option value="true">开启</option>
|
||||
</select>
|
||||
</div>
|
||||
<textarea id="ddlSqlArea" placeholder="请输入表结构信息..." class="form-control btn-lg" style="height: 250px;">
|
||||
CREATE TABLE 'userinfo' (
|
||||
@ -229,6 +285,7 @@ CREATE TABLE 'userinfo' (
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='用户信息'
|
||||
</textarea><br>
|
||||
<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 id="history" class="btn-group" role="group" aria-label="Basic example"></div>
|
||||
<hr>
|
||||
<!-- Example row of columns -->
|
||||
<div class="row" style="margin-top: 10px;">
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user