5959 });
6060 return o;
6161 };
62+ var historyCount= 0 ;
63+ // 初始化清除session
64+ if (window .sessionStorage ){
65+ // 修复当F5刷新的时候,session没有清空各个值,但是页面的button没了。
66+ sessionStorage .clear ();
67+ }
6268 /**
6369 * 生成代码
6470 */
7076 " authorName" : $ (" #authorName" ).val (),
7177 " dataType" : $ (" #dataType" ).val (),
7278 " tinyintTransType" : $ (" #tinyintTransType" ).val (),
73- " nameCaseType" : $ (" #nameCaseType" ).val ()
79+ " nameCaseType" : $ (" #nameCaseType" ).val (),
80+ " swagger" : $ (" #isSwagger" ).val ()
7481 };
7582 $ .ajax ({
7683 type: ' POST' ,
8188 success : function (data ) {
8289 if (data .code === 200 ) {
8390 codeData = data .data ;
84- genCodeArea .setValue (codeData .beetlentity );
91+ genCodeArea .setValue (codeData .entity );
8592 genCodeArea .setSize (' auto' , ' auto' );
8693 $ .toast (" √ 代码生成成功" );
94+ // 添加历史记录
95+ addHistory (codeData);
8796 } else {
8897 $ .toast (" × 代码生成失败 :" + data .msg );
8998 }
9099 }
91100 });
92101 return false ;
93102 });
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+
94142 /**
95143 * 按钮事件组
96144 */
169217 <div class =" container" >
170218 <h2 >Spring Boot Code Generator!</h2 >
171219 <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 >
173221 √用DDL-SQL语句生成JPA/JdbcTemplate/Mybatis/MybatisPlus/BeetlSQL相关代码。<br >
174222 如果发现有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 >
175223 </p >
219267 <option value =" UnderScoreCase" >下划线</option >
220268 <#-- <option value="UpperUnderScoreCase">大写下划线</option>-->
221269 </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 >
222278 </div >
223279 <textarea id =" ddlSqlArea" placeholder =" 请输入表结构信息..." class =" form-control btn-lg" style =" height : 250px ;" >
224280CREATE TABLE 'userinfo' (
@@ -229,6 +285,7 @@ CREATE TABLE 'userinfo' (
229285) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='用户信息'
230286 </textarea ><br >
231287 <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 >
232289 <hr >
233290 <!-- Example row of columns -->
234291 <div class =" row" style =" margin-top : 10px ;" >
0 commit comments