Commit 192cf209 authored by hewei's avatar hewei

bugfix[issues#24]:在单独使用某些插件,Mapper接口没有import的问题;

parent a50ef78c
......@@ -16,10 +16,7 @@
package com.itfsw.mybatis.generator.plugins;
import com.itfsw.mybatis.generator.plugins.utils.BasePlugin;
import com.itfsw.mybatis.generator.plugins.utils.JavaElementGeneratorTools;
import com.itfsw.mybatis.generator.plugins.utils.PluginTools;
import com.itfsw.mybatis.generator.plugins.utils.XmlElementGeneratorTools;
import com.itfsw.mybatis.generator.plugins.utils.*;
import org.mybatis.generator.api.IntrospectedColumn;
import org.mybatis.generator.api.IntrospectedTable;
import org.mybatis.generator.api.dom.java.*;
......@@ -88,7 +85,7 @@ public class BatchInsertPlugin extends BasePlugin {
);
commentGenerator.addGeneralMethodComment(mBatchInsert, introspectedTable);
// interface 增加方法
interfaze.addMethod(mBatchInsert);
FormatTools.addMethodWithBestPosition(interfaze, mBatchInsert);
logger.debug("itfsw(批量插入插件):" + interfaze.getType().getShortName() + "增加batchInsert方法。");
// 2. batchInsertSelective
......@@ -102,7 +99,7 @@ public class BatchInsertPlugin extends BasePlugin {
);
commentGenerator.addGeneralMethodComment(mBatchInsertSelective, introspectedTable);
// interface 增加方法
interfaze.addMethod(mBatchInsertSelective);
FormatTools.addMethodWithBestPosition(interfaze, mBatchInsertSelective);
logger.debug("itfsw(批量插入插件):" + interfaze.getType().getShortName() + "增加batchInsertSelective方法。");
return true;
......
package com.itfsw.mybatis.generator.plugins;
import com.itfsw.mybatis.generator.plugins.utils.BasePlugin;
import com.itfsw.mybatis.generator.plugins.utils.FormatTools;
import com.itfsw.mybatis.generator.plugins.utils.JavaElementGeneratorTools;
import com.itfsw.mybatis.generator.plugins.utils.enhanced.InnerInterface;
import com.itfsw.mybatis.generator.plugins.utils.enhanced.InnerInterfaceWrapperToInnerClass;
......@@ -91,7 +92,7 @@ public class ExampleEnhancedPlugin extends BasePlugin {
exampleMethod,
"return this.example;"
);
innerClass.addMethod(exampleMethod);
FormatTools.addMethodWithBestPosition(innerClass, exampleMethod);
logger.debug("itfsw(Example增强插件):" + topLevelClass.getType().getShortName() + "." + innerClass.getType().getShortName() + "增加工厂方法example");
}
......@@ -116,7 +117,7 @@ public class ExampleEnhancedPlugin extends BasePlugin {
new Parameter(innerClass.getType(), "add")
);
commentGenerator.addGeneralMethodComment(addMethod, introspectedTable);
criteriaAddInterface.addMethod(addMethod);
FormatTools.addMethodWithBestPosition(criteriaAddInterface, addMethod);
logger.debug("itfsw(Example增强插件):" + topLevelClass.getType().getShortName() + "." + innerClass.getType().getShortName() + "." + criteriaAddInterface.getType().getShortName() + "增加方法add");
InnerClass innerClassWrapper = new InnerInterfaceWrapperToInnerClass(criteriaAddInterface);
......@@ -140,7 +141,7 @@ public class ExampleEnhancedPlugin extends BasePlugin {
"}",
"return this;"
);
innerClass.addMethod(andIfMethod);
FormatTools.addMethodWithBestPosition(innerClass, andIfMethod);
logger.debug("itfsw(Example增强插件):" + topLevelClass.getType().getShortName() + "." + innerClass.getType().getShortName() + "增加方法andIf");
}
......@@ -163,7 +164,7 @@ public class ExampleEnhancedPlugin extends BasePlugin {
"this.setOrderByClause(orderByClause);",
"return this;"
);
topLevelClass.addMethod(orderByMethod);
FormatTools.addMethodWithBestPosition(topLevelClass, orderByMethod);
logger.debug("itfsw(Example增强插件):" + topLevelClass.getType().getShortName() + "增加方法orderBy");
// 添加orderBy
......@@ -187,7 +188,7 @@ public class ExampleEnhancedPlugin extends BasePlugin {
"return this;"
);
topLevelClass.addMethod(orderByMethod1);
FormatTools.addMethodWithBestPosition(topLevelClass, orderByMethod1);
logger.debug("itfsw(Example增强插件):" + topLevelClass.getType().getShortName() + "增加方法orderBy(String ... orderByClauses)");
}
}
......@@ -177,11 +177,11 @@ public class IncrementsPlugin extends BasePlugin implements IModelBuilderPluginH
mInc.addBodyLine("this.value = value;");
mInc.addParameter(new Parameter(FullyQualifiedJavaType.getStringInstance(), "value"));
commentGenerator.addGeneralMethodComment(mInc, introspectedTable);
eIncrements.addMethod(mInc);
FormatTools.addMethodWithBestPosition(eIncrements, mInc);
Method mValue = JavaElementGeneratorTools.generateGetterMethod(fValue);
commentGenerator.addGeneralMethodComment(mValue, introspectedTable);
eIncrements.addMethod(mValue);
FormatTools.addMethodWithBestPosition(eIncrements, mValue);
builderClass.addInnerEnum(eIncrements);
// 增加field
......@@ -198,10 +198,10 @@ public class IncrementsPlugin extends BasePlugin implements IModelBuilderPluginH
// getter&setter
Method mGetter = JavaElementGeneratorTools.generateGetterMethod(fIncrements);
commentGenerator.addGetterComment(mGetter, introspectedTable, null);
topLevelClass.addMethod(mGetter);
FormatTools.addMethodWithBestPosition(topLevelClass, mGetter);
Method mSetter = JavaElementGeneratorTools.generateSetterMethod(fIncrements);
commentGenerator.addSetterComment(mSetter, introspectedTable, null);
topLevelClass.addMethod(mSetter);
FormatTools.addMethodWithBestPosition(topLevelClass, mSetter);
// 增加判断方法
Method mHasIncsForColumn = JavaElementGeneratorTools.generateMethod(
IncrementsPlugin.METHOD_INC_CHECK,
......
......@@ -17,6 +17,7 @@
package com.itfsw.mybatis.generator.plugins;
import com.itfsw.mybatis.generator.plugins.utils.BasePlugin;
import com.itfsw.mybatis.generator.plugins.utils.FormatTools;
import com.itfsw.mybatis.generator.plugins.utils.JavaElementGeneratorTools;
import org.mybatis.generator.api.IntrospectedTable;
import org.mybatis.generator.api.dom.java.*;
......@@ -41,8 +42,8 @@ public class LimitPlugin extends BasePlugin {
@Override
public boolean validate(List<String> warnings) {
// 该插件只支持MYSQL
if ("com.mysql.jdbc.Driver".equalsIgnoreCase(this.getContext().getJdbcConnectionConfiguration().getDriverClass()) == false){
warnings.add("itfsw:插件"+this.getClass().getTypeName()+"只支持MySQL数据库!");
if ("com.mysql.jdbc.Driver".equalsIgnoreCase(this.getContext().getJdbcConnectionConfiguration().getDriverClass()) == false) {
warnings.add("itfsw:插件" + this.getClass().getTypeName() + "只支持MySQL数据库!");
return false;
}
return super.validate(warnings);
......@@ -51,7 +52,6 @@ public class LimitPlugin extends BasePlugin {
/**
* ModelExample Methods 生成
* 具体执行顺序 http://www.mybatis.org/generator/reference/pluggingIn.html
*
* @param topLevelClass
* @param introspectedTable
* @return
......@@ -77,25 +77,25 @@ public class LimitPlugin extends BasePlugin {
);
commentGenerator.addFieldComment(rowsField, introspectedTable);
topLevelClass.addField(rowsField);
logger.debug("itfsw(MySQL分页插件):"+topLevelClass.getType().getShortName()+"增加offset和rows字段");
logger.debug("itfsw(MySQL分页插件):" + topLevelClass.getType().getShortName() + "增加offset和rows字段");
// 增加getter && setter 方法
Method mSetOffset = JavaElementGeneratorTools.generateSetterMethod(offsetField);
commentGenerator.addGeneralMethodComment(mSetOffset, introspectedTable);
topLevelClass.addMethod(mSetOffset);
FormatTools.addMethodWithBestPosition(topLevelClass, mSetOffset);
Method mGetOffset = JavaElementGeneratorTools.generateGetterMethod(offsetField);
commentGenerator.addGeneralMethodComment(mGetOffset, introspectedTable);
topLevelClass.addMethod(mGetOffset);
FormatTools.addMethodWithBestPosition(topLevelClass, mGetOffset);
Method mSetRows = JavaElementGeneratorTools.generateSetterMethod(rowsField);
commentGenerator.addGeneralMethodComment(mSetRows, introspectedTable);
topLevelClass.addMethod(mSetRows);
FormatTools.addMethodWithBestPosition(topLevelClass, mSetRows);
Method mGetRows = JavaElementGeneratorTools.generateGetterMethod(rowsField);
commentGenerator.addGeneralMethodComment(mGetRows, introspectedTable);
topLevelClass.addMethod(mGetRows);
logger.debug("itfsw(MySQL分页插件):"+topLevelClass.getType().getShortName()+"增加offset和rows的getter和setter实现。");
FormatTools.addMethodWithBestPosition(topLevelClass, mGetRows);
logger.debug("itfsw(MySQL分页插件):" + topLevelClass.getType().getShortName() + "增加offset和rows的getter和setter实现。");
// 提供几个快捷方法
Method setLimit = JavaElementGeneratorTools.generateMethod(
......@@ -110,7 +110,7 @@ public class LimitPlugin extends BasePlugin {
"this.rows = rows;",
"return this;"
);
topLevelClass.addMethod(setLimit);
FormatTools.addMethodWithBestPosition(topLevelClass, setLimit);
Method setLimit2 = JavaElementGeneratorTools.generateMethod(
"limit",
......@@ -126,8 +126,8 @@ public class LimitPlugin extends BasePlugin {
"this.rows = rows;",
"return this;"
);
topLevelClass.addMethod(setLimit2);
logger.debug("itfsw(MySQL分页插件):"+topLevelClass.getType().getShortName()+"增加limit方法。");
FormatTools.addMethodWithBestPosition(topLevelClass, setLimit2);
logger.debug("itfsw(MySQL分页插件):" + topLevelClass.getType().getShortName() + "增加limit方法。");
Method setPage = JavaElementGeneratorTools.generateMethod(
"page",
......@@ -143,16 +143,16 @@ public class LimitPlugin extends BasePlugin {
"this.rows = pageSize;",
"return this;"
);
topLevelClass.addMethod(setPage);
logger.debug("itfsw(MySQL分页插件):"+topLevelClass.getType().getShortName()+"增加page方法");
FormatTools.addMethodWithBestPosition(topLevelClass, setPage);
logger.debug("itfsw(MySQL分页插件):" + topLevelClass.getType().getShortName() + "增加page方法");
// !!! clear 方法增加 offset 和 rows的清理
List<Method> methodList = topLevelClass.getMethods();
for (Method method: methodList){
if (method.getName().equals("clear")){
for (Method method : methodList) {
if (method.getName().equals("clear")) {
method.addBodyLine("rows = null;");
method.addBodyLine("offset = null;");
logger.debug("itfsw(MySQL分页插件):"+topLevelClass.getType().getShortName()+"修改clear方法,增加rows和offset字段的清空");
logger.debug("itfsw(MySQL分页插件):" + topLevelClass.getType().getShortName() + "修改clear方法,增加rows和offset字段的清空");
}
}
......@@ -162,7 +162,6 @@ public class LimitPlugin extends BasePlugin {
/**
* SQL Map Methods 生成
* 具体执行顺序 http://www.mybatis.org/generator/reference/pluggingIn.html
*
* @param element
* @param introspectedTable
* @return
......@@ -176,7 +175,6 @@ public class LimitPlugin extends BasePlugin {
/**
* SQL Map Methods 生成
* 具体执行顺序 http://www.mybatis.org/generator/reference/pluggingIn.html
*
* @param element
* @param introspectedTable
* @return
......@@ -189,11 +187,10 @@ public class LimitPlugin extends BasePlugin {
/**
* 生成limit节点
*
* @param element
* @param introspectedTable
*/
public void generateLimitElement(XmlElement element, IntrospectedTable introspectedTable){
public void generateLimitElement(XmlElement element, IntrospectedTable introspectedTable) {
XmlElement ifLimitNotNullElement = new XmlElement("if");
ifLimitNotNullElement.addAttribute(new Attribute("test", "rows != null"));
......@@ -209,6 +206,6 @@ public class LimitPlugin extends BasePlugin {
element.addElement(ifLimitNotNullElement);
logger.debug("itfsw(MySQL分页插件):"+introspectedTable.getMyBatis3XmlMapperFileName()+"selectByExample方法增加分页条件。");
logger.debug("itfsw(MySQL分页插件):" + introspectedTable.getMyBatis3XmlMapperFileName() + "selectByExample方法增加分页条件。");
}
}
......@@ -17,6 +17,7 @@
package com.itfsw.mybatis.generator.plugins;
import com.itfsw.mybatis.generator.plugins.utils.BasePlugin;
import com.itfsw.mybatis.generator.plugins.utils.FormatTools;
import com.itfsw.mybatis.generator.plugins.utils.JavaElementGeneratorTools;
import com.itfsw.mybatis.generator.plugins.utils.PluginTools;
import com.itfsw.mybatis.generator.plugins.utils.enhanced.InnerTypeFullyQualifiedJavaType;
......@@ -116,7 +117,7 @@ public class ModelBuilderPlugin extends BasePlugin {
commentGenerator.addGeneralMethodComment(builder, introspectedTable);
builder.setStatic(true);
builder.addBodyLine("return new " + builderType.getShortName() + "();");
topLevelClass.addMethod(builder);
FormatTools.addMethodWithBestPosition(topLevelClass, builder);
commentGenerator.addClassComment(innerClass, introspectedTable);
logger.debug("itfsw(数据Model链式构建插件):" + topLevelClass.getType().getShortName() + "增加内部Builder类。");
......@@ -132,7 +133,7 @@ public class ModelBuilderPlugin extends BasePlugin {
constructor.setConstructor(true);
constructor.addBodyLine(new StringBuilder("this.obj = new ").append(topLevelClass.getType().getShortName()).append("();").toString());
commentGenerator.addGeneralMethodComment(constructor, introspectedTable);
innerClass.addMethod(constructor);
FormatTools.addMethodWithBestPosition(innerClass, constructor);
logger.debug("itfsw(数据Model链式构建插件):" + topLevelClass.getType().getShortName() + ".Builder增加的构造方法。");
for (IntrospectedColumn introspectedColumn : columns) {
......@@ -154,7 +155,7 @@ public class ModelBuilderPlugin extends BasePlugin {
// hook
if (PluginTools.getHook(IModelBuilderPluginHook.class).modelBuilderSetterMethodGenerated(method, topLevelClass, innerClass, introspectedColumn, introspectedTable)) {
innerClass.addMethod(method);
FormatTools.addMethodWithBestPosition(innerClass, method);
logger.debug("itfsw(数据Model链式构建插件):" + topLevelClass.getType().getShortName() + ".Builder增加" + method.getName() + "方法(复合主键)。");
}
}
......@@ -166,7 +167,7 @@ public class ModelBuilderPlugin extends BasePlugin {
);
build.addBodyLine("return this.obj;");
commentGenerator.addGeneralMethodComment(build, introspectedTable);
innerClass.addMethod(build);
FormatTools.addMethodWithBestPosition(innerClass, build);
logger.debug("itfsw(数据Model链式构建插件):" + topLevelClass.getType().getShortName() + ".Builder增加build方法。");
// hook
......
......@@ -17,6 +17,7 @@
package com.itfsw.mybatis.generator.plugins;
import com.itfsw.mybatis.generator.plugins.utils.BasePlugin;
import com.itfsw.mybatis.generator.plugins.utils.FormatTools;
import com.itfsw.mybatis.generator.plugins.utils.JavaElementGeneratorTools;
import org.mybatis.generator.api.IntrospectedColumn;
import org.mybatis.generator.api.IntrospectedTable;
......@@ -110,22 +111,22 @@ public class ModelColumnPlugin extends BasePlugin {
mValue.setReturnType(FullyQualifiedJavaType.getStringInstance());
mValue.addBodyLine("return this.column;");
commentGenerator.addGeneralMethodComment(mValue, introspectedTable);
innerEnum.addMethod(mValue);
FormatTools.addMethodWithBestPosition(innerEnum, mValue);
Method mGetValue = new Method("getValue");
mGetValue.setVisibility(JavaVisibility.PUBLIC);
mGetValue.setReturnType(FullyQualifiedJavaType.getStringInstance());
mGetValue.addBodyLine("return this.column;");
commentGenerator.addGeneralMethodComment(mGetValue, introspectedTable);
innerEnum.addMethod(mGetValue);
FormatTools.addMethodWithBestPosition(innerEnum, mGetValue);
Method mGetJavaProperty = JavaElementGeneratorTools.generateGetterMethod(javaPropertyField);
commentGenerator.addGeneralMethodComment(mGetJavaProperty, introspectedTable);
innerEnum.addMethod(mGetJavaProperty);
FormatTools.addMethodWithBestPosition(innerEnum, mGetJavaProperty);
Method mGetJdbcType = JavaElementGeneratorTools.generateGetterMethod(jdbcTypeField);
commentGenerator.addGeneralMethodComment(mGetJdbcType, introspectedTable);
innerEnum.addMethod(mGetJdbcType);
FormatTools.addMethodWithBestPosition(innerEnum, mGetJdbcType);
Method constructor = new Method(ENUM_NAME);
constructor.setConstructor(true);
......@@ -136,7 +137,7 @@ public class ModelColumnPlugin extends BasePlugin {
constructor.addParameter(new Parameter(FullyQualifiedJavaType.getStringInstance(), "javaProperty"));
constructor.addParameter(new Parameter(FullyQualifiedJavaType.getStringInstance(), "jdbcType"));
commentGenerator.addGeneralMethodComment(constructor, introspectedTable);
innerEnum.addMethod(constructor);
FormatTools.addMethodWithBestPosition(innerEnum, constructor);
logger.debug("itfsw(数据Model属性对应Column获取插件):" + topLevelClass.getType().getShortName() + ".Column增加构造方法和column属性。");
// Enum枚举
......@@ -163,14 +164,14 @@ public class ModelColumnPlugin extends BasePlugin {
desc.setReturnType(FullyQualifiedJavaType.getStringInstance());
desc.addBodyLine("return this.column + \" DESC\";");
commentGenerator.addGeneralMethodComment(desc, introspectedTable);
innerEnum.addMethod(desc);
FormatTools.addMethodWithBestPosition(innerEnum, desc);
Method asc = new Method("asc");
asc.setVisibility(JavaVisibility.PUBLIC);
asc.setReturnType(FullyQualifiedJavaType.getStringInstance());
asc.addBodyLine("return this.column + \" ASC\";");
commentGenerator.addGeneralMethodComment(asc, introspectedTable);
innerEnum.addMethod(asc);
FormatTools.addMethodWithBestPosition(innerEnum, asc);
logger.debug("itfsw(数据Model属性对应Column获取插件):" + topLevelClass.getType().getShortName() + ".Column增加asc()和desc()方法。");
return innerEnum;
......
......@@ -16,10 +16,7 @@
package com.itfsw.mybatis.generator.plugins;
import com.itfsw.mybatis.generator.plugins.utils.BasePlugin;
import com.itfsw.mybatis.generator.plugins.utils.JavaElementGeneratorTools;
import com.itfsw.mybatis.generator.plugins.utils.PluginTools;
import com.itfsw.mybatis.generator.plugins.utils.XmlElementGeneratorTools;
import com.itfsw.mybatis.generator.plugins.utils.*;
import com.itfsw.mybatis.generator.plugins.utils.hook.IUpsertPluginHook;
import org.mybatis.generator.api.IntrospectedColumn;
import org.mybatis.generator.api.IntrospectedTable;
......@@ -96,7 +93,7 @@ public class UpsertPlugin extends BasePlugin {
);
commentGenerator.addGeneralMethodComment(mUpsert, introspectedTable);
// interface 增加方法
interfaze.addMethod(mUpsert);
FormatTools.addMethodWithBestPosition(interfaze, mUpsert);
logger.debug("itfsw(存在即更新插件):" + interfaze.getType().getShortName() + "增加upsert方法。");
// ====================================== upsertWithBLOBs ======================================
......@@ -110,7 +107,7 @@ public class UpsertPlugin extends BasePlugin {
);
commentGenerator.addGeneralMethodComment(mUpsertWithBLOBs, introspectedTable);
// interface 增加方法
interfaze.addMethod(mUpsertWithBLOBs);
FormatTools.addMethodWithBestPosition(interfaze, mUpsertWithBLOBs);
logger.debug("itfsw(存在即更新插件):" + interfaze.getType().getShortName() + "增加upsert方法。");
}
......@@ -127,7 +124,7 @@ public class UpsertPlugin extends BasePlugin {
// hook
if (PluginTools.getHook(IUpsertPluginHook.class).clientUpsertSelectiveMethodGenerated(mUpsertSelective, interfaze, introspectedTable)) {
// interface 增加方法
interfaze.addMethod(mUpsertSelective);
FormatTools.addMethodWithBestPosition(interfaze, mUpsertSelective);
logger.debug("itfsw(存在即更新插件):" + interfaze.getType().getShortName() + "增加upsertSelective方法。");
}
......@@ -142,7 +139,7 @@ public class UpsertPlugin extends BasePlugin {
);
commentGenerator.addGeneralMethodComment(mUpsertByExample, introspectedTable);
// interface 增加方法
interfaze.addMethod(mUpsertByExample);
FormatTools.addMethodWithBestPosition(interfaze, mUpsertByExample);
logger.debug("itfsw(存在即更新插件):" + interfaze.getType().getShortName() + "增加upsertByExample方法。");
// ====================================== upsertByExampleWithBLOBs ======================================
......@@ -157,7 +154,7 @@ public class UpsertPlugin extends BasePlugin {
);
commentGenerator.addGeneralMethodComment(mUpsertByExampleWithBLOBs, introspectedTable);
// interface 增加方法
interfaze.addMethod(mUpsertByExampleWithBLOBs);
FormatTools.addMethodWithBestPosition(interfaze, mUpsertByExampleWithBLOBs);
logger.debug("itfsw(存在即更新插件):" + interfaze.getType().getShortName() + "增加upsertByExample方法。");
}
......@@ -173,7 +170,7 @@ public class UpsertPlugin extends BasePlugin {
// hook
if (PluginTools.getHook(IUpsertPluginHook.class).clientUpsertByExampleSelectiveMethodGenerated(mUpsertByExampleSelective, interfaze, introspectedTable)) {
// interface 增加方法
interfaze.addMethod(mUpsertByExampleSelective);
FormatTools.addMethodWithBestPosition(interfaze, mUpsertByExampleSelective);
logger.debug("itfsw(存在即更新插件):" + interfaze.getType().getShortName() + "增加upsertByExampleSelective方法。");
}
}
......
......@@ -16,12 +16,10 @@
package com.itfsw.mybatis.generator.plugins.utils;
import com.itfsw.mybatis.generator.plugins.ModelColumnPlugin;
import org.mybatis.generator.api.CommentGenerator;
import org.mybatis.generator.api.IntrospectedTable;
import org.mybatis.generator.api.dom.java.InnerClass;
import org.mybatis.generator.api.dom.java.Interface;
import org.mybatis.generator.api.dom.java.Method;
import org.mybatis.generator.api.dom.java.TopLevelClass;
import org.mybatis.generator.api.dom.java.*;
import org.mybatis.generator.api.dom.xml.Attribute;
import org.mybatis.generator.api.dom.xml.Element;
import org.mybatis.generator.api.dom.xml.TextElement;
......@@ -29,6 +27,8 @@ import org.mybatis.generator.api.dom.xml.XmlElement;
import java.util.Iterator;
import java.util.List;
import java.util.Set;
import java.util.TreeSet;
/**
* ---------------------------------------------------------------------------
......@@ -54,9 +54,43 @@ public class FormatTools {
* @param method
*/
public static void addMethodWithBestPosition(Interface interfacz, Method method) {
// import
Set<FullyQualifiedJavaType> importTypes = new TreeSet<>();
// 返回
if (method.getReturnType() != null) {
importTypes.add(method.getReturnType());
importTypes.addAll(method.getReturnType().getTypeArguments());
}
// 参数 比较特殊的是ModelColumn生成的Column
for (Parameter parameter : method.getParameters()) {
boolean flag = true;
for (String annotation : parameter.getAnnotations()) {
if (annotation.startsWith("@Param")) {
importTypes.add(new FullyQualifiedJavaType("org.apache.ibatis.annotations.Param"));
if (annotation.matches(".*selective.*") && parameter.getType().getShortName().equals(ModelColumnPlugin.ENUM_NAME)) {
flag = false;
}
}
}
if (flag) {
importTypes.add(parameter.getType());
importTypes.addAll(parameter.getType().getTypeArguments());
}
}
interfacz.addImportedTypes(importTypes);
addMethodWithBestPosition(method, interfacz.getMethods());
}
/**
* 在最佳位置添加方法
* @param innerEnum
* @param method
*/
public static void addMethodWithBestPosition(InnerEnum innerEnum, Method method) {
addMethodWithBestPosition(method, innerEnum.getMethods());
}
/**
* 在最佳位置添加方法
* @param topLevelClass
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment