Skip to content

Commit f5359f8

Browse files
committed
生成后自动trim掉前后空格输出。完善ReadMe文档。
1 parent 8675730 commit f5359f8

File tree

21 files changed

+88
-1159
lines changed

21 files changed

+88
-1159
lines changed

README.md

Lines changed: 29 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@
2222
>generate to many popular templates by ddl-sql/insert-sql/simple json<br>
2323
>可通过`建表SQL语句``INSERT语句`或者`简单JSON`生成`JPA/JdbcTemplate/Mybatis/MybatisPlus/BeetlSQL`相关模板代码.
2424
>
25-
>thanks for your using , the 600pv per day and the 700 stars totals inspired me<br>
26-
> 感谢大家的使用和反馈,每天600PV和700的星星是前进和继续做下去的东西
25+
>thanks for your using and feedback,I'm inspired by the 600PV every day and github more than 700 stars <br>
26+
> 感谢大家的使用和反馈,每天六百的PV和获得超过七百多的星星是我前进和继续做下去的动力
2727
>
2828
>hope everyone can keep good balance on work and life , stay health and safety , be smooth on work as well<br>
2929
> 愿大家可以维持生活和工作平衡,保持健康和安全,祝大家工作顺利!
@@ -44,9 +44,10 @@
4444

4545
感谢`三叔`将他部署在[DEVTOOLS](https://java.devtools.cn/)上,继续作为Golden Tool开放给大家使用。<br>
4646

47+
Thanks for `JetBrains` providing us the `Licenses for Open Source Development`[Get free access to all JetBrains tools for developing your open source project!](https://www.jetbrains.com/community/opensource/#support) .<br>
4748

4849
|访问地址|http://localhost:1234/generator|
49-
|----|----|
50+
|:----|:----|
5051
|BEJSON 在线地址|https://java.bejson.com/generator|
5152
|DEVTOOLS 在线地址|https://java.devtools.cn|
5253
|CSDN BLOG|https://zhengkai.blog.csdn.net|
@@ -56,8 +57,9 @@
5657

5758
# Update Logs
5859
|更新日期|更新内容|
59-
|----|----|
60-
|2021.01.16|全新3.0版本:一、前端半vue半js化,更多动态加载项。二、支持更多生成设置,优化生成场景。三、js导入支持本地/CDN模式,支持断网环境轻松使用。|
60+
|:----|:----|
61+
|2021.01.17|生成后自动trim掉前后空格输出。完善ReadMe文档。|
62+
|2021.01.16|全新3.0版本:<br>一、前端半vue半js化,更多动态加载项。<br>二、支持更多生成设置,优化生成场景。<br>三、js导入支持本地/CDN模式,支持断网环境轻松使用。|
6163
|2020.10.22|1.tinyint多加一个Short类型转换(感谢@wttHero的建议)|
6264
|2020.10.20|1.修复mapper2 insert代码问题(感谢@mXiaoWan的PR)<br>2.优化对fulltext/index关键字的处理(感谢@WEGFan的反馈)。<br>3.新增日期类型的转换选择(感谢@qingkediguo的建议)。<br>4.新增是否包装类型的转换选择。|
6365
|2020.06.28|优化Util下的BeanUtil,支持更多map.put的操作。整合CRUD模板到SQL(CRUD)模板。|
@@ -103,8 +105,8 @@
103105
|2018.08.31|初始化项目.新增JPA系列Entity+Repository模板.|
104106

105107
# ClassInfo/TableInfo
106-
|字段名|说明|
107-
|-|-|
108+
|名称|说明|
109+
|:----|:----|
108110
|packageName|自定义的包名|
109111
|authorName|自定义的作者名|
110112
|tableName|sql中的表名|
@@ -113,6 +115,26 @@
113115
|fieldName|字段名|
114116
|fieldComment|字段备注|
115117

118+
# Options
119+
|名称|说明|默认值|
120+
|:----|:----|:----|
121+
|作者 |authorName|zhengkai.blog.csdn.net|
122+
|包名 |packageName|cn.devtools|
123+
|返回(成功)|returnUtilSuccess|Return.SUCCESS|
124+
|返回(失败)|returnUtilFailure|Return.ERROR|
125+
|忽略前缀|ignorePrefix |sys_|
126+
|输入类型 |dataType|DDL SQL|
127+
|TinyInt转换 |tinyintTransType|int|
128+
|时间类型 |timeTransType|Date|
129+
|命名类型 |nameCaseType|CamelCase/驼峰|
130+
|是否包装类型 |isPackageType|true|
131+
|是否swaggerUI|isSwagger|false|
132+
|是否字段注释|isComment|true|
133+
|是否自动引包|isAutoImport||
134+
|是否带包路径|isWithPackage||
135+
|是否Lombok|isLombok|true|
136+
137+
116138
# How to add a new template
117139
1. `resources/templates/code-generator`中找到对应类型
118140
2. COPY并编写freemarker模板文件`.ftl`

generator-web/src/main/java/com/softdev/system/generator/config/GlobalDefaultExceptionHandler.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,17 @@
77

88
import javax.servlet.http.HttpServletRequest;
99

10+
/**
11+
* @author zhengkai.blog.csdn.net
12+
*/
1013
@ControllerAdvice
1114
public class GlobalDefaultExceptionHandler {
1215

1316
@ExceptionHandler(Exception.class)
1417
@ResponseBody
1518
public ReturnT defaultExceptionHandler(HttpServletRequest req, Exception e) {
1619
e.printStackTrace();
17-
return ReturnT.error(e.getMessage());
20+
return ReturnT.error("代码生成失败:"+e.getMessage());
1821
}
1922

2023
}

generator-web/src/main/java/com/softdev/system/generator/controller/GeneratorController.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
import org.springframework.stereotype.Controller;
1414
import org.springframework.web.bind.annotation.*;
1515

16-
import java.util.HashMap;
1716
import java.util.Map;
1817

1918
/**

generator-web/src/main/resources/statics/js/main.js

Lines changed: 31 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,17 @@ $(function(){
77

88
//init input code area
99
$.inputArea = CodeMirror.fromTextArea(document.getElementById("inputArea"), {
10-
lineNumbers: true,
11-
lineWrapping: false,
12-
readOnly: false,
13-
foldGutter: true,
14-
mode: "text/x-sql"
10+
mode: "text/x-sql", // SQL
11+
theme: "idea", // IDEA主题
12+
lineNumbers: true, //显示行号
13+
smartIndent: true, // 自动缩进
14+
autoCloseBrackets: true// 自动补全括号
1515
});
1616
$.inputArea.setSize('auto','auto');
1717

1818
// init output code area
1919
$.outputArea = CodeMirror.fromTextArea(document.getElementById("outputArea"), {
20-
mode: "text/x-java", //Java语言
20+
theme: "idea", // IDEA主题
2121
lineNumbers: true, //显示行号
2222
smartIndent: true, // 自动缩进
2323
autoCloseBrackets: true// 自动补全括号
@@ -70,7 +70,7 @@ const vm = new Vue({
7070
const targetModel = event.target.innerText.trim();
7171
console.log(targetModel);
7272
vm.outputStr=vm.outputJson[targetModel];
73-
$.outputArea.setValue(vm.outputStr);
73+
$.outputArea.setValue(vm.outputStr.trim());
7474
//console.log(vm.outputStr);
7575
$.outputArea.setSize('auto', 'auto');
7676
},
@@ -86,11 +86,30 @@ const vm = new Vue({
8686
}else{
8787
alert("浏览器不支持sessionStorage");
8888
}
89-
vm.outputStr=vm.outputJson["plusentity"];
89+
vm.outputStr=vm.outputJson["plusentity"].trim();
9090
$.outputArea.setValue(vm.outputStr);
9191
//console.log(vm.outputStr);
9292
$.outputArea.setSize('auto', 'auto');
9393
},
94+
setHistoricalData : function (tableName){
95+
//add new table only
96+
if(vm.historicalData.indexOf(tableName)<0){
97+
vm.historicalData.unshift(tableName);
98+
}
99+
//remove last record , if more than N
100+
if(vm.historicalData.length>9){
101+
vm.historicalData.splice(9,1);
102+
}
103+
//get and set to session data
104+
const valueSession = sessionStorage.getItem(tableName);
105+
//remove if exists
106+
if(valueSession!==undefined && valueSession!=null){
107+
sessionStorage.removeItem(tableName);
108+
}
109+
//set data to session
110+
sessionStorage.setItem(tableName,JSON.stringify(vm.outputJson));
111+
//console.log(vm.historicalData);
112+
},
94113
//request with formData to generate the code 根据参数生成代码
95114
generate : function(){
96115
//get value from codemirror
@@ -103,34 +122,18 @@ const vm = new Vue({
103122
//console.log(res.outputJson);
104123
vm.outputJson=res.outputJson;
105124
// console.log(vm.outputJson["bootstrap-ui"]);
106-
vm.outputStr=vm.outputJson["plusentity"];
125+
vm.outputStr=vm.outputJson["plusentity"].trim();
107126
//console.log(vm.outputJson["bootstrap-ui"]);
108127
//console.log(vm.outputStr);
109128
$.outputArea.setValue(vm.outputStr);
110129
$.outputArea.setSize('auto', 'auto');
111130
//add to historicalData
112-
const tableName = res.outputJson.tableName;
113-
//add new table only
114-
if(vm.historicalData.indexOf(tableName)<0){
115-
vm.historicalData.unshift(tableName);
116-
}
117-
//remove last record , if more than N
118-
if(vm.historicalData.length>9){
119-
vm.historicalData.splice(9,1);
120-
}
121-
//get and set to session data
122-
const valueSession = sessionStorage.getItem(tableName);
123-
//remove if exists
124-
if(valueSession!==undefined && valueSession!=null){
125-
sessionStorage.removeItem(tableName);
126-
}
127-
//set data to session
128-
sessionStorage.setItem(tableName,JSON.stringify(vm.outputJson));
129-
//console.log(vm.historicalData);
131+
vm.setHistoricalData(res.outputJson.tableName);
132+
alert("生成成功");
130133
});
131134
},
132135
copy : function (){
133-
navigator.clipboard.writeText(vm.outputStr).then(r => {alert("已复制")});
136+
navigator.clipboard.writeText(vm.outputStr.trim()).then(r => {alert("已复制")});
134137
}
135138
},
136139
created: function () {

generator-web/src/main/resources/statics/plugins/codemirror/codemirror.min.css

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

generator-web/src/main/resources/statics/plugins/codemirror/idea.min.css

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

generator-web/src/main/resources/statics/plugins/layer/layer.js

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

generator-web/src/main/resources/statics/plugins/layer/mobile/layer.js

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)