Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
mybatis-generator-plugin
Project overview
Project overview
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
mybatis-generator-plugin
Commits
e75e36af
Commit
e75e36af
authored
Aug 04, 2017
by
hewei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bugfix[issues#10]:修正在配置autoDelimitKeywords时,由于正则获取columnName异常问题
parent
54d68e59
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
7 deletions
+12
-7
src/main/java/com/itfsw/mybatis/generator/plugins/IncrementsPlugin.java
...com/itfsw/mybatis/generator/plugins/IncrementsPlugin.java
+2
-2
src/main/java/com/itfsw/mybatis/generator/plugins/SelectiveEnhancedPlugin.java
...sw/mybatis/generator/plugins/SelectiveEnhancedPlugin.java
+10
-5
No files found.
src/main/java/com/itfsw/mybatis/generator/plugins/IncrementsPlugin.java
View file @
e75e36af
...
...
@@ -206,9 +206,9 @@ public class IncrementsPlugin extends BasePlugin {
// 找到text节点且格式为 set xx = xx 或者 xx = xx
if
(
ele
instanceof
TextElement
)
{
String
text
=
((
TextElement
)
ele
).
getContent
().
trim
();
if
(
text
.
matches
(
"(set\\s)?\\S+\\s?=.*"
))
{
if
(
text
.
matches
(
"(
^
set\\s)?\\S+\\s?=.*"
))
{
// 清理 set 操作
text
=
text
.
replaceFirst
(
"set\\s"
,
""
).
trim
();
text
=
text
.
replaceFirst
(
"
^
set\\s"
,
""
).
trim
();
String
columnName
=
text
.
split
(
"="
)[
0
].
trim
();
IntrospectedColumn
introspectedColumn
=
IntrospectedTableTools
.
safeGetColumn
(
introspectedTable
,
columnName
);
// 查找判断是否需要进行节点替换
...
...
src/main/java/com/itfsw/mybatis/generator/plugins/SelectiveEnhancedPlugin.java
View file @
e75e36af
...
...
@@ -34,6 +34,7 @@ import java.util.regex.Pattern;
* ---------------------------------------------------------------------------
* Selective 增强插件
* ---------------------------------------------------------------------------
*
* @author: hewei
* @time:2017/4/20 15:39
* ---------------------------------------------------------------------------
...
...
@@ -61,6 +62,7 @@ public class SelectiveEnhancedPlugin extends BasePlugin {
/**
* Model Methods 生成
* 具体执行顺序 http://www.mybatis.org/generator/reference/pluggingIn.html
*
* @param topLevelClass
* @param introspectedTable
* @return
...
...
@@ -116,6 +118,7 @@ public class SelectiveEnhancedPlugin extends BasePlugin {
/**
* SQL Map Methods 生成
* 具体执行顺序 http://www.mybatis.org/generator/reference/pluggingIn.html
*
* @param document
* @param introspectedTable
* @return
...
...
@@ -182,6 +185,7 @@ public class SelectiveEnhancedPlugin extends BasePlugin {
/**
* 替换节点if信息
*
* @param element
* @param prefix
* @param introspectedTable
...
...
@@ -194,7 +198,7 @@ public class SelectiveEnhancedPlugin extends BasePlugin {
whenEle
.
addAttribute
(
new
Attribute
(
"test"
,
prefix
+
"isSelective()"
));
for
(
Element
ele
:
element
.
getElements
())
{
// 对于字符串主键,是没有if判断节点的
if
(
ele
instanceof
XmlElement
){
if
(
ele
instanceof
XmlElement
)
{
// if的text节点
XmlElement
xmlElement
=
(
XmlElement
)
ele
;
...
...
@@ -205,7 +209,7 @@ public class SelectiveEnhancedPlugin extends BasePlugin {
if
(
text
.
matches
(
"#\\{.*\\},?"
))
{
Pattern
pattern
=
Pattern
.
compile
(
"#\\{(.*?),.*\\},?"
);
Matcher
matcher
=
pattern
.
matcher
(
text
);
if
(
matcher
.
find
()){
if
(
matcher
.
find
())
{
String
field
=
matcher
.
group
(
1
);
// 查找对应column
for
(
IntrospectedColumn
column
:
introspectedTable
.
getAllColumns
())
{
...
...
@@ -215,7 +219,7 @@ public class SelectiveEnhancedPlugin extends BasePlugin {
}
}
}
else
{
if
(
text
.
matches
(
".*=.*"
)){
if
(
text
.
matches
(
".*=.*"
))
{
columnName
=
text
.
split
(
"="
)[
0
];
}
else
{
columnName
=
text
.
replaceAll
(
","
,
""
);
...
...
@@ -228,8 +232,8 @@ public class SelectiveEnhancedPlugin extends BasePlugin {
XmlElement
ifEle
=
new
XmlElement
(
"if"
);
ifEle
.
addAttribute
(
new
Attribute
(
"test"
,
prefix
+
"isSelective(\'"
+
MyBatis3FormattingUtilities
.
getEscapedColumnName
(
column
)
+
"\')"
));
for
(
Element
ifChild
:
xmlElement
.
getElements
()){
ifEle
.
addAttribute
(
new
Attribute
(
"test"
,
prefix
+
"isSelective(\'"
+
column
.
getActualColumnName
(
)
+
"\')"
));
for
(
Element
ifChild
:
xmlElement
.
getElements
())
{
ifEle
.
addElement
(
ifChild
);
}
whenEle
.
addElement
(
ifEle
);
...
...
@@ -254,6 +258,7 @@ public class SelectiveEnhancedPlugin extends BasePlugin {
/**
* 替换节点upsertByExampleSelective if信息
*
* @param element
* @param prefix
* @param introspectedTable
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment