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
bfbae5f3
Commit
bfbae5f3
authored
Apr 21, 2017
by
hewei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1. 代码精简;
2. 增加SelectiveEnhancedPlugin插件;
parent
1b151673
Changes
11
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
189 additions
and
37 deletions
+189
-37
src/main/java/com/itfsw/mybatis/generator/plugins/BatchInsertOldPlugin.java
...itfsw/mybatis/generator/plugins/BatchInsertOldPlugin.java
+2
-2
src/main/java/com/itfsw/mybatis/generator/plugins/BatchInsertPlugin.java
...om/itfsw/mybatis/generator/plugins/BatchInsertPlugin.java
+3
-3
src/main/java/com/itfsw/mybatis/generator/plugins/ExampleEnhancedPlugin.java
...tfsw/mybatis/generator/plugins/ExampleEnhancedPlugin.java
+5
-5
src/main/java/com/itfsw/mybatis/generator/plugins/LimitPlugin.java
...java/com/itfsw/mybatis/generator/plugins/LimitPlugin.java
+7
-7
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
+4
-4
src/main/java/com/itfsw/mybatis/generator/plugins/ModelColumnPlugin.java
...om/itfsw/mybatis/generator/plugins/ModelColumnPlugin.java
+5
-5
src/main/java/com/itfsw/mybatis/generator/plugins/SelectOneByExamplePlugin.java
...w/mybatis/generator/plugins/SelectOneByExamplePlugin.java
+1
-1
src/main/java/com/itfsw/mybatis/generator/plugins/SelectiveEnhancedPlugin.java
...sw/mybatis/generator/plugins/SelectiveEnhancedPlugin.java
+154
-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/CommentTools.java
...m/itfsw/mybatis/generator/plugins/utils/CommentTools.java
+1
-1
No files found.
src/main/java/com/itfsw/mybatis/generator/plugins/BatchInsertOldPlugin.java
View file @
bfbae5f3
...
@@ -125,7 +125,7 @@ public class BatchInsertOldPlugin extends PluginAdapter {
...
@@ -125,7 +125,7 @@ public class BatchInsertOldPlugin extends PluginAdapter {
FullyQualifiedJavaType
type1
=
new
FullyQualifiedJavaType
(
introspectedTable
.
getRules
().
calculateAllFieldsClass
().
getShortName
()+
"."
+
ModelColumnPlugin
.
ENUM_NAME
);
FullyQualifiedJavaType
type1
=
new
FullyQualifiedJavaType
(
introspectedTable
.
getRules
().
calculateAllFieldsClass
().
getShortName
()+
"."
+
ModelColumnPlugin
.
ENUM_NAME
);
method
.
addParameter
(
new
Parameter
(
type1
,
"insertColumns"
,
"@Param(\"insertColumns\")"
,
true
));
method
.
addParameter
(
new
Parameter
(
type1
,
"insertColumns"
,
"@Param(\"insertColumns\")"
,
true
));
// 添加方法说明
// 添加方法说明
CommentTools
.
add
General
MethodComment
(
method
,
introspectedTable
);
CommentTools
.
addMethodComment
(
method
,
introspectedTable
);
// interface 增加方法
// interface 增加方法
interfaze
.
addMethod
(
method
);
interfaze
.
addMethod
(
method
);
...
@@ -142,7 +142,7 @@ public class BatchInsertOldPlugin extends PluginAdapter {
...
@@ -142,7 +142,7 @@ public class BatchInsertOldPlugin extends PluginAdapter {
type
.
addTypeArgument
(
introspectedTable
.
getRules
().
calculateAllFieldsClass
());
type
.
addTypeArgument
(
introspectedTable
.
getRules
().
calculateAllFieldsClass
());
method
.
addParameter
(
new
Parameter
(
type
,
"list"
,
"@Param(\"list\")"
));
method
.
addParameter
(
new
Parameter
(
type
,
"list"
,
"@Param(\"list\")"
));
// 添加方法说明
// 添加方法说明
CommentTools
.
add
General
MethodComment
(
method
,
introspectedTable
);
CommentTools
.
addMethodComment
(
method
,
introspectedTable
);
// interface 增加方法
// interface 增加方法
interfaze
.
addMethod
(
method
);
interfaze
.
addMethod
(
method
);
...
...
src/main/java/com/itfsw/mybatis/generator/plugins/BatchInsertPlugin.java
View file @
bfbae5f3
...
@@ -69,7 +69,7 @@ public class BatchInsertPlugin extends PluginAdapter {
...
@@ -69,7 +69,7 @@ public class BatchInsertPlugin extends PluginAdapter {
// 插件使用前提是使用了ModelColumnPlugin插件
// 插件使用前提是使用了ModelColumnPlugin插件
if
(!
PluginTools
.
checkDependencyPlugin
(
ModelColumnPlugin
.
class
,
null
))
{
if
(!
PluginTools
.
checkDependencyPlugin
(
ModelColumnPlugin
.
class
,
getContext
()
))
{
logger
.
warn
(
"itfsw:插件"
+
this
.
getClass
().
getTypeName
()
+
"插件需配合com.itfsw.mybatis.generator.plugins.ModelColumnPlugin插件使用!"
);
logger
.
warn
(
"itfsw:插件"
+
this
.
getClass
().
getTypeName
()
+
"插件需配合com.itfsw.mybatis.generator.plugins.ModelColumnPlugin插件使用!"
);
return
false
;
return
false
;
}
}
...
@@ -101,7 +101,7 @@ public class BatchInsertPlugin extends PluginAdapter {
...
@@ -101,7 +101,7 @@ public class BatchInsertPlugin extends PluginAdapter {
tList
.
addTypeArgument
(
introspectedTable
.
getRules
().
calculateAllFieldsClass
());
tList
.
addTypeArgument
(
introspectedTable
.
getRules
().
calculateAllFieldsClass
());
mBatchInsert
.
addParameter
(
new
Parameter
(
tList
,
"list"
,
"@Param(\"list\")"
));
mBatchInsert
.
addParameter
(
new
Parameter
(
tList
,
"list"
,
"@Param(\"list\")"
));
// 添加方法说明
// 添加方法说明
CommentTools
.
add
General
MethodComment
(
mBatchInsert
,
introspectedTable
);
CommentTools
.
addMethodComment
(
mBatchInsert
,
introspectedTable
);
// interface 增加方法
// interface 增加方法
interfaze
.
addMethod
(
mBatchInsert
);
interfaze
.
addMethod
(
mBatchInsert
);
logger
.
debug
(
"itfsw(批量插入插件):"
+
interfaze
.
getType
().
getShortName
()
+
"增加batchInsert方法。"
);
logger
.
debug
(
"itfsw(批量插入插件):"
+
interfaze
.
getType
().
getShortName
()
+
"增加batchInsert方法。"
);
...
@@ -114,7 +114,7 @@ public class BatchInsertPlugin extends PluginAdapter {
...
@@ -114,7 +114,7 @@ public class BatchInsertPlugin extends PluginAdapter {
mBatchInsertSelective
.
addParameter
(
new
Parameter
(
tList
,
"list"
,
"@Param(\"list\")"
));
mBatchInsertSelective
.
addParameter
(
new
Parameter
(
tList
,
"list"
,
"@Param(\"list\")"
));
mBatchInsertSelective
.
addParameter
(
new
Parameter
(
tSelective
,
"selective"
,
"@Param(\"selective\")"
,
true
));
mBatchInsertSelective
.
addParameter
(
new
Parameter
(
tSelective
,
"selective"
,
"@Param(\"selective\")"
,
true
));
// 添加方法说明
// 添加方法说明
CommentTools
.
add
General
MethodComment
(
mBatchInsertSelective
,
introspectedTable
);
CommentTools
.
addMethodComment
(
mBatchInsertSelective
,
introspectedTable
);
// interface 增加方法
// interface 增加方法
interfaze
.
addMethod
(
mBatchInsertSelective
);
interfaze
.
addMethod
(
mBatchInsertSelective
);
logger
.
debug
(
"itfsw(批量插入插件):"
+
interfaze
.
getType
().
getShortName
()
+
"增加batchInsertSelective方法。"
);
logger
.
debug
(
"itfsw(批量插入插件):"
+
interfaze
.
getType
().
getShortName
()
+
"增加batchInsertSelective方法。"
);
...
...
src/main/java/com/itfsw/mybatis/generator/plugins/ExampleEnhancedPlugin.java
View file @
bfbae5f3
...
@@ -96,7 +96,7 @@ public class ExampleEnhancedPlugin extends PluginAdapter {
...
@@ -96,7 +96,7 @@ public class ExampleEnhancedPlugin extends PluginAdapter {
method
.
setVisibility
(
JavaVisibility
.
PUBLIC
);
method
.
setVisibility
(
JavaVisibility
.
PUBLIC
);
method
.
setReturnType
(
topLevelClass
.
getType
());
method
.
setReturnType
(
topLevelClass
.
getType
());
method
.
addBodyLine
(
"return this.example;"
);
method
.
addBodyLine
(
"return this.example;"
);
CommentTools
.
add
General
MethodComment
(
method
,
introspectedTable
);
CommentTools
.
addMethodComment
(
method
,
introspectedTable
);
innerClass
.
addMethod
(
method
);
innerClass
.
addMethod
(
method
);
logger
.
debug
(
"itfsw(Example增强插件):"
+
topLevelClass
.
getType
().
getShortName
()+
"."
+
innerClass
.
getType
().
getShortName
()+
"增加工厂方法example"
);
logger
.
debug
(
"itfsw(Example增强插件):"
+
topLevelClass
.
getType
().
getShortName
()+
"."
+
innerClass
.
getType
().
getShortName
()+
"增加工厂方法example"
);
}
}
...
@@ -120,7 +120,7 @@ public class ExampleEnhancedPlugin extends PluginAdapter {
...
@@ -120,7 +120,7 @@ public class ExampleEnhancedPlugin extends PluginAdapter {
Method
addMethod
=
new
Method
(
"add"
);
Method
addMethod
=
new
Method
(
"add"
);
addMethod
.
setReturnType
(
innerClass
.
getType
());
addMethod
.
setReturnType
(
innerClass
.
getType
());
addMethod
.
addParameter
(
new
Parameter
(
innerClass
.
getType
(),
"add"
));
addMethod
.
addParameter
(
new
Parameter
(
innerClass
.
getType
(),
"add"
));
CommentTools
.
add
General
MethodComment
(
addMethod
,
introspectedTable
);
CommentTools
.
addMethodComment
(
addMethod
,
introspectedTable
);
criteriaAddInterface
.
addMethod
(
addMethod
);
criteriaAddInterface
.
addMethod
(
addMethod
);
logger
.
debug
(
"itfsw(Example增强插件):"
+
topLevelClass
.
getType
().
getShortName
()+
"."
+
innerClass
.
getType
().
getShortName
()+
"."
+
criteriaAddInterface
.
getType
().
getShortName
()+
"增加方法add"
);
logger
.
debug
(
"itfsw(Example增强插件):"
+
topLevelClass
.
getType
().
getShortName
()+
"."
+
innerClass
.
getType
().
getShortName
()+
"."
+
criteriaAddInterface
.
getType
().
getShortName
()+
"增加方法add"
);
...
@@ -138,7 +138,7 @@ public class ExampleEnhancedPlugin extends PluginAdapter {
...
@@ -138,7 +138,7 @@ public class ExampleEnhancedPlugin extends PluginAdapter {
method
.
addBodyLine
(
"add.add(this);"
);
method
.
addBodyLine
(
"add.add(this);"
);
method
.
addBodyLine
(
"}"
);
method
.
addBodyLine
(
"}"
);
method
.
addBodyLine
(
"return this;"
);
method
.
addBodyLine
(
"return this;"
);
CommentTools
.
add
General
MethodComment
(
method
,
introspectedTable
);
CommentTools
.
addMethodComment
(
method
,
introspectedTable
);
innerClass
.
addMethod
(
method
);
innerClass
.
addMethod
(
method
);
logger
.
debug
(
"itfsw(Example增强插件):"
+
topLevelClass
.
getType
().
getShortName
()+
"."
+
innerClass
.
getType
().
getShortName
()+
"增加方法andIf"
);
logger
.
debug
(
"itfsw(Example增强插件):"
+
topLevelClass
.
getType
().
getShortName
()+
"."
+
innerClass
.
getType
().
getShortName
()+
"增加方法andIf"
);
}
}
...
@@ -159,7 +159,7 @@ public class ExampleEnhancedPlugin extends PluginAdapter {
...
@@ -159,7 +159,7 @@ public class ExampleEnhancedPlugin extends PluginAdapter {
method
.
addBodyLine
(
"this.setOrderByClause(orderByClause);"
);
method
.
addBodyLine
(
"this.setOrderByClause(orderByClause);"
);
method
.
addBodyLine
(
"return this;"
);
method
.
addBodyLine
(
"return this;"
);
CommentTools
.
add
General
MethodComment
(
method
,
introspectedTable
);
CommentTools
.
addMethodComment
(
method
,
introspectedTable
);
topLevelClass
.
addMethod
(
method
);
topLevelClass
.
addMethod
(
method
);
logger
.
debug
(
"itfsw(Example增强插件):"
+
topLevelClass
.
getType
().
getShortName
()+
"增加方法orderBy"
);
logger
.
debug
(
"itfsw(Example增强插件):"
+
topLevelClass
.
getType
().
getShortName
()+
"增加方法orderBy"
);
...
@@ -179,7 +179,7 @@ public class ExampleEnhancedPlugin extends PluginAdapter {
...
@@ -179,7 +179,7 @@ public class ExampleEnhancedPlugin extends PluginAdapter {
mOrderByMore
.
addBodyLine
(
"this.setOrderByClause(sb.toString());"
);
mOrderByMore
.
addBodyLine
(
"this.setOrderByClause(sb.toString());"
);
mOrderByMore
.
addBodyLine
(
"return this;"
);
mOrderByMore
.
addBodyLine
(
"return this;"
);
CommentTools
.
add
General
MethodComment
(
mOrderByMore
,
introspectedTable
);
CommentTools
.
addMethodComment
(
mOrderByMore
,
introspectedTable
);
topLevelClass
.
addMethod
(
mOrderByMore
);
topLevelClass
.
addMethod
(
mOrderByMore
);
logger
.
debug
(
"itfsw(Example增强插件):"
+
topLevelClass
.
getType
().
getShortName
()+
"增加方法orderBy(String ... orderByClauses)"
);
logger
.
debug
(
"itfsw(Example增强插件):"
+
topLevelClass
.
getType
().
getShortName
()+
"增加方法orderBy(String ... orderByClauses)"
);
}
}
...
...
src/main/java/com/itfsw/mybatis/generator/plugins/LimitPlugin.java
View file @
bfbae5f3
...
@@ -90,7 +90,7 @@ public class LimitPlugin extends PluginAdapter {
...
@@ -90,7 +90,7 @@ public class LimitPlugin extends PluginAdapter {
setOffset
.
setName
(
"setOffset"
);
setOffset
.
setName
(
"setOffset"
);
setOffset
.
addParameter
(
new
Parameter
(
integerWrapper
,
"offset"
));
setOffset
.
addParameter
(
new
Parameter
(
integerWrapper
,
"offset"
));
setOffset
.
addBodyLine
(
"this.offset = offset;"
);
setOffset
.
addBodyLine
(
"this.offset = offset;"
);
CommentTools
.
add
General
MethodComment
(
setOffset
,
introspectedTable
);
CommentTools
.
addMethodComment
(
setOffset
,
introspectedTable
);
topLevelClass
.
addMethod
(
setOffset
);
topLevelClass
.
addMethod
(
setOffset
);
Method
getOffset
=
new
Method
();
Method
getOffset
=
new
Method
();
...
@@ -98,7 +98,7 @@ public class LimitPlugin extends PluginAdapter {
...
@@ -98,7 +98,7 @@ public class LimitPlugin extends PluginAdapter {
getOffset
.
setReturnType
(
integerWrapper
);
getOffset
.
setReturnType
(
integerWrapper
);
getOffset
.
setName
(
"getOffset"
);
getOffset
.
setName
(
"getOffset"
);
getOffset
.
addBodyLine
(
"return offset;"
);
getOffset
.
addBodyLine
(
"return offset;"
);
CommentTools
.
add
General
MethodComment
(
getOffset
,
introspectedTable
);
CommentTools
.
addMethodComment
(
getOffset
,
introspectedTable
);
topLevelClass
.
addMethod
(
getOffset
);
topLevelClass
.
addMethod
(
getOffset
);
Method
setRows
=
new
Method
();
Method
setRows
=
new
Method
();
...
@@ -106,7 +106,7 @@ public class LimitPlugin extends PluginAdapter {
...
@@ -106,7 +106,7 @@ public class LimitPlugin extends PluginAdapter {
setRows
.
setName
(
"setRows"
);
setRows
.
setName
(
"setRows"
);
setRows
.
addParameter
(
new
Parameter
(
integerWrapper
,
"rows"
));
setRows
.
addParameter
(
new
Parameter
(
integerWrapper
,
"rows"
));
setRows
.
addBodyLine
(
"this.rows = rows;"
);
setRows
.
addBodyLine
(
"this.rows = rows;"
);
CommentTools
.
add
General
MethodComment
(
setRows
,
introspectedTable
);
CommentTools
.
addMethodComment
(
setRows
,
introspectedTable
);
topLevelClass
.
addMethod
(
setRows
);
topLevelClass
.
addMethod
(
setRows
);
Method
getRows
=
new
Method
();
Method
getRows
=
new
Method
();
...
@@ -114,7 +114,7 @@ public class LimitPlugin extends PluginAdapter {
...
@@ -114,7 +114,7 @@ public class LimitPlugin extends PluginAdapter {
getRows
.
setReturnType
(
integerWrapper
);
getRows
.
setReturnType
(
integerWrapper
);
getRows
.
setName
(
"getRows"
);
getRows
.
setName
(
"getRows"
);
getRows
.
addBodyLine
(
"return rows;"
);
getRows
.
addBodyLine
(
"return rows;"
);
CommentTools
.
add
General
MethodComment
(
getRows
,
introspectedTable
);
CommentTools
.
addMethodComment
(
getRows
,
introspectedTable
);
topLevelClass
.
addMethod
(
getRows
);
topLevelClass
.
addMethod
(
getRows
);
logger
.
debug
(
"itfsw(MySQL分页插件):"
+
topLevelClass
.
getType
().
getShortName
()+
"增加offset和rows的getter和setter实现。"
);
logger
.
debug
(
"itfsw(MySQL分页插件):"
+
topLevelClass
.
getType
().
getShortName
()+
"增加offset和rows的getter和setter实现。"
);
...
@@ -126,7 +126,7 @@ public class LimitPlugin extends PluginAdapter {
...
@@ -126,7 +126,7 @@ public class LimitPlugin extends PluginAdapter {
setLimit
.
addParameter
(
new
Parameter
(
integerWrapper
,
"rows"
));
setLimit
.
addParameter
(
new
Parameter
(
integerWrapper
,
"rows"
));
setLimit
.
addBodyLine
(
"this.rows = rows;"
);
setLimit
.
addBodyLine
(
"this.rows = rows;"
);
setLimit
.
addBodyLine
(
"return this;"
);
setLimit
.
addBodyLine
(
"return this;"
);
CommentTools
.
add
General
MethodComment
(
setLimit
,
introspectedTable
);
CommentTools
.
addMethodComment
(
setLimit
,
introspectedTable
);
topLevelClass
.
addMethod
(
setLimit
);
topLevelClass
.
addMethod
(
setLimit
);
Method
setLimit2
=
new
Method
();
Method
setLimit2
=
new
Method
();
...
@@ -138,7 +138,7 @@ public class LimitPlugin extends PluginAdapter {
...
@@ -138,7 +138,7 @@ public class LimitPlugin extends PluginAdapter {
setLimit2
.
addBodyLine
(
"this.offset = offset;"
);
setLimit2
.
addBodyLine
(
"this.offset = offset;"
);
setLimit2
.
addBodyLine
(
"this.rows = rows;"
);
setLimit2
.
addBodyLine
(
"this.rows = rows;"
);
setLimit2
.
addBodyLine
(
"return this;"
);
setLimit2
.
addBodyLine
(
"return this;"
);
CommentTools
.
add
General
MethodComment
(
setLimit2
,
introspectedTable
);
CommentTools
.
addMethodComment
(
setLimit2
,
introspectedTable
);
topLevelClass
.
addMethod
(
setLimit2
);
topLevelClass
.
addMethod
(
setLimit2
);
logger
.
debug
(
"itfsw(MySQL分页插件):"
+
topLevelClass
.
getType
().
getShortName
()+
"增加limit方法。"
);
logger
.
debug
(
"itfsw(MySQL分页插件):"
+
topLevelClass
.
getType
().
getShortName
()+
"增加limit方法。"
);
...
@@ -151,7 +151,7 @@ public class LimitPlugin extends PluginAdapter {
...
@@ -151,7 +151,7 @@ public class LimitPlugin extends PluginAdapter {
setPage
.
addBodyLine
(
"this.offset = page * pageSize;"
);
setPage
.
addBodyLine
(
"this.offset = page * pageSize;"
);
setPage
.
addBodyLine
(
"this.rows = pageSize;"
);
setPage
.
addBodyLine
(
"this.rows = pageSize;"
);
setPage
.
addBodyLine
(
"return this;"
);
setPage
.
addBodyLine
(
"return this;"
);
CommentTools
.
add
General
MethodComment
(
setPage
,
introspectedTable
);
CommentTools
.
addMethodComment
(
setPage
,
introspectedTable
);
topLevelClass
.
addMethod
(
setPage
);
topLevelClass
.
addMethod
(
setPage
);
logger
.
debug
(
"itfsw(MySQL分页插件):"
+
topLevelClass
.
getType
().
getShortName
()+
"增加page方法"
);
logger
.
debug
(
"itfsw(MySQL分页插件):"
+
topLevelClass
.
getType
().
getShortName
()+
"增加page方法"
);
...
...
src/main/java/com/itfsw/mybatis/generator/plugins/LogicalDeletePlugin.java
View file @
bfbae5f3
...
@@ -146,7 +146,7 @@ public class LogicalDeletePlugin extends PluginAdapter {
...
@@ -146,7 +146,7 @@ public class LogicalDeletePlugin extends PluginAdapter {
FullyQualifiedJavaType
type
=
new
FullyQualifiedJavaType
(
introspectedTable
.
getExampleType
());
FullyQualifiedJavaType
type
=
new
FullyQualifiedJavaType
(
introspectedTable
.
getExampleType
());
mLogicalDeleteByExample
.
addParameter
(
new
Parameter
(
type
,
"example"
));
mLogicalDeleteByExample
.
addParameter
(
new
Parameter
(
type
,
"example"
));
// 添加方法说明
// 添加方法说明
CommentTools
.
add
General
MethodComment
(
mLogicalDeleteByExample
,
introspectedTable
);
CommentTools
.
addMethodComment
(
mLogicalDeleteByExample
,
introspectedTable
);
// interface 增加方法
// interface 增加方法
interfaze
.
addMethod
(
mLogicalDeleteByExample
);
interfaze
.
addMethod
(
mLogicalDeleteByExample
);
logger
.
debug
(
"itfsw(逻辑删除插件):"
+
interfaze
.
getType
().
getShortName
()+
"增加方法logicalDeleteByExample。"
);
logger
.
debug
(
"itfsw(逻辑删除插件):"
+
interfaze
.
getType
().
getShortName
()+
"增加方法logicalDeleteByExample。"
);
...
@@ -191,7 +191,7 @@ public class LogicalDeletePlugin extends PluginAdapter {
...
@@ -191,7 +191,7 @@ public class LogicalDeletePlugin extends PluginAdapter {
}
}
// 添加方法说明
// 添加方法说明
CommentTools
.
add
General
MethodComment
(
mLogicalDeleteByPrimaryKey
,
introspectedTable
);
CommentTools
.
addMethodComment
(
mLogicalDeleteByPrimaryKey
,
introspectedTable
);
// interface 增加方法
// interface 增加方法
interfaze
.
addImportedTypes
(
importedTypes
);
interfaze
.
addImportedTypes
(
importedTypes
);
interfaze
.
addMethod
(
mLogicalDeleteByPrimaryKey
);
interfaze
.
addMethod
(
mLogicalDeleteByPrimaryKey
);
...
@@ -375,7 +375,7 @@ public class LogicalDeletePlugin extends PluginAdapter {
...
@@ -375,7 +375,7 @@ public class LogicalDeletePlugin extends PluginAdapter {
if
(
"Criteria"
.
equals
(
innerClass
.
getType
().
getShortName
()))
{
if
(
"Criteria"
.
equals
(
innerClass
.
getType
().
getShortName
()))
{
// 增加逻辑删除条件
// 增加逻辑删除条件
Method
method
=
new
Method
(
METHOD_LOGICAL_DELETE
);
Method
method
=
new
Method
(
METHOD_LOGICAL_DELETE
);
CommentTools
.
add
General
MethodComment
(
method
,
introspectedTable
);
CommentTools
.
addMethodComment
(
method
,
introspectedTable
);
method
.
setVisibility
(
JavaVisibility
.
PUBLIC
);
method
.
setVisibility
(
JavaVisibility
.
PUBLIC
);
method
.
setReturnType
(
innerClass
.
getType
());
method
.
setReturnType
(
innerClass
.
getType
());
method
.
addParameter
(
new
Parameter
(
FullyQualifiedJavaType
.
getBooleanPrimitiveInstance
(),
"deleted"
));
method
.
addParameter
(
new
Parameter
(
FullyQualifiedJavaType
.
getBooleanPrimitiveInstance
(),
"deleted"
));
...
...
src/main/java/com/itfsw/mybatis/generator/plugins/ModelBuilderPlugin.java
View file @
bfbae5f3
...
@@ -83,7 +83,7 @@ public class ModelBuilderPlugin extends PluginAdapter {
...
@@ -83,7 +83,7 @@ public class ModelBuilderPlugin extends PluginAdapter {
constructor
.
setVisibility
(
JavaVisibility
.
PUBLIC
);
constructor
.
setVisibility
(
JavaVisibility
.
PUBLIC
);
constructor
.
setConstructor
(
true
);
constructor
.
setConstructor
(
true
);
constructor
.
addBodyLine
(
new
StringBuilder
(
"this.obj = new "
).
append
(
topLevelClass
.
getType
().
getShortName
()).
append
(
"();"
).
toString
());
constructor
.
addBodyLine
(
new
StringBuilder
(
"this.obj = new "
).
append
(
topLevelClass
.
getType
().
getShortName
()).
append
(
"();"
).
toString
());
CommentTools
.
add
General
MethodComment
(
constructor
,
introspectedTable
);
CommentTools
.
addMethodComment
(
constructor
,
introspectedTable
);
innerClass
.
addMethod
(
constructor
);
innerClass
.
addMethod
(
constructor
);
logger
.
debug
(
"itfsw(数据Model链式构建插件):"
+
topLevelClass
.
getType
().
getShortName
()+
".Builder增加的构造方法。"
);
logger
.
debug
(
"itfsw(数据Model链式构建插件):"
+
topLevelClass
.
getType
().
getShortName
()+
".Builder增加的构造方法。"
);
...
@@ -100,7 +100,7 @@ public class ModelBuilderPlugin extends PluginAdapter {
...
@@ -100,7 +100,7 @@ public class ModelBuilderPlugin extends PluginAdapter {
method
.
addBodyLine
(
new
StringBuilder
().
append
(
"obj."
).
append
(
setterMethod
.
getName
())
method
.
addBodyLine
(
new
StringBuilder
().
append
(
"obj."
).
append
(
setterMethod
.
getName
())
.
append
(
"("
).
append
(
field
.
getName
()).
append
(
");"
).
toString
());
.
append
(
"("
).
append
(
field
.
getName
()).
append
(
");"
).
toString
());
method
.
addBodyLine
(
new
StringBuilder
().
append
(
"return this;"
).
toString
());
method
.
addBodyLine
(
new
StringBuilder
().
append
(
"return this;"
).
toString
());
CommentTools
.
add
General
MethodComment
(
method
,
introspectedTable
);
CommentTools
.
addMethodComment
(
method
,
introspectedTable
);
innerClass
.
addMethod
(
method
);
innerClass
.
addMethod
(
method
);
logger
.
debug
(
"itfsw(数据Model链式构建插件):"
+
topLevelClass
.
getType
().
getShortName
()+
".Builder增加"
+
method
.
getName
()+
"方法(复合主键)。"
);
logger
.
debug
(
"itfsw(数据Model链式构建插件):"
+
topLevelClass
.
getType
().
getShortName
()+
".Builder增加"
+
method
.
getName
()+
"方法(复合主键)。"
);
}
}
...
@@ -118,7 +118,7 @@ public class ModelBuilderPlugin extends PluginAdapter {
...
@@ -118,7 +118,7 @@ public class ModelBuilderPlugin extends PluginAdapter {
method
.
addBodyLine
(
new
StringBuilder
().
append
(
"obj."
).
append
(
field
.
getName
())
method
.
addBodyLine
(
new
StringBuilder
().
append
(
"obj."
).
append
(
field
.
getName
())
.
append
(
" = "
).
append
(
field
.
getName
()).
append
(
";"
).
toString
());
.
append
(
" = "
).
append
(
field
.
getName
()).
append
(
";"
).
toString
());
method
.
addBodyLine
(
new
StringBuilder
().
append
(
"return this;"
).
toString
());
method
.
addBodyLine
(
new
StringBuilder
().
append
(
"return this;"
).
toString
());
CommentTools
.
add
General
MethodComment
(
method
,
introspectedTable
);
CommentTools
.
addMethodComment
(
method
,
introspectedTable
);
innerClass
.
addMethod
(
method
);
innerClass
.
addMethod
(
method
);
logger
.
debug
(
"itfsw(数据Model链式构建插件):"
+
topLevelClass
.
getType
().
getShortName
()+
".Builder增加"
+
method
.
getName
()+
"方法。"
);
logger
.
debug
(
"itfsw(数据Model链式构建插件):"
+
topLevelClass
.
getType
().
getShortName
()+
".Builder增加"
+
method
.
getName
()+
"方法。"
);
}
}
...
@@ -127,7 +127,7 @@ public class ModelBuilderPlugin extends PluginAdapter {
...
@@ -127,7 +127,7 @@ public class ModelBuilderPlugin extends PluginAdapter {
build
.
setReturnType
(
topLevelClass
.
getType
());
build
.
setReturnType
(
topLevelClass
.
getType
());
build
.
setVisibility
(
JavaVisibility
.
PUBLIC
);
build
.
setVisibility
(
JavaVisibility
.
PUBLIC
);
build
.
addBodyLine
(
"return this.obj;"
);
build
.
addBodyLine
(
"return this.obj;"
);
CommentTools
.
add
General
MethodComment
(
build
,
introspectedTable
);
CommentTools
.
addMethodComment
(
build
,
introspectedTable
);
innerClass
.
addMethod
(
build
);
innerClass
.
addMethod
(
build
);
logger
.
debug
(
"itfsw(数据Model链式构建插件):"
+
topLevelClass
.
getType
().
getShortName
()+
".Builder增加build方法。"
);
logger
.
debug
(
"itfsw(数据Model链式构建插件):"
+
topLevelClass
.
getType
().
getShortName
()+
".Builder增加build方法。"
);
...
...
src/main/java/com/itfsw/mybatis/generator/plugins/ModelColumnPlugin.java
View file @
bfbae5f3
...
@@ -82,21 +82,21 @@ public class ModelColumnPlugin extends PluginAdapter {
...
@@ -82,21 +82,21 @@ public class ModelColumnPlugin extends PluginAdapter {
mValue
.
setVisibility
(
JavaVisibility
.
PUBLIC
);
mValue
.
setVisibility
(
JavaVisibility
.
PUBLIC
);
mValue
.
setReturnType
(
FullyQualifiedJavaType
.
getStringInstance
());
mValue
.
setReturnType
(
FullyQualifiedJavaType
.
getStringInstance
());
mValue
.
addBodyLine
(
"return this.column;"
);
mValue
.
addBodyLine
(
"return this.column;"
);
CommentTools
.
add
General
MethodComment
(
mValue
,
introspectedTable
);
CommentTools
.
addMethodComment
(
mValue
,
introspectedTable
);
innerEnum
.
addMethod
(
mValue
);
innerEnum
.
addMethod
(
mValue
);
Method
mGetValue
=
new
Method
(
"getValue"
);
Method
mGetValue
=
new
Method
(
"getValue"
);
mGetValue
.
setVisibility
(
JavaVisibility
.
PUBLIC
);
mGetValue
.
setVisibility
(
JavaVisibility
.
PUBLIC
);
mGetValue
.
setReturnType
(
FullyQualifiedJavaType
.
getStringInstance
());
mGetValue
.
setReturnType
(
FullyQualifiedJavaType
.
getStringInstance
());
mGetValue
.
addBodyLine
(
"return this.column;"
);
mGetValue
.
addBodyLine
(
"return this.column;"
);
CommentTools
.
add
General
MethodComment
(
mGetValue
,
introspectedTable
);
CommentTools
.
addMethodComment
(
mGetValue
,
introspectedTable
);
innerEnum
.
addMethod
(
mGetValue
);
innerEnum
.
addMethod
(
mGetValue
);
Method
constructor
=
new
Method
(
ENUM_NAME
);
Method
constructor
=
new
Method
(
ENUM_NAME
);
constructor
.
setConstructor
(
true
);
constructor
.
setConstructor
(
true
);
constructor
.
addBodyLine
(
"this.column = column;"
);
constructor
.
addBodyLine
(
"this.column = column;"
);
constructor
.
addParameter
(
new
Parameter
(
FullyQualifiedJavaType
.
getStringInstance
(),
"column"
));
constructor
.
addParameter
(
new
Parameter
(
FullyQualifiedJavaType
.
getStringInstance
(),
"column"
));
CommentTools
.
add
General
MethodComment
(
constructor
,
introspectedTable
);
CommentTools
.
addMethodComment
(
constructor
,
introspectedTable
);
innerEnum
.
addMethod
(
constructor
);
innerEnum
.
addMethod
(
constructor
);
logger
.
debug
(
"itfsw(数据Model属性对应Column获取插件):"
+
topLevelClass
.
getType
().
getShortName
()
+
".Column增加构造方法和column属性。"
);
logger
.
debug
(
"itfsw(数据Model属性对应Column获取插件):"
+
topLevelClass
.
getType
().
getShortName
()
+
".Column增加构造方法和column属性。"
);
...
@@ -119,14 +119,14 @@ public class ModelColumnPlugin extends PluginAdapter {
...
@@ -119,14 +119,14 @@ public class ModelColumnPlugin extends PluginAdapter {
desc
.
setVisibility
(
JavaVisibility
.
PUBLIC
);
desc
.
setVisibility
(
JavaVisibility
.
PUBLIC
);
desc
.
setReturnType
(
FullyQualifiedJavaType
.
getStringInstance
());
desc
.
setReturnType
(
FullyQualifiedJavaType
.
getStringInstance
());
desc
.
addBodyLine
(
"return this.column + \" DESC\";"
);
desc
.
addBodyLine
(
"return this.column + \" DESC\";"
);
CommentTools
.
add
General
MethodComment
(
desc
,
introspectedTable
);
CommentTools
.
addMethodComment
(
desc
,
introspectedTable
);
innerEnum
.
addMethod
(
desc
);
innerEnum
.
addMethod
(
desc
);
Method
asc
=
new
Method
(
"asc"
);
Method
asc
=
new
Method
(
"asc"
);
asc
.
setVisibility
(
JavaVisibility
.
PUBLIC
);
asc
.
setVisibility
(
JavaVisibility
.
PUBLIC
);
asc
.
setReturnType
(
FullyQualifiedJavaType
.
getStringInstance
());
asc
.
setReturnType
(
FullyQualifiedJavaType
.
getStringInstance
());
asc
.
addBodyLine
(
"return this.column + \" ASC\";"
);
asc
.
addBodyLine
(
"return this.column + \" ASC\";"
);
CommentTools
.
add
General
MethodComment
(
asc
,
introspectedTable
);
CommentTools
.
addMethodComment
(
asc
,
introspectedTable
);
innerEnum
.
addMethod
(
asc
);
innerEnum
.
addMethod
(
asc
);
logger
.
debug
(
"itfsw(数据Model属性对应Column获取插件):"
+
topLevelClass
.
getType
().
getShortName
()
+
".Column增加asc()和desc()方法。"
);
logger
.
debug
(
"itfsw(数据Model属性对应Column获取插件):"
+
topLevelClass
.
getType
().
getShortName
()
+
".Column增加asc()和desc()方法。"
);
...
...
src/main/java/com/itfsw/mybatis/generator/plugins/SelectOneByExamplePlugin.java
View file @
bfbae5f3
...
@@ -80,7 +80,7 @@ public class SelectOneByExamplePlugin extends PluginAdapter {
...
@@ -80,7 +80,7 @@ public class SelectOneByExamplePlugin extends PluginAdapter {
FullyQualifiedJavaType
type
=
new
FullyQualifiedJavaType
(
introspectedTable
.
getExampleType
());
FullyQualifiedJavaType
type
=
new
FullyQualifiedJavaType
(
introspectedTable
.
getExampleType
());
method
.
addParameter
(
new
Parameter
(
type
,
"example"
));
method
.
addParameter
(
new
Parameter
(
type
,
"example"
));
// 添加方法说明
// 添加方法说明
CommentTools
.
add
General
MethodComment
(
method
,
introspectedTable
);
CommentTools
.
addMethodComment
(
method
,
introspectedTable
);
// interface 增加方法
// interface 增加方法
interfaze
.
addMethod
(
method
);
interfaze
.
addMethod
(
method
);
...
...
src/main/java/com/itfsw/mybatis/generator/plugins/SelectiveEnhancedPlugin.java
View file @
bfbae5f3
...
@@ -16,15 +16,20 @@
...
@@ -16,15 +16,20 @@
package
com
.
itfsw
.
mybatis
.
generator
.
plugins
;
package
com
.
itfsw
.
mybatis
.
generator
.
plugins
;
import
com.itfsw.mybatis.generator.plugins.utils.CommentTools
;
import
com.itfsw.mybatis.generator.plugins.utils.PluginTools
;
import
com.itfsw.mybatis.generator.plugins.utils.PluginTools
;
import
org.mybatis.generator.api.IntrospectedTable
;
import
org.mybatis.generator.api.IntrospectedTable
;
import
org.mybatis.generator.api.PluginAdapter
;
import
org.mybatis.generator.api.PluginAdapter
;
import
org.mybatis.generator.api.dom.java.TopLevelClass
;
import
org.mybatis.generator.api.dom.java.*
;
import
org.mybatis.generator.api.dom.xml.*
;
import
org.mybatis.generator.internal.util.StringUtility
;
import
org.mybatis.generator.internal.util.StringUtility
;
import
org.slf4j.Logger
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.slf4j.LoggerFactory
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.List
;
import
java.util.regex.Matcher
;
import
java.util.regex.Pattern
;
/**
/**
* ---------------------------------------------------------------------------
* ---------------------------------------------------------------------------
...
@@ -49,7 +54,7 @@ public class SelectiveEnhancedPlugin extends PluginAdapter {
...
@@ -49,7 +54,7 @@ public class SelectiveEnhancedPlugin extends PluginAdapter {
}
}
// 插件使用前提是使用了ModelColumnPlugin插件
// 插件使用前提是使用了ModelColumnPlugin插件
if
(!
PluginTools
.
checkDependencyPlugin
(
ModelColumnPlugin
.
class
,
null
))
{
if
(!
PluginTools
.
checkDependencyPlugin
(
ModelColumnPlugin
.
class
,
getContext
()
))
{
logger
.
warn
(
"itfsw:插件"
+
this
.
getClass
().
getTypeName
()
+
"插件需配合com.itfsw.mybatis.generator.plugins.ModelColumnPlugin插件使用!"
);
logger
.
warn
(
"itfsw:插件"
+
this
.
getClass
().
getTypeName
()
+
"插件需配合com.itfsw.mybatis.generator.plugins.ModelColumnPlugin插件使用!"
);
return
false
;
return
false
;
}
}
...
@@ -66,7 +71,154 @@ public class SelectiveEnhancedPlugin extends PluginAdapter {
...
@@ -66,7 +71,154 @@ public class SelectiveEnhancedPlugin extends PluginAdapter {
*/
*/
@Override
@Override
public
boolean
modelBaseRecordClassGenerated
(
TopLevelClass
topLevelClass
,
IntrospectedTable
introspectedTable
)
{
public
boolean
modelBaseRecordClassGenerated
(
TopLevelClass
topLevelClass
,
IntrospectedTable
introspectedTable
)
{
// import
topLevelClass
.
addImportedType
(
FullyQualifiedJavaType
.
getNewMapInstance
());
topLevelClass
.
addImportedType
(
FullyQualifiedJavaType
.
getNewHashMapInstance
());
// field
Field
selectiveColumnsField
=
new
Field
(
"selectiveColumns"
,
new
FullyQualifiedJavaType
(
"Map<String, Boolean>"
));
CommentTools
.
addFieldComment
(
selectiveColumnsField
,
introspectedTable
);
selectiveColumnsField
.
setVisibility
(
JavaVisibility
.
PRIVATE
);
selectiveColumnsField
.
setInitializationString
(
"new HashMap<String, Boolean>()"
);
topLevelClass
.
addField
(
selectiveColumnsField
);
// Method isSelective
Method
mIsSelective
=
new
Method
(
"isSelective"
);
CommentTools
.
addMethodComment
(
mIsSelective
,
introspectedTable
);
mIsSelective
.
setVisibility
(
JavaVisibility
.
PUBLIC
);
mIsSelective
.
setReturnType
(
FullyQualifiedJavaType
.
getBooleanPrimitiveInstance
());
mIsSelective
.
addParameter
(
new
Parameter
(
FullyQualifiedJavaType
.
getStringInstance
(),
"column"
));
mIsSelective
.
addBodyLine
(
"if (column == null) {"
);
mIsSelective
.
addBodyLine
(
"return this.selectiveColumns.size() > 0;"
);
mIsSelective
.
addBodyLine
(
"} else {"
);
mIsSelective
.
addBodyLine
(
"return this.selectiveColumns.get(column) != null;"
);
mIsSelective
.
addBodyLine
(
"}"
);
topLevelClass
.
addMethod
(
mIsSelective
);
// Method selective
Method
mSelective
=
new
Method
(
"selective"
);
CommentTools
.
addMethodComment
(
mSelective
,
introspectedTable
);
mSelective
.
setVisibility
(
JavaVisibility
.
PUBLIC
);
mSelective
.
setReturnType
(
topLevelClass
.
getType
());
mSelective
.
addParameter
(
new
Parameter
(
new
FullyQualifiedJavaType
(
ModelColumnPlugin
.
ENUM_NAME
),
"columns"
,
true
));
mSelective
.
addBodyLine
(
"this.selectiveColumns.clear();"
);
mSelective
.
addBodyLine
(
"if (columns != null) {"
);
mSelective
.
addBodyLine
(
"for ("
+
ModelColumnPlugin
.
ENUM_NAME
+
" column : columns) {"
);
mSelective
.
addBodyLine
(
"this.selectiveColumns.put(column.value(), true);"
);
mSelective
.
addBodyLine
(
"}"
);
mSelective
.
addBodyLine
(
"}"
);
mSelective
.
addBodyLine
(
"return this;"
);
topLevelClass
.
addMethod
(
mSelective
);
return
true
;
}
/**
* SQL Map Methods 生成
* 具体执行顺序 http://www.mybatis.org/generator/reference/pluggingIn.html
* @param document
* @param introspectedTable
* @return
*/
@Override
public
boolean
sqlMapDocumentGenerated
(
Document
document
,
IntrospectedTable
introspectedTable
)
{
List
<
Element
>
rootElements
=
document
.
getRootElement
().
getElements
();
for
(
Element
rootElement
:
rootElements
)
{
if
(
rootElement
instanceof
XmlElement
)
{
XmlElement
xmlElement
=
(
XmlElement
)
rootElement
;
List
<
Attribute
>
attributes
=
xmlElement
.
getAttributes
();
// 查找ID
String
id
=
""
;
for
(
Attribute
attribute
:
attributes
)
{
if
(
attribute
.
getName
().
equals
(
"id"
))
{
id
=
attribute
.
getValue
();
}
}
// ====================================== 1. insertSelective ======================================
if
(
"insertSelective"
.
equals
(
id
))
{
List
<
XmlElement
>
trimEles
=
this
.
findEle
(
xmlElement
,
"trim"
);
for
(
XmlElement
ele
:
trimEles
)
{
this
.
replaceEle
(
ele
,
"_parameter."
);
}
}
}
}
return
true
;
return
true
;
}
}
/**
* 查找当前节点下的指定节点
* @param element
* @param eleName
* @return
*/
private
List
<
XmlElement
>
findEle
(
XmlElement
element
,
String
eleName
)
{
List
<
XmlElement
>
list
=
new
ArrayList
<>();
List
<
Element
>
elements
=
element
.
getElements
();
for
(
Element
ele
:
elements
)
{
if
(
ele
instanceof
XmlElement
)
{
XmlElement
xmlElement
=
(
XmlElement
)
ele
;
if
(
eleName
.
equalsIgnoreCase
(
xmlElement
.
getName
()))
{
list
.
add
(
xmlElement
);
}
}
}
return
list
;
}
/**
* 替换节点if信息
* @param element
* @param prefix
*/
private
void
replaceEle
(
XmlElement
element
,
String
prefix
)
{
// choose
XmlElement
chooseEle
=
new
XmlElement
(
"choose"
);
// when
XmlElement
whenEle
=
new
XmlElement
(
"when"
);
whenEle
.
addAttribute
(
new
Attribute
(
"test"
,
prefix
+
"isSelective()"
));
for
(
Element
ele
:
element
.
getElements
())
{
// if的text节点
XmlElement
xmlElement
=
(
XmlElement
)
ele
;
TextElement
textElement
=
(
TextElement
)
xmlElement
.
getElements
().
get
(
0
);
// 找出field 名称
String
text
=
textElement
.
getContent
().
trim
();
String
field
=
""
;
if
(
text
.
matches
(
".*\\s*=\\s*#\\{.*\\},?"
))
{
Pattern
pattern
=
Pattern
.
compile
(
"(.*)\\s*=\\s*#\\{.*},?"
);
Matcher
matcher
=
pattern
.
matcher
(
text
);
if
(
matcher
.
find
()){
field
=
matcher
.
group
(
1
);
}
}
else
if
(
text
.
matches
(
"#\\{.*\\},?"
))
{
Pattern
pattern
=
Pattern
.
compile
(
"#\\{(.*?),.*\\},?"
);
Matcher
matcher
=
pattern
.
matcher
(
text
);
if
(
matcher
.
find
()){
field
=
matcher
.
group
(
1
);
}
}
else
{
field
=
text
.
replaceAll
(
","
,
""
);
}
XmlElement
ifEle
=
new
XmlElement
(
"if"
);
ifEle
.
addAttribute
(
new
Attribute
(
"test"
,
prefix
+
"isSelective("
+
field
+
")"
));
ifEle
.
addElement
(
textElement
);
whenEle
.
addElement
(
ifEle
);
}
// otherwise
XmlElement
otherwiseEle
=
new
XmlElement
(
"otherwise"
);
for
(
Element
ele
:
element
.
getElements
())
{
otherwiseEle
.
addElement
(
ele
);
}
chooseEle
.
addElement
(
whenEle
);
chooseEle
.
addElement
(
otherwiseEle
);
// 清空原始节点,新增choose节点
element
.
getElements
().
clear
();
element
.
addElement
(
chooseEle
);
}
}
}
src/main/java/com/itfsw/mybatis/generator/plugins/UpsertPlugin.java
View file @
bfbae5f3
...
@@ -98,7 +98,7 @@ public class UpsertPlugin extends PluginAdapter {
...
@@ -98,7 +98,7 @@ public class UpsertPlugin extends PluginAdapter {
// 添加参数
// 添加参数
mUpsert
.
addParameter
(
new
Parameter
(
introspectedTable
.
getRules
().
calculateAllFieldsClass
(),
"record"
));
mUpsert
.
addParameter
(
new
Parameter
(
introspectedTable
.
getRules
().
calculateAllFieldsClass
(),
"record"
));
// 添加方法说明
// 添加方法说明
CommentTools
.
add
General
MethodComment
(
mUpsert
,
introspectedTable
);
CommentTools
.
addMethodComment
(
mUpsert
,
introspectedTable
);
// interface 增加方法
// interface 增加方法
interfaze
.
addMethod
(
mUpsert
);
interfaze
.
addMethod
(
mUpsert
);
logger
.
debug
(
"itfsw(存在即更新插件):"
+
interfaze
.
getType
().
getShortName
()
+
"增加upsert方法。"
);
logger
.
debug
(
"itfsw(存在即更新插件):"
+
interfaze
.
getType
().
getShortName
()
+
"增加upsert方法。"
);
...
@@ -110,7 +110,7 @@ public class UpsertPlugin extends PluginAdapter {
...
@@ -110,7 +110,7 @@ public class UpsertPlugin extends PluginAdapter {
// 添加参数
// 添加参数
mUpsertSelective
.
addParameter
(
new
Parameter
(
introspectedTable
.
getRules
().
calculateAllFieldsClass
(),
"record"
));
mUpsertSelective
.
addParameter
(
new
Parameter
(
introspectedTable
.
getRules
().
calculateAllFieldsClass
(),
"record"
));
// 添加方法说明
// 添加方法说明
CommentTools
.
add
General
MethodComment
(
mUpsertSelective
,
introspectedTable
);
CommentTools
.
addMethodComment
(
mUpsertSelective
,
introspectedTable
);
// interface 增加方法
// interface 增加方法
interfaze
.
addMethod
(
mUpsertSelective
);
interfaze
.
addMethod
(
mUpsertSelective
);
logger
.
debug
(
"itfsw(存在即更新插件):"
+
interfaze
.
getType
().
getShortName
()
+
"增加upsertSelective方法。"
);
logger
.
debug
(
"itfsw(存在即更新插件):"
+
interfaze
.
getType
().
getShortName
()
+
"增加upsertSelective方法。"
);
...
@@ -124,7 +124,7 @@ public class UpsertPlugin extends PluginAdapter {
...
@@ -124,7 +124,7 @@ public class UpsertPlugin extends PluginAdapter {
mUpsertByExample
.
addParameter
(
new
Parameter
(
introspectedTable
.
getRules
().
calculateAllFieldsClass
(),
"record"
,
"@Param(\"record\")"
));
mUpsertByExample
.
addParameter
(
new
Parameter
(
introspectedTable
.
getRules
().
calculateAllFieldsClass
(),
"record"
,
"@Param(\"record\")"
));
mUpsertByExample
.
addParameter
(
new
Parameter
(
new
FullyQualifiedJavaType
(
introspectedTable
.
getExampleType
()),
"example"
,
"@Param(\"example\")"
));
mUpsertByExample
.
addParameter
(
new
Parameter
(
new
FullyQualifiedJavaType
(
introspectedTable
.
getExampleType
()),
"example"
,
"@Param(\"example\")"
));
// 添加方法说明
// 添加方法说明
CommentTools
.
add
General
MethodComment
(
mUpsertByExample
,
introspectedTable
);
CommentTools
.
addMethodComment
(
mUpsertByExample
,
introspectedTable
);
// interface 增加方法
// interface 增加方法
interfaze
.
addMethod
(
mUpsertByExample
);
interfaze
.
addMethod
(
mUpsertByExample
);
logger
.
debug
(
"itfsw(存在即更新插件):"
+
interfaze
.
getType
().
getShortName
()
+
"增加upsertByExample方法。"
);
logger
.
debug
(
"itfsw(存在即更新插件):"
+
interfaze
.
getType
().
getShortName
()
+
"增加upsertByExample方法。"
);
...
@@ -137,7 +137,7 @@ public class UpsertPlugin extends PluginAdapter {
...
@@ -137,7 +137,7 @@ public class UpsertPlugin extends PluginAdapter {
mUpsertByExampleSelective
.
addParameter
(
new
Parameter
(
introspectedTable
.
getRules
().
calculateAllFieldsClass
(),
"record"
,
"@Param(\"record\")"
));
mUpsertByExampleSelective
.
addParameter
(
new
Parameter
(
introspectedTable
.
getRules
().
calculateAllFieldsClass
(),
"record"
,
"@Param(\"record\")"
));
mUpsertByExampleSelective
.
addParameter
(
new
Parameter
(
new
FullyQualifiedJavaType
(
introspectedTable
.
getExampleType
()),
"example"
,
"@Param(\"example\")"
));
mUpsertByExampleSelective
.
addParameter
(
new
Parameter
(
new
FullyQualifiedJavaType
(
introspectedTable
.
getExampleType
()),
"example"
,
"@Param(\"example\")"
));
// 添加方法说明
// 添加方法说明
CommentTools
.
add
General
MethodComment
(
mUpsertByExampleSelective
,
introspectedTable
);
CommentTools
.
addMethodComment
(
mUpsertByExampleSelective
,
introspectedTable
);
// interface 增加方法
// interface 增加方法
interfaze
.
addMethod
(
mUpsertByExampleSelective
);
interfaze
.
addMethod
(
mUpsertByExampleSelective
);
logger
.
debug
(
"itfsw(存在即更新插件):"
+
interfaze
.
getType
().
getShortName
()
+
"增加upsertByExampleSelective方法。"
);
logger
.
debug
(
"itfsw(存在即更新插件):"
+
interfaze
.
getType
().
getShortName
()
+
"增加upsertByExampleSelective方法。"
);
...
...
src/main/java/com/itfsw/mybatis/generator/plugins/utils/CommentTools.java
View file @
bfbae5f3
...
@@ -99,7 +99,7 @@ public class CommentTools {
...
@@ -99,7 +99,7 @@ public class CommentTools {
* @param method 方法
* @param method 方法
* @param introspectedTable 表
* @param introspectedTable 表
*/
*/
public
static
void
add
General
MethodComment
(
Method
method
,
IntrospectedTable
introspectedTable
)
{
public
static
void
addMethodComment
(
Method
method
,
IntrospectedTable
introspectedTable
)
{
StringBuilder
sb
=
new
StringBuilder
();
StringBuilder
sb
=
new
StringBuilder
();
method
.
addJavaDocLine
(
"/**"
);
method
.
addJavaDocLine
(
"/**"
);
method
.
addJavaDocLine
(
" * 这是Mybatis Generator拓展插件生成的方法(请勿删除)."
);
method
.
addJavaDocLine
(
" * 这是Mybatis Generator拓展插件生成的方法(请勿删除)."
);
...
...
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