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
cc429d06
Commit
cc429d06
authored
Jul 07, 2017
by
hewei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bugfix:类命名规范不应该使用官方驼峰命名规则方法,而应采用简单进行首字母大写就行;
parent
9167f9dc
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
6 deletions
+14
-6
src/main/java/com/itfsw/mybatis/generator/plugins/TableRenamePlugin.java
...om/itfsw/mybatis/generator/plugins/TableRenamePlugin.java
+14
-6
No files found.
src/main/java/com/itfsw/mybatis/generator/plugins/TableRenamePlugin.java
View file @
cc429d06
...
...
@@ -20,7 +20,6 @@ import com.itfsw.mybatis.generator.plugins.utils.BasePlugin;
import
com.itfsw.mybatis.generator.plugins.utils.IntrospectedTableTools
;
import
org.mybatis.generator.api.IntrospectedTable
;
import
org.mybatis.generator.config.TableConfiguration
;
import
org.mybatis.generator.internal.util.JavaBeansUtil
;
import
java.util.List
;
import
java.util.regex.Matcher
;
...
...
@@ -53,8 +52,8 @@ public class TableRenamePlugin extends BasePlugin {
}
// 如果table配置了domainObjectName或者mapperName就不要再启动该插件了
for
(
TableConfiguration
tableConfiguration:
context
.
getTableConfigurations
())
{
if
(
tableConfiguration
.
getDomainObjectName
()
!=
null
||
tableConfiguration
.
getMapperName
()
!=
null
){
for
(
TableConfiguration
tableConfiguration
:
context
.
getTableConfigurations
())
{
if
(
tableConfiguration
.
getDomainObjectName
()
!=
null
||
tableConfiguration
.
getMapperName
()
!=
null
)
{
warnings
.
add
(
"itfsw:插件"
+
this
.
getClass
().
getTypeName
()
+
"插件请不要配合table的domainObjectName或者mapperName一起使用!"
);
return
false
;
}
...
...
@@ -79,7 +78,7 @@ public class TableRenamePlugin extends BasePlugin {
}
catch
(
Exception
e
)
{
logger
.
error
(
"itfsw:插件"
+
this
.
getClass
().
getTypeName
()
+
"使用tableOverride替换时异常!"
,
e
);
}
}
else
if
(
getProperties
().
getProperty
(
PRE_SEARCH_STRING
)
!=
null
){
}
else
if
(
getProperties
().
getProperty
(
PRE_SEARCH_STRING
)
!=
null
)
{
String
searchString
=
getProperties
().
getProperty
(
PRE_SEARCH_STRING
);
String
replaceString
=
getProperties
().
getProperty
(
PRE_REPLACE_STRING
);
...
...
@@ -87,8 +86,8 @@ public class TableRenamePlugin extends BasePlugin {
Pattern
pattern
=
Pattern
.
compile
(
searchString
);
Matcher
matcher
=
pattern
.
matcher
(
domainObjectName
);
domainObjectName
=
matcher
.
replaceAll
(
replaceString
);
// 命名规范化
domainObjectName
=
JavaBeansUtil
.
getCamelCaseString
(
domainObjectName
,
tru
e
);
// 命名规范化
首字母大写
domainObjectName
=
upFirstWord
(
domainObjectNam
e
);
try
{
IntrospectedTableTools
.
setDomainObjectName
(
introspectedTable
,
getContext
(),
domainObjectName
);
}
catch
(
Exception
e
)
{
...
...
@@ -96,4 +95,13 @@ public class TableRenamePlugin extends BasePlugin {
}
}
}
/**
* 字符串首字母大写
* @param str
* @return
*/
private
String
upFirstWord
(
String
str
)
{
return
str
.
substring
(
0
,
1
).
toUpperCase
()
+
str
.
substring
(
1
);
}
}
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