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
577eb406
Commit
577eb406
authored
Jun 27, 2017
by
hewei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
配合测试用例的编写,更新日志打印方式,采用官方实现,优化warning日志打印位置到所有日志最后
parent
f8b2af30
Changes
11
Show whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
23 additions
and
21 deletions
+23
-21
src/main/java/com/itfsw/mybatis/generator/plugins/ExampleTargetPlugin.java
.../itfsw/mybatis/generator/plugins/ExampleTargetPlugin.java
+1
-1
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/LimitPlugin.java
...java/com/itfsw/mybatis/generator/plugins/LimitPlugin.java
+1
-1
src/main/java/com/itfsw/mybatis/generator/plugins/LogicalDeletePlugin.java
.../itfsw/mybatis/generator/plugins/LogicalDeletePlugin.java
+3
-3
src/main/java/com/itfsw/mybatis/generator/plugins/ModelBuilderPlugin.java
...m/itfsw/mybatis/generator/plugins/ModelBuilderPlugin.java
+1
-1
src/main/java/com/itfsw/mybatis/generator/plugins/SelectiveEnhancedPlugin.java
...sw/mybatis/generator/plugins/SelectiveEnhancedPlugin.java
+2
-2
src/main/java/com/itfsw/mybatis/generator/plugins/TablePrefixPlugin.java
...om/itfsw/mybatis/generator/plugins/TablePrefixPlugin.java
+1
-1
src/main/java/com/itfsw/mybatis/generator/plugins/TableRenamePlugin.java
...om/itfsw/mybatis/generator/plugins/TableRenamePlugin.java
+2
-2
src/main/java/com/itfsw/mybatis/generator/plugins/UpsertPlugin.java
...ava/com/itfsw/mybatis/generator/plugins/UpsertPlugin.java
+4
-4
src/main/java/com/itfsw/mybatis/generator/plugins/utils/IncrementsPluginTools.java
...ybatis/generator/plugins/utils/IncrementsPluginTools.java
+3
-2
src/main/java/com/itfsw/mybatis/generator/plugins/utils/PluginTools.java
...om/itfsw/mybatis/generator/plugins/utils/PluginTools.java
+3
-2
No files found.
src/main/java/com/itfsw/mybatis/generator/plugins/ExampleTargetPlugin.java
View file @
577eb406
...
...
@@ -47,7 +47,7 @@ public class ExampleTargetPlugin extends BasePlugin {
Properties
properties
=
getProperties
();
this
.
targetPackage
=
properties
.
getProperty
(
TARGET_PACKAGE_KEY
);
if
(
this
.
targetPackage
==
null
){
logger
.
error
(
"请配置com.itfsw.mybatis.generator.plugins.ExampleTargetPlugin插件的目标包名(targetPackage)!"
);
warnings
.
add
(
"请配置com.itfsw.mybatis.generator.plugins.ExampleTargetPlugin插件的目标包名(targetPackage)!"
);
return
false
;
}
return
super
.
validate
(
warnings
);
...
...
src/main/java/com/itfsw/mybatis/generator/plugins/IncrementsPlugin.java
View file @
577eb406
...
...
@@ -52,7 +52,7 @@ public class IncrementsPlugin extends BasePlugin {
// 插件使用前提是使用了ModelBuilderPlugin插件
if
(!
PluginTools
.
checkDependencyPlugin
(
getContext
(),
ModelBuilderPlugin
.
class
))
{
logger
.
error
(
"itfsw:插件"
+
this
.
getClass
().
getTypeName
()
+
"插件需配合com.itfsw.mybatis.generator.plugins.ModelBuilderPlugin插件使用!"
);
warnings
.
add
(
"itfsw:插件"
+
this
.
getClass
().
getTypeName
()
+
"插件需配合com.itfsw.mybatis.generator.plugins.ModelBuilderPlugin插件使用!"
);
return
false
;
}
...
...
@@ -65,7 +65,7 @@ public class IncrementsPlugin extends BasePlugin {
*/
@Override
public
void
initialized
(
IntrospectedTable
introspectedTable
)
{
this
.
incTools
=
IncrementsPluginTools
.
getTools
(
context
,
introspectedTable
);
this
.
incTools
=
IncrementsPluginTools
.
getTools
(
context
,
introspectedTable
,
warnings
);
}
/**
...
...
src/main/java/com/itfsw/mybatis/generator/plugins/LimitPlugin.java
View file @
577eb406
...
...
@@ -42,7 +42,7 @@ public class LimitPlugin extends BasePlugin {
public
boolean
validate
(
List
<
String
>
warnings
)
{
// 该插件只支持MYSQL
if
(
"com.mysql.jdbc.Driver"
.
equalsIgnoreCase
(
this
.
getContext
().
getJdbcConnectionConfiguration
().
getDriverClass
())
==
false
){
logger
.
error
(
"itfsw:插件"
+
this
.
getClass
().
getTypeName
()+
"只支持MySQL数据库!"
);
warnings
.
add
(
"itfsw:插件"
+
this
.
getClass
().
getTypeName
()+
"只支持MySQL数据库!"
);
return
false
;
}
return
super
.
validate
(
warnings
);
...
...
src/main/java/com/itfsw/mybatis/generator/plugins/LogicalDeletePlugin.java
View file @
577eb406
...
...
@@ -105,18 +105,18 @@ public class LogicalDeletePlugin extends BasePlugin {
||
JDBCType
.
VARCHAR
==
type
){
this
.
logicalDeleteColumn
=
column
;
}
else
{
logger
.
warn
(
"itfsw(逻辑删除插件):"
+
introspectedTable
.
getFullyQualifiedTable
()+
"逻辑删除列("
+
introspectedTable
.
getTableConfigurationProperty
(
LOGICAL_DELETE_COLUMN_KEY
)+
")的类型不在支持范围(请使用数字列,字符串列,布尔列)!"
);
warnings
.
add
(
"itfsw(逻辑删除插件):"
+
introspectedTable
.
getFullyQualifiedTable
()+
"逻辑删除列("
+
introspectedTable
.
getTableConfigurationProperty
(
LOGICAL_DELETE_COLUMN_KEY
)+
")的类型不在支持范围(请使用数字列,字符串列,布尔列)!"
);
}
}
}
if
(
introspectedTable
.
getTableConfigurationProperty
(
LOGICAL_DELETE_COLUMN_KEY
)
!=
null
&&
this
.
logicalDeleteColumn
==
null
){
logger
.
warn
(
"itfsw(逻辑删除插件):"
+
introspectedTable
.
getFullyQualifiedTable
()+
"没有找到您配置的逻辑删除列("
+
introspectedTable
.
getTableConfigurationProperty
(
LOGICAL_DELETE_COLUMN_KEY
)+
")!"
);
warnings
.
add
(
"itfsw(逻辑删除插件):"
+
introspectedTable
.
getFullyQualifiedTable
()+
"没有找到您配置的逻辑删除列("
+
introspectedTable
.
getTableConfigurationProperty
(
LOGICAL_DELETE_COLUMN_KEY
)+
")!"
);
}
// 4. 判断逻辑删除值是否配置了
if
(
this
.
logicalDeleteColumn
!=
null
&&
(
this
.
logicalDeleteValue
==
null
||
this
.
logicalUnDeleteValue
==
null
)){
logger
.
warn
(
"itfsw(逻辑删除插件):"
+
introspectedTable
.
getFullyQualifiedTable
()+
"没有找到您配置的逻辑删除值,请全局或者局部配置logicalDeleteValue和logicalUnDeleteValue值!"
);
warnings
.
add
(
"itfsw(逻辑删除插件):"
+
introspectedTable
.
getFullyQualifiedTable
()+
"没有找到您配置的逻辑删除值,请全局或者局部配置logicalDeleteValue和logicalUnDeleteValue值!"
);
}
}
...
...
src/main/java/com/itfsw/mybatis/generator/plugins/ModelBuilderPlugin.java
View file @
577eb406
...
...
@@ -131,7 +131,7 @@ public class ModelBuilderPlugin extends BasePlugin {
// ========================================== IncrementsPlugin =======================================
IncrementsPluginTools
incTools
=
IncrementsPluginTools
.
getTools
(
context
,
introspectedTable
);
IncrementsPluginTools
incTools
=
IncrementsPluginTools
.
getTools
(
context
,
introspectedTable
,
warnings
);
if
(
incTools
.
support
())
{
if
(
modelBaseRecord
)
{
// 增加枚举
...
...
src/main/java/com/itfsw/mybatis/generator/plugins/SelectiveEnhancedPlugin.java
View file @
577eb406
...
...
@@ -47,12 +47,12 @@ public class SelectiveEnhancedPlugin extends BasePlugin {
// 插件使用前提是使用了ModelColumnPlugin插件
if
(!
PluginTools
.
checkDependencyPlugin
(
getContext
(),
ModelColumnPlugin
.
class
))
{
logger
.
error
(
"itfsw:插件"
+
this
.
getClass
().
getTypeName
()
+
"插件需配合com.itfsw.mybatis.generator.plugins.ModelColumnPlugin插件使用!"
);
warnings
.
add
(
"itfsw:插件"
+
this
.
getClass
().
getTypeName
()
+
"插件需配合com.itfsw.mybatis.generator.plugins.ModelColumnPlugin插件使用!"
);
return
false
;
}
// 插件位置
PluginTools
.
shouldAfterPlugins
(
getContext
(),
this
.
getClass
(),
UpsertPlugin
.
class
);
PluginTools
.
shouldAfterPlugins
(
getContext
(),
this
.
getClass
(),
warnings
,
UpsertPlugin
.
class
);
return
super
.
validate
(
warnings
);
}
...
...
src/main/java/com/itfsw/mybatis/generator/plugins/TablePrefixPlugin.java
View file @
577eb406
...
...
@@ -44,7 +44,7 @@ public class TablePrefixPlugin extends BasePlugin {
// 如果table配置了domainObjectName或者mapperName就不要再启动该插件了
for
(
TableConfiguration
tableConfiguration
:
context
.
getTableConfigurations
())
{
if
(
tableConfiguration
.
getDomainObjectName
()
!=
null
||
tableConfiguration
.
getMapperName
()
!=
null
)
{
logger
.
error
(
"itfsw:插件"
+
this
.
getClass
().
getTypeName
()
+
"插件请不要配合table的domainObjectName或者mapperName一起使用!"
);
warnings
.
add
(
"itfsw:插件"
+
this
.
getClass
().
getTypeName
()
+
"插件请不要配合table的domainObjectName或者mapperName一起使用!"
);
return
false
;
}
}
...
...
src/main/java/com/itfsw/mybatis/generator/plugins/TableRenamePlugin.java
View file @
577eb406
...
...
@@ -48,14 +48,14 @@ public class TableRenamePlugin extends BasePlugin {
// 如果配置了searchString 或者 replaceString,二者不允许单独存在
if
((
getProperties
().
getProperty
(
PRE_SEARCH_STRING
)
==
null
&&
getProperties
().
getProperty
(
PRE_REPLACE_STRING
)
!=
null
)
||
(
getProperties
().
getProperty
(
PRE_SEARCH_STRING
)
!=
null
&&
getProperties
().
getProperty
(
PRE_REPLACE_STRING
)
==
null
))
{
logger
.
error
(
"itfsw:插件"
+
this
.
getClass
().
getTypeName
()
+
"插件的searchString、replaceString属性需配合使用,不能单独存在!"
);
warnings
.
add
(
"itfsw:插件"
+
this
.
getClass
().
getTypeName
()
+
"插件的searchString、replaceString属性需配合使用,不能单独存在!"
);
return
false
;
}
// 如果table配置了domainObjectName或者mapperName就不要再启动该插件了
for
(
TableConfiguration
tableConfiguration:
context
.
getTableConfigurations
())
{
if
(
tableConfiguration
.
getDomainObjectName
()
!=
null
||
tableConfiguration
.
getMapperName
()
!=
null
){
logger
.
error
(
"itfsw:插件"
+
this
.
getClass
().
getTypeName
()
+
"插件请不要配合table的domainObjectName或者mapperName一起使用!"
);
warnings
.
add
(
"itfsw:插件"
+
this
.
getClass
().
getTypeName
()
+
"插件请不要配合table的domainObjectName或者mapperName一起使用!"
);
return
false
;
}
}
...
...
src/main/java/com/itfsw/mybatis/generator/plugins/UpsertPlugin.java
View file @
577eb406
...
...
@@ -61,7 +61,7 @@ public class UpsertPlugin extends BasePlugin {
// 插件使用前提是数据库为MySQL
if
(
"com.mysql.jdbc.Driver"
.
equalsIgnoreCase
(
this
.
getContext
().
getJdbcConnectionConfiguration
().
getDriverClass
())
==
false
)
{
logger
.
error
(
"itfsw:插件"
+
this
.
getClass
().
getTypeName
()
+
"插件使用前提是数据库为MySQL!"
);
warnings
.
add
(
"itfsw:插件"
+
this
.
getClass
().
getTypeName
()
+
"插件使用前提是数据库为MySQL!"
);
return
false
;
}
...
...
@@ -71,7 +71,7 @@ public class UpsertPlugin extends BasePlugin {
this
.
allowMultiQueries
=
allowMultiQueries
==
null
?
false
:
StringUtility
.
isTrue
(
allowMultiQueries
);
if
(
this
.
allowMultiQueries
)
{
// 提示用户注意信息
logger
.
warn
(
"itfsw:插件"
+
this
.
getClass
().
getTypeName
()
+
"插件您开启了allowMultiQueries支持,注意在jdbc url 配置中增加“allowMultiQueries=true”支持(不怎么建议使用该功能,开启多sql提交会增加sql注入的风险,请确保你所有sql都使用MyBatis书写,请不要使用statement进行sql提交)!"
);
warnings
.
add
(
"itfsw:插件"
+
this
.
getClass
().
getTypeName
()
+
"插件您开启了allowMultiQueries支持,注意在jdbc url 配置中增加“allowMultiQueries=true”支持(不怎么建议使用该功能,开启多sql提交会增加sql注入的风险,请确保你所有sql都使用MyBatis书写,请不要使用statement进行sql提交)!"
);
}
return
super
.
validate
(
warnings
);
...
...
@@ -509,7 +509,7 @@ public class UpsertPlugin extends BasePlugin {
* @param hasPrefix
*/
private
void
incrementsSelectiveSupport
(
XmlElement
xmlElement
,
XmlElement
trimXmlElement
,
IntrospectedTable
introspectedTable
,
boolean
hasPrefix
)
{
IncrementsPluginTools
incTools
=
IncrementsPluginTools
.
getTools
(
context
,
introspectedTable
);
IncrementsPluginTools
incTools
=
IncrementsPluginTools
.
getTools
(
context
,
introspectedTable
,
warnings
);
if
(
incTools
.
support
())
{
List
<
Element
>
ifs
=
new
ArrayList
<>();
// 获取if节点
...
...
@@ -537,7 +537,7 @@ public class UpsertPlugin extends BasePlugin {
* @param hasPrefix
*/
private
void
incrementsSupport
(
XmlElement
xmlElement
,
List
<
TextElement
>
elements
,
IntrospectedTable
introspectedTable
,
boolean
hasPrefix
)
{
IncrementsPluginTools
incTools
=
IncrementsPluginTools
.
getTools
(
context
,
introspectedTable
);
IncrementsPluginTools
incTools
=
IncrementsPluginTools
.
getTools
(
context
,
introspectedTable
,
warnings
);
for
(
TextElement
element
:
elements
)
{
if
(
incTools
.
support
())
{
// 获取column
...
...
src/main/java/com/itfsw/mybatis/generator/plugins/utils/IncrementsPluginTools.java
View file @
577eb406
...
...
@@ -62,9 +62,10 @@ public class IncrementsPluginTools {
* 获取工具
* @param context
* @param introspectedTable
* @param warnings
* @return
*/
public
static
IncrementsPluginTools
getTools
(
Context
context
,
IntrospectedTable
introspectedTable
)
{
public
static
IncrementsPluginTools
getTools
(
Context
context
,
IntrospectedTable
introspectedTable
,
List
<
String
>
warnings
)
{
IncrementsPluginTools
tools
=
new
IncrementsPluginTools
(
context
,
introspectedTable
);
// 判断是否启用了插件
if
(
PluginTools
.
getPluginConfiguration
(
context
,
IncrementsPlugin
.
class
)
!=
null
)
{
...
...
@@ -75,7 +76,7 @@ public class IncrementsPluginTools {
for
(
String
incrementsColumnsStr
:
incrementsColumnsStrs
)
{
IntrospectedColumn
column
=
introspectedTable
.
getColumn
(
incrementsColumnsStr
.
trim
());
if
(
column
==
null
)
{
logger
.
warn
(
"itfsw:插件"
+
IncrementsPlugin
.
class
.
getTypeName
()
+
"插件没有找到column为"
+
incrementsColumnsStr
.
trim
()
+
"的字段!"
);
warnings
.
add
(
"itfsw:插件"
+
IncrementsPlugin
.
class
.
getTypeName
()
+
"插件没有找到column为"
+
incrementsColumnsStr
.
trim
()
+
"的字段!"
);
}
else
{
tools
.
columns
.
add
(
column
);
}
...
...
src/main/java/com/itfsw/mybatis/generator/plugins/utils/PluginTools.java
View file @
577eb406
...
...
@@ -104,16 +104,17 @@ public class PluginTools {
*
* @param context
* @param plugin
* @param warnings
* @param plugins
* @return
*/
public
static
boolean
shouldAfterPlugins
(
Context
context
,
Class
plugin
,
Class
...
plugins
){
public
static
boolean
shouldAfterPlugins
(
Context
context
,
Class
plugin
,
List
<
String
>
warnings
,
Class
...
plugins
){
int
index
=
getPluginIndex
(
context
,
plugin
);
if
(
plugins
!=
null
){
for
(
Class
cls
:
plugins
){
int
index1
=
getPluginIndex
(
context
,
cls
);
if
(
index1
!=
-
1
&&
index1
>=
index
){
logger
.
warn
(
"itfsw:插件"
+
plugin
.
getTypeName
()
+
"插件建议配置在插件"
+
cls
.
getTypeName
()+
"后面,否则某些功能可能得不到增强!"
);
warnings
.
add
(
"itfsw:插件"
+
plugin
.
getTypeName
()
+
"插件建议配置在插件"
+
cls
.
getTypeName
()+
"后面,否则某些功能可能得不到增强!"
);
return
false
;
}
}
...
...
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