mirror of
https://github.com/moshowgame/SpringBootCodeGenerator.git
synced 2026-03-22 07:28:25 +08:00
support deal with column type of xxx(x,x) and some special character in ''
This commit is contained in:
@@ -16,6 +16,7 @@ SpringBootCodeGenerator
|
|||||||
<tr><td>CSDN博客</td> <td>http://blog.csdn.net/moshowgame</td></tr>
|
<tr><td>CSDN博客</td> <td>http://blog.csdn.net/moshowgame</td></tr>
|
||||||
<tr><td></td> <td></td></tr>
|
<tr><td></td> <td></td></tr>
|
||||||
<tr><td>更新日期</td> <td>更新内容</td></tr>
|
<tr><td>更新日期</td> <td>更新内容</td></tr>
|
||||||
|
<tr><td>20181018<td>支持doublt(x,x)的类型,以及comment里面包含一些特殊字符的处理(感谢@tanwubo的反馈)。</td></tr>
|
||||||
<tr><td>20181010<td>CDN变更,修复CDN不稳定导致网页js报错问题。</td></tr>
|
<tr><td>20181010<td>CDN变更,修复CDN不稳定导致网页js报错问题。</td></tr>
|
||||||
<tr><td>20181003<td>新增element-ui/bootstrap生成。</td></tr>
|
<tr><td>20181003<td>新增element-ui/bootstrap生成。</td></tr>
|
||||||
<tr><td>20181002<td>修复公共CDN之Layer.js404问题,导致项目无法生成。</td></tr>
|
<tr><td>20181002<td>修复公共CDN之Layer.js404问题,导致项目无法生成。</td></tr>
|
||||||
|
|||||||
@@ -102,7 +102,7 @@ public class TableParseUtil {
|
|||||||
String fieldListTmp = tableSql.substring(tableSql.indexOf("(")+1, tableSql.lastIndexOf(")"));
|
String fieldListTmp = tableSql.substring(tableSql.indexOf("(")+1, tableSql.lastIndexOf(")"));
|
||||||
|
|
||||||
// 匹配 comment,替换备注里的小逗号, 防止不小心被当成切割符号切割
|
// 匹配 comment,替换备注里的小逗号, 防止不小心被当成切割符号切割
|
||||||
Matcher matcher = Pattern.compile("\\ comment `(.*?)\\`").matcher(fieldListTmp); // "\\{(.*?)\\}"
|
Matcher matcher = Pattern.compile("comment `(.*?)\\`").matcher(fieldListTmp); // "\\{(.*?)\\}"
|
||||||
while(matcher.find()){
|
while(matcher.find()){
|
||||||
|
|
||||||
String commentTmp = matcher.group();
|
String commentTmp = matcher.group();
|
||||||
@@ -114,8 +114,24 @@ public class TableParseUtil {
|
|||||||
fieldListTmp = fieldListTmp.replace(matcher.group(), commentTmpFinal);
|
fieldListTmp = fieldListTmp.replace(matcher.group(), commentTmpFinal);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
//2018-10-18 zhengkai 新增支持double(10, 2)等类型中有英文逗号的特殊情况
|
||||||
|
Matcher matcher2 = Pattern.compile("\\`(.*?)\\`").matcher(fieldListTmp); // "\\{(.*?)\\}"
|
||||||
|
while(matcher2.find()){
|
||||||
|
String commentTmp2 = matcher2.group();
|
||||||
|
if (commentTmp2.contains(",")) {
|
||||||
|
String commentTmpFinal = commentTmp2.replaceAll(",", ",").replaceAll("\\(", "(").replaceAll("\\)", ")");
|
||||||
|
fieldListTmp = fieldListTmp.replace(matcher2.group(), commentTmpFinal);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//2018-10-18 zhengkai 新增支持double(10, 2)等类型中有英文逗号的特殊情况
|
||||||
|
Matcher matcher3 = Pattern.compile("\\((.*?)\\)").matcher(fieldListTmp); // "\\{(.*?)\\}"
|
||||||
|
while(matcher3.find()){
|
||||||
|
String commentTmp3 = matcher3.group();
|
||||||
|
if (commentTmp3.contains(",")) {
|
||||||
|
String commentTmpFinal = commentTmp3.replaceAll(",", ",");
|
||||||
|
fieldListTmp = fieldListTmp.replace(matcher3.group(), commentTmpFinal);
|
||||||
|
}
|
||||||
|
}
|
||||||
String[] fieldLineList = fieldListTmp.split(",");
|
String[] fieldLineList = fieldListTmp.split(",");
|
||||||
if (fieldLineList.length > 0) {
|
if (fieldLineList.length > 0) {
|
||||||
int i=0;//i为了解决primary key关键字出现的地方,出现在前3行,一般和id有关
|
int i=0;//i为了解决primary key关键字出现的地方,出现在前3行,一般和id有关
|
||||||
@@ -175,7 +191,7 @@ public class TableParseUtil {
|
|||||||
}
|
}
|
||||||
//解决最后一句是评论,无主键且连着)的问题:album_id int(3) default '1' null comment '相册id:0 代表头像 1代表照片墙')
|
//解决最后一句是评论,无主键且连着)的问题:album_id int(3) default '1' null comment '相册id:0 代表头像 1代表照片墙')
|
||||||
if(commentTmp.contains(")")){
|
if(commentTmp.contains(")")){
|
||||||
commentTmp = commentTmp.substring(0, commentTmp.lastIndexOf(")"));
|
commentTmp = commentTmp.substring(0, commentTmp.lastIndexOf(")")+1);
|
||||||
}
|
}
|
||||||
fieldComment = commentTmp;
|
fieldComment = commentTmp;
|
||||||
}else if(tableSql.contains("comment on column")&&tableSql.contains("."+columnName+" is `")){
|
}else if(tableSql.contains("comment on column")&&tableSql.contains("."+columnName+" is `")){
|
||||||
|
|||||||
@@ -79,7 +79,7 @@ CREATE TABLE `userinfo` (
|
|||||||
<div class="btn-toolbar mb-3" role="toolbar" aria-label="Toolbar with button groups">
|
<div class="btn-toolbar mb-3" role="toolbar" aria-label="Toolbar with button groups">
|
||||||
<div class="input-group">
|
<div class="input-group">
|
||||||
<div class="input-group-prepend">
|
<div class="input-group-prepend">
|
||||||
<div class="input-group-text" id="btnGroupAddon">JPA</div>
|
<div class="input-group-text" id="btnGroupAddon">UI</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="btn-group mr-2" role="group" aria-label="First group">
|
<div class="btn-group mr-2" role="group" aria-label="First group">
|
||||||
|
|||||||
Reference in New Issue
Block a user