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
d412fb37
Commit
d412fb37
authored
Jan 13, 2017
by
hewei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
一些修正和新增插件
parent
a316fceb
Changes
10
Show whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
125 additions
and
12 deletions
+125
-12
src/main/java/com/itfsw/mybatis/generator/plugins/BatchInsertPlugin.java
...om/itfsw/mybatis/generator/plugins/BatchInsertPlugin.java
+109
-0
src/main/java/com/itfsw/mybatis/generator/plugins/CriteriaBuilderPlugin.java
...tfsw/mybatis/generator/plugins/CriteriaBuilderPlugin.java
+2
-1
src/main/java/com/itfsw/mybatis/generator/plugins/ExampleTargetPlugin.java
.../itfsw/mybatis/generator/plugins/ExampleTargetPlugin.java
+2
-2
src/main/java/com/itfsw/mybatis/generator/plugins/LimitPlugin.java
...java/com/itfsw/mybatis/generator/plugins/LimitPlugin.java
+3
-1
src/main/java/com/itfsw/mybatis/generator/plugins/ModelBuilderPlugin.java
...m/itfsw/mybatis/generator/plugins/ModelBuilderPlugin.java
+2
-1
src/main/java/com/itfsw/mybatis/generator/plugins/SelectOneByExamplePlugin.java
...w/mybatis/generator/plugins/SelectOneByExamplePlugin.java
+3
-3
src/main/java/com/itfsw/mybatis/generator/plugins/utils/CommentTools.java
...m/itfsw/mybatis/generator/plugins/utils/CommentTools.java
+1
-1
src/main/java/com/itfsw/mybatis/generator/plugins/utils/InnerInterface.java
...itfsw/mybatis/generator/plugins/utils/InnerInterface.java
+1
-1
src/main/java/com/itfsw/mybatis/generator/plugins/utils/InnerInterfaceWrapperToInnerClass.java
...ator/plugins/utils/InnerInterfaceWrapperToInnerClass.java
+1
-1
src/main/java/com/itfsw/mybatis/generator/plugins/utils/XmlElementGeneratorTools.java
...tis/generator/plugins/utils/XmlElementGeneratorTools.java
+1
-1
No files found.
src/main/java/com/itfsw/mybatis/generator/plugins/BatchInsertPlugin.java
0 → 100644
View file @
d412fb37
/*
* Copyright (c) 2017.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
com
.
itfsw
.
mybatis
.
generator
.
plugins
;
import
com.itfsw.mybatis.generator.plugins.utils.CommentTools
;
import
org.mybatis.generator.api.IntrospectedTable
;
import
org.mybatis.generator.api.PluginAdapter
;
import
org.mybatis.generator.api.dom.java.*
;
import
org.mybatis.generator.api.dom.xml.Document
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
java.util.List
;
/**
* ---------------------------------------------------------------------------
* 批量插入插件
* ---------------------------------------------------------------------------
* @author: hewei
* @time:2017/1/13 9:33
* ---------------------------------------------------------------------------
*/
public
class
BatchInsertPlugin
extends
PluginAdapter
{
private
static
final
Logger
logger
=
LoggerFactory
.
getLogger
(
BatchInsertPlugin
.
class
);
public
static
final
String
METHOD_BATCH_INSERT
=
"batchInsert"
;
// 方法名
public
static
final
String
METHOD_BATCH_INSERT_SELECTIVE
=
"batchInsertSelective"
;
// 方法名
/**
* {@inheritDoc}
*/
@Override
public
boolean
validate
(
List
<
String
>
warnings
)
{
return
true
;
}
/**
* Java Client Methods 生成
* 具体执行顺序 http://www.mybatis.org/generator/reference/pluggingIn.html
*
* @param interfaze
* @param topLevelClass
* @param introspectedTable
* @return
*/
@Override
public
boolean
clientGenerated
(
Interface
interfaze
,
TopLevelClass
topLevelClass
,
IntrospectedTable
introspectedTable
)
{
logger
.
debug
(
"itfsw:生成"
+
interfaze
.
getType
()+
"对应batchInsert方法..."
);
// 方法生成
Method
method
=
new
Method
(
METHOD_BATCH_INSERT
);
// 方法可见性 interface会忽略
// method.setVisibility(JavaVisibility.PUBLIC);
// 返回值类型
method
.
setReturnType
(
FullyQualifiedJavaType
.
getIntInstance
());
// 添加参数
FullyQualifiedJavaType
type
=
FullyQualifiedJavaType
.
getNewListInstance
();
type
.
addTypeArgument
(
interfaze
.
getType
());
method
.
addParameter
(
new
Parameter
(
type
,
"list"
,
"@Param(\"list\")"
));
// 添加方法说明
CommentTools
.
addGeneralMethodComment
(
method
,
introspectedTable
);
// interface 增加方法
interfaze
.
addMethod
(
method
);
logger
.
debug
(
"itfsw:生成"
+
interfaze
.
getType
()+
"对应batchInsertSelective方法..."
);
// 方法生成
Method
method1
=
new
Method
(
METHOD_BATCH_INSERT_SELECTIVE
);
// 方法可见性 interface会忽略
// method1.setVisibility(JavaVisibility.PUBLIC);
// 返回值类型
method1
.
setReturnType
(
FullyQualifiedJavaType
.
getIntInstance
());
// 添加参数
FullyQualifiedJavaType
type1
=
FullyQualifiedJavaType
.
getNewListInstance
();
type1
.
addTypeArgument
(
interfaze
.
getType
());
method1
.
addParameter
(
new
Parameter
(
type1
,
"list"
,
"@Param(\"list\")"
));
// 添加方法说明
CommentTools
.
addGeneralMethodComment
(
method1
,
introspectedTable
);
// interface 增加方法
interfaze
.
addMethod
(
method1
);
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
)
{
return
true
;
}
}
src/main/java/com/itfsw/mybatis/generator/plugins/CriteriaBuilderPlugin.java
View file @
d412fb37
/*
* Copyright (c) 201
4
.
* Copyright (c) 201
7
.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
...
...
@@ -40,6 +40,7 @@ public class CriteriaBuilderPlugin extends PluginAdapter {
/**
* {@inheritDoc}
*/
@Override
public
boolean
validate
(
List
<
String
>
warnings
)
{
return
true
;
}
...
...
src/main/java/com/itfsw/mybatis/generator/plugins/ExampleTargetPlugin.java
View file @
d412fb37
/*
*
* * Copyright (c) 201
4
.
* * Copyright (c) 201
7
.
* *
* * Licensed under the Apache License, Version 2.0 (the "License");
* * you may not use this file except in compliance with the License.
...
...
@@ -38,7 +38,7 @@ import java.util.Properties;
*/
public
class
ExampleTargetPlugin
extends
PluginAdapter
{
public
static
final
String
TARGET_PACKAGE_KEY
=
"targetPackage"
;
// 配置targetPackage名
private
static
final
Logger
logger
=
LoggerFactory
.
getLogger
(
CriteriaBuilder
Plugin
.
class
);
private
static
final
Logger
logger
=
LoggerFactory
.
getLogger
(
ExampleTarget
Plugin
.
class
);
private
String
targetPackage
;
// 目标包
...
...
src/main/java/com/itfsw/mybatis/generator/plugins/LimitPlugin.java
View file @
d412fb37
/*
* Copyright (c) 201
4
.
* Copyright (c) 201
7
.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
...
...
@@ -41,9 +41,11 @@ public class LimitPlugin extends PluginAdapter {
/**
* {@inheritDoc}
*/
@Override
public
boolean
validate
(
List
<
String
>
warnings
)
{
return
true
;
}
/**
* ModelExample Methods 生成
* 具体执行顺序 http://www.mybatis.org/generator/reference/pluggingIn.html
...
...
src/main/java/com/itfsw/mybatis/generator/plugins/ModelBuilderPlugin.java
View file @
d412fb37
/*
* Copyright (c) 201
4
.
* Copyright (c) 201
7
.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
...
...
@@ -42,6 +42,7 @@ public class ModelBuilderPlugin extends PluginAdapter {
/**
* {@inheritDoc}
*/
@Override
public
boolean
validate
(
List
<
String
>
warnings
)
{
return
true
;
}
...
...
src/main/java/com/itfsw/mybatis/generator/plugins/SelectOneByExamplePlugin.java
View file @
d412fb37
/*
* Copyright (c) 201
4
.
* Copyright (c) 201
7
.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
...
...
@@ -66,8 +66,8 @@ public class SelectOneByExamplePlugin extends PluginAdapter {
logger
.
debug
(
"itfsw:生成"
+
interfaze
.
getType
()+
"对应SelectOneByExample方法..."
);
// 方法生成
Method
method
=
new
Method
(
METHOD_NAME
);
// 方法可见性
method
.
setVisibility
(
JavaVisibility
.
PUBLIC
);
// 方法可见性
interface会忽略
//
method.setVisibility(JavaVisibility.PUBLIC);
// 返回值类型
FullyQualifiedJavaType
returnType
=
introspectedTable
.
getRules
().
calculateAllFieldsClass
();
method
.
setReturnType
(
returnType
);
...
...
src/main/java/com/itfsw/mybatis/generator/plugins/utils/CommentTools.java
View file @
d412fb37
/*
* Copyright (c) 201
4
.
* Copyright (c) 201
7
.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
...
...
src/main/java/com/itfsw/mybatis/generator/plugins/utils/InnerInterface.java
View file @
d412fb37
/*
*
* * Copyright (c) 201
4
.
* * Copyright (c) 201
7
.
* *
* * Licensed under the Apache License, Version 2.0 (the "License");
* * you may not use this file except in compliance with the License.
...
...
src/main/java/com/itfsw/mybatis/generator/plugins/utils/InnerInterfaceWrapperToInnerClass.java
View file @
d412fb37
/*
*
* * Copyright (c) 201
4
.
* * Copyright (c) 201
7
.
* *
* * Licensed under the Apache License, Version 2.0 (the "License");
* * you may not use this file except in compliance with the License.
...
...
src/main/java/com/itfsw/mybatis/generator/plugins/utils/XmlElementGeneratorTools.java
View file @
d412fb37
/*
* Copyright (c) 201
4
.
* Copyright (c) 201
7
.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
...
...
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