59
59
});
60
60
return o;
61
61
};
62
+ var historyCount= 0 ;
63
+ // 初始化清除session
64
+ if (window .sessionStorage ){
65
+ // 修复当F5刷新的时候,session没有清空各个值,但是页面的button没了。
66
+ sessionStorage .clear ();
67
+ }
62
68
/**
63
69
* 生成代码
64
70
*/
70
76
" authorName" : $ (" #authorName" ).val (),
71
77
" dataType" : $ (" #dataType" ).val (),
72
78
" tinyintTransType" : $ (" #tinyintTransType" ).val (),
73
- " nameCaseType" : $ (" #nameCaseType" ).val ()
79
+ " nameCaseType" : $ (" #nameCaseType" ).val (),
80
+ " swagger" : $ (" #isSwagger" ).val ()
74
81
};
75
82
$ .ajax ({
76
83
type: ' POST' ,
81
88
success : function (data ) {
82
89
if (data .code === 200 ) {
83
90
codeData = data .data ;
84
- genCodeArea .setValue (codeData .beetlentity );
91
+ genCodeArea .setValue (codeData .entity );
85
92
genCodeArea .setSize (' auto' , ' auto' );
86
93
$ .toast (" √ 代码生成成功" );
94
+ // 添加历史记录
95
+ addHistory (codeData);
87
96
} else {
88
97
$ .toast (" × 代码生成失败 :" + data .msg );
89
98
}
90
99
}
91
100
});
92
101
return false ;
93
102
});
103
+ /**
104
+ * 切换历史记录
105
+ */
106
+ function getHistory (tableName ){
107
+ if (window .sessionStorage ){
108
+ var valueSession = sessionStorage .getItem (tableName);
109
+ codeData = JSON .parse (valueSession);
110
+ $ .toast (" $ 切换历史记录成功:" + tableName);
111
+ genCodeArea .setValue (codeData .entity );
112
+ }else {
113
+ console .log (" 浏览器不支持sessionStorage" );
114
+ }
115
+ }
116
+ /**
117
+ * 添加历史记录
118
+ */
119
+ function addHistory (data ){
120
+ if (window .sessionStorage ){
121
+ // console.log(historyCount);
122
+ if (historyCount>= 9 ){
123
+ $ (" #history" ).find (" .btn:last" ).remove ();
124
+ historyCount-- ;
125
+ }
126
+ var tableName= data .tableName ;
127
+ var valueSession = sessionStorage .getItem (tableName);
128
+ if (valueSession!== undefined && valueSession!= null ){
129
+ sessionStorage .removeItem (tableName);
130
+ }else {
131
+ $ (" #history" ).prepend (' <button id="his-' + tableName+ ' " type="button" class="btn">' + tableName+ ' </button>' );
132
+ // $("#history").prepend('<button id="his-'+tableName+'" onclick="getHistory(\''+tableName+'\');" type="button" class="btn">'+tableName+'</button>');
133
+ $ (" #his-" + tableName).bind (' click' , function () {getHistory (tableName)});
134
+ }
135
+ sessionStorage .setItem (tableName,JSON .stringify (data));
136
+ historyCount++ ;
137
+ }else {
138
+ console .log (" 浏览器不支持sessionStorage" );
139
+ }
140
+ }
141
+
94
142
/**
95
143
* 按钮事件组
96
144
*/
169
217
<div class =" container" >
170
218
<h2 >Spring Boot Code Generator!</h2 >
171
219
<p class =" lead" >
172
- √基于SpringBoot2+Freemarker的代码生成器 ,√以释放双手为目的,√支持mysql/oracle/pgsql三大数据库,<br >
220
+ √基于SpringBoot2+Freemarker的< a class = " lead " href = " https://github.com/moshowgame/SpringBootCodeGenerator " >代码生成器</ a > ,√以释放双手为目的,√支持mysql/oracle/pgsql三大数据库,<br >
173
221
√用DDL-SQL语句生成JPA/JdbcTemplate/Mybatis/MybatisPlus/BeetlSQL相关代码。<br >
174
222
如果发现有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 >
175
223
</p >
219
267
<option value =" UnderScoreCase" >下划线</option >
220
268
<#-- <option value="UpperUnderScoreCase">大写下划线</option>-->
221
269
</select >
270
+ <div class =" input-group-prepend" >
271
+ <span class =" input-group-text" >swagger-ui</span >
272
+ </div >
273
+ <select type =" text" class =" form-control" id =" isSwagger"
274
+ name =" isSwagger" >
275
+ <option value =" false" >关闭</option >
276
+ <option value =" true" >开启</option >
277
+ </select >
222
278
</div >
223
279
<textarea id =" ddlSqlArea" placeholder =" 请输入表结构信息..." class =" form-control btn-lg" style =" height : 250px ;" >
224
280
CREATE TABLE 'userinfo' (
@@ -229,6 +285,7 @@ CREATE TABLE 'userinfo' (
229
285
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='用户信息'
230
286
</textarea ><br >
231
287
<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 >
288
+ <div id =" history" class =" btn-group" role =" group" aria-label =" Basic example" ></div >
232
289
<hr >
233
290
<!-- Example row of columns -->
234
291
<div class =" row" style =" margin-top : 10px ;" >
0 commit comments