Commit bfbae5f3 authored by hewei's avatar hewei

1. 代码精简;

2. 增加SelectiveEnhancedPlugin插件;
parent 1b151673
......@@ -125,7 +125,7 @@ public class BatchInsertOldPlugin extends PluginAdapter {
FullyQualifiedJavaType type1 = new FullyQualifiedJavaType(introspectedTable.getRules().calculateAllFieldsClass().getShortName()+"."+ModelColumnPlugin.ENUM_NAME);
method.addParameter(new Parameter(type1, "insertColumns", "@Param(\"insertColumns\")", true));
// 添加方法说明
CommentTools.addGeneralMethodComment(method, introspectedTable);
CommentTools.addMethodComment(method, introspectedTable);
// interface 增加方法
interfaze.addMethod(method);
......@@ -142,7 +142,7 @@ public class BatchInsertOldPlugin extends PluginAdapter {
type.addTypeArgument(introspectedTable.getRules().calculateAllFieldsClass());
method.addParameter(new Parameter(type, "list", "@Param(\"list\")"));
// 添加方法说明
CommentTools.addGeneralMethodComment(method, introspectedTable);
CommentTools.addMethodComment(method, introspectedTable);
// interface 增加方法
interfaze.addMethod(method);
......
......@@ -69,7 +69,7 @@ public class BatchInsertPlugin extends PluginAdapter {
// 插件使用前提是使用了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插件使用!");
return false;
}
......@@ -101,7 +101,7 @@ public class BatchInsertPlugin extends PluginAdapter {
tList.addTypeArgument(introspectedTable.getRules().calculateAllFieldsClass());
mBatchInsert.addParameter(new Parameter(tList, "list", "@Param(\"list\")"));
// 添加方法说明
CommentTools.addGeneralMethodComment(mBatchInsert, introspectedTable);
CommentTools.addMethodComment(mBatchInsert, introspectedTable);
// interface 增加方法
interfaze.addMethod(mBatchInsert);
logger.debug("itfsw(批量插入插件):" + interfaze.getType().getShortName() + "增加batchInsert方法。");
......@@ -114,7 +114,7 @@ public class BatchInsertPlugin extends PluginAdapter {
mBatchInsertSelective.addParameter(new Parameter(tList, "list", "@Param(\"list\")"));
mBatchInsertSelective.addParameter(new Parameter(tSelective, "selective", "@Param(\"selective\")", true));
// 添加方法说明
CommentTools.addGeneralMethodComment(mBatchInsertSelective, introspectedTable);
CommentTools.addMethodComment(mBatchInsertSelective, introspectedTable);
// interface 增加方法
interfaze.addMethod(mBatchInsertSelective);
logger.debug("itfsw(批量插入插件):" + interfaze.getType().getShortName() + "增加batchInsertSelective方法。");
......
......@@ -96,7 +96,7 @@ public class ExampleEnhancedPlugin extends PluginAdapter {
method.setVisibility(JavaVisibility.PUBLIC);
method.setReturnType(topLevelClass.getType());
method.addBodyLine("return this.example;");
CommentTools.addGeneralMethodComment(method, introspectedTable);
CommentTools.addMethodComment(method, introspectedTable);
innerClass.addMethod(method);
logger.debug("itfsw(Example增强插件):"+topLevelClass.getType().getShortName()+"."+innerClass.getType().getShortName()+"增加工厂方法example");
}
......@@ -120,7 +120,7 @@ public class ExampleEnhancedPlugin extends PluginAdapter {
Method addMethod = new Method("add");
addMethod.setReturnType(innerClass.getType());
addMethod.addParameter(new Parameter(innerClass.getType(), "add"));
CommentTools.addGeneralMethodComment(addMethod, introspectedTable);
CommentTools.addMethodComment(addMethod, introspectedTable);
criteriaAddInterface.addMethod(addMethod);
logger.debug("itfsw(Example增强插件):"+topLevelClass.getType().getShortName()+"."+innerClass.getType().getShortName()+"."+criteriaAddInterface.getType().getShortName()+"增加方法add");
......@@ -138,7 +138,7 @@ public class ExampleEnhancedPlugin extends PluginAdapter {
method.addBodyLine("add.add(this);");
method.addBodyLine("}");
method.addBodyLine("return this;");
CommentTools.addGeneralMethodComment(method, introspectedTable);
CommentTools.addMethodComment(method, introspectedTable);
innerClass.addMethod(method);
logger.debug("itfsw(Example增强插件):"+topLevelClass.getType().getShortName()+"."+innerClass.getType().getShortName()+"增加方法andIf");
}
......@@ -159,7 +159,7 @@ public class ExampleEnhancedPlugin extends PluginAdapter {
method.addBodyLine("this.setOrderByClause(orderByClause);");
method.addBodyLine("return this;");
CommentTools.addGeneralMethodComment(method, introspectedTable);
CommentTools.addMethodComment(method, introspectedTable);
topLevelClass.addMethod(method);
logger.debug("itfsw(Example增强插件):"+topLevelClass.getType().getShortName()+"增加方法orderBy");
......@@ -179,7 +179,7 @@ public class ExampleEnhancedPlugin extends PluginAdapter {
mOrderByMore.addBodyLine("this.setOrderByClause(sb.toString());");
mOrderByMore.addBodyLine("return this;");
CommentTools.addGeneralMethodComment(mOrderByMore, introspectedTable);
CommentTools.addMethodComment(mOrderByMore, introspectedTable);
topLevelClass.addMethod(mOrderByMore);
logger.debug("itfsw(Example增强插件):"+topLevelClass.getType().getShortName()+"增加方法orderBy(String ... orderByClauses)");
}
......
......@@ -90,7 +90,7 @@ public class LimitPlugin extends PluginAdapter {
setOffset.setName("setOffset");
setOffset.addParameter(new Parameter(integerWrapper, "offset"));
setOffset.addBodyLine("this.offset = offset;");
CommentTools.addGeneralMethodComment(setOffset, introspectedTable);
CommentTools.addMethodComment(setOffset, introspectedTable);
topLevelClass.addMethod(setOffset);
Method getOffset = new Method();
......@@ -98,7 +98,7 @@ public class LimitPlugin extends PluginAdapter {
getOffset.setReturnType(integerWrapper);
getOffset.setName("getOffset");
getOffset.addBodyLine("return offset;");
CommentTools.addGeneralMethodComment(getOffset, introspectedTable);
CommentTools.addMethodComment(getOffset, introspectedTable);
topLevelClass.addMethod(getOffset);
Method setRows = new Method();
......@@ -106,7 +106,7 @@ public class LimitPlugin extends PluginAdapter {
setRows.setName("setRows");
setRows.addParameter(new Parameter(integerWrapper, "rows"));
setRows.addBodyLine("this.rows = rows;");
CommentTools.addGeneralMethodComment(setRows, introspectedTable);
CommentTools.addMethodComment(setRows, introspectedTable);
topLevelClass.addMethod(setRows);
Method getRows = new Method();
......@@ -114,7 +114,7 @@ public class LimitPlugin extends PluginAdapter {
getRows.setReturnType(integerWrapper);
getRows.setName("getRows");
getRows.addBodyLine("return rows;");
CommentTools.addGeneralMethodComment(getRows, introspectedTable);
CommentTools.addMethodComment(getRows, introspectedTable);
topLevelClass.addMethod(getRows);
logger.debug("itfsw(MySQL分页插件):"+topLevelClass.getType().getShortName()+"增加offset和rows的getter和setter实现。");
......@@ -126,7 +126,7 @@ public class LimitPlugin extends PluginAdapter {
setLimit.addParameter(new Parameter(integerWrapper, "rows"));
setLimit.addBodyLine("this.rows = rows;");
setLimit.addBodyLine("return this;");
CommentTools.addGeneralMethodComment(setLimit, introspectedTable);
CommentTools.addMethodComment(setLimit, introspectedTable);
topLevelClass.addMethod(setLimit);
Method setLimit2 = new Method();
......@@ -138,7 +138,7 @@ public class LimitPlugin extends PluginAdapter {
setLimit2.addBodyLine("this.offset = offset;");
setLimit2.addBodyLine("this.rows = rows;");
setLimit2.addBodyLine("return this;");
CommentTools.addGeneralMethodComment(setLimit2, introspectedTable);
CommentTools.addMethodComment(setLimit2, introspectedTable);
topLevelClass.addMethod(setLimit2);
logger.debug("itfsw(MySQL分页插件):"+topLevelClass.getType().getShortName()+"增加limit方法。");
......@@ -151,7 +151,7 @@ public class LimitPlugin extends PluginAdapter {
setPage.addBodyLine("this.offset = page * pageSize;");
setPage.addBodyLine("this.rows = pageSize;");
setPage.addBodyLine("return this;");
CommentTools.addGeneralMethodComment(setPage, introspectedTable);
CommentTools.addMethodComment(setPage, introspectedTable);
topLevelClass.addMethod(setPage);
logger.debug("itfsw(MySQL分页插件):"+topLevelClass.getType().getShortName()+"增加page方法");
......
......@@ -146,7 +146,7 @@ public class LogicalDeletePlugin extends PluginAdapter {
FullyQualifiedJavaType type = new FullyQualifiedJavaType(introspectedTable.getExampleType());
mLogicalDeleteByExample.addParameter(new Parameter(type, "example"));
// 添加方法说明
CommentTools.addGeneralMethodComment(mLogicalDeleteByExample, introspectedTable);
CommentTools.addMethodComment(mLogicalDeleteByExample, introspectedTable);
// interface 增加方法
interfaze.addMethod(mLogicalDeleteByExample);
logger.debug("itfsw(逻辑删除插件):"+interfaze.getType().getShortName()+"增加方法logicalDeleteByExample。");
......@@ -191,7 +191,7 @@ public class LogicalDeletePlugin extends PluginAdapter {
}
// 添加方法说明
CommentTools.addGeneralMethodComment(mLogicalDeleteByPrimaryKey, introspectedTable);
CommentTools.addMethodComment(mLogicalDeleteByPrimaryKey, introspectedTable);
// interface 增加方法
interfaze.addImportedTypes(importedTypes);
interfaze.addMethod(mLogicalDeleteByPrimaryKey);
......@@ -375,7 +375,7 @@ public class LogicalDeletePlugin extends PluginAdapter {
if ("Criteria".equals(innerClass.getType().getShortName())) {
// 增加逻辑删除条件
Method method = new Method(METHOD_LOGICAL_DELETE);
CommentTools.addGeneralMethodComment(method, introspectedTable);
CommentTools.addMethodComment(method, introspectedTable);
method.setVisibility(JavaVisibility.PUBLIC);
method.setReturnType(innerClass.getType());
method.addParameter(new Parameter(FullyQualifiedJavaType.getBooleanPrimitiveInstance(), "deleted"));
......
......@@ -83,7 +83,7 @@ public class ModelBuilderPlugin extends PluginAdapter {
constructor.setVisibility(JavaVisibility.PUBLIC);
constructor.setConstructor(true);
constructor.addBodyLine(new StringBuilder("this.obj = new ").append(topLevelClass.getType().getShortName()).append("();").toString());
CommentTools.addGeneralMethodComment(constructor, introspectedTable);
CommentTools.addMethodComment(constructor, introspectedTable);
innerClass.addMethod(constructor);
logger.debug("itfsw(数据Model链式构建插件):"+topLevelClass.getType().getShortName()+".Builder增加的构造方法。");
......@@ -100,7 +100,7 @@ public class ModelBuilderPlugin extends PluginAdapter {
method.addBodyLine(new StringBuilder().append("obj.").append(setterMethod.getName())
.append("(").append(field.getName()).append(");").toString());
method.addBodyLine(new StringBuilder().append("return this;").toString());
CommentTools.addGeneralMethodComment(method, introspectedTable);
CommentTools.addMethodComment(method, introspectedTable);
innerClass.addMethod(method);
logger.debug("itfsw(数据Model链式构建插件):"+topLevelClass.getType().getShortName()+".Builder增加"+method.getName()+"方法(复合主键)。");
}
......@@ -118,7 +118,7 @@ public class ModelBuilderPlugin extends PluginAdapter {
method.addBodyLine(new StringBuilder().append("obj.").append(field.getName())
.append(" = ").append(field.getName()).append(";").toString());
method.addBodyLine(new StringBuilder().append("return this;").toString());
CommentTools.addGeneralMethodComment(method, introspectedTable);
CommentTools.addMethodComment(method, introspectedTable);
innerClass.addMethod(method);
logger.debug("itfsw(数据Model链式构建插件):"+topLevelClass.getType().getShortName()+".Builder增加"+method.getName()+"方法。");
}
......@@ -127,7 +127,7 @@ public class ModelBuilderPlugin extends PluginAdapter {
build.setReturnType(topLevelClass.getType());
build.setVisibility(JavaVisibility.PUBLIC);
build.addBodyLine("return this.obj;");
CommentTools.addGeneralMethodComment(build, introspectedTable);
CommentTools.addMethodComment(build, introspectedTable);
innerClass.addMethod(build);
logger.debug("itfsw(数据Model链式构建插件):"+topLevelClass.getType().getShortName()+".Builder增加build方法。");
......
......@@ -82,21 +82,21 @@ public class ModelColumnPlugin extends PluginAdapter {
mValue.setVisibility(JavaVisibility.PUBLIC);
mValue.setReturnType(FullyQualifiedJavaType.getStringInstance());
mValue.addBodyLine("return this.column;");
CommentTools.addGeneralMethodComment(mValue, introspectedTable);
CommentTools.addMethodComment(mValue, introspectedTable);
innerEnum.addMethod(mValue);
Method mGetValue = new Method("getValue");
mGetValue.setVisibility(JavaVisibility.PUBLIC);
mGetValue.setReturnType(FullyQualifiedJavaType.getStringInstance());
mGetValue.addBodyLine("return this.column;");
CommentTools.addGeneralMethodComment(mGetValue, introspectedTable);
CommentTools.addMethodComment(mGetValue, introspectedTable);
innerEnum.addMethod(mGetValue);
Method constructor = new Method(ENUM_NAME);
constructor.setConstructor(true);
constructor.addBodyLine("this.column = column;");
constructor.addParameter(new Parameter(FullyQualifiedJavaType.getStringInstance(), "column"));
CommentTools.addGeneralMethodComment(constructor, introspectedTable);
CommentTools.addMethodComment(constructor, introspectedTable);
innerEnum.addMethod(constructor);
logger.debug("itfsw(数据Model属性对应Column获取插件):" + topLevelClass.getType().getShortName() + ".Column增加构造方法和column属性。");
......@@ -119,14 +119,14 @@ public class ModelColumnPlugin extends PluginAdapter {
desc.setVisibility(JavaVisibility.PUBLIC);
desc.setReturnType(FullyQualifiedJavaType.getStringInstance());
desc.addBodyLine("return this.column + \" DESC\";");
CommentTools.addGeneralMethodComment(desc, introspectedTable);
CommentTools.addMethodComment(desc, introspectedTable);
innerEnum.addMethod(desc);
Method asc = new Method("asc");
asc.setVisibility(JavaVisibility.PUBLIC);
asc.setReturnType(FullyQualifiedJavaType.getStringInstance());
asc.addBodyLine("return this.column + \" ASC\";");
CommentTools.addGeneralMethodComment(asc, introspectedTable);
CommentTools.addMethodComment(asc, introspectedTable);
innerEnum.addMethod(asc);
logger.debug("itfsw(数据Model属性对应Column获取插件):" + topLevelClass.getType().getShortName() + ".Column增加asc()和desc()方法。");
......
......@@ -80,7 +80,7 @@ public class SelectOneByExamplePlugin extends PluginAdapter {
FullyQualifiedJavaType type = new FullyQualifiedJavaType(introspectedTable.getExampleType());
method.addParameter(new Parameter(type, "example"));
// 添加方法说明
CommentTools.addGeneralMethodComment(method, introspectedTable);
CommentTools.addMethodComment(method, introspectedTable);
// interface 增加方法
interfaze.addMethod(method);
......
......@@ -16,15 +16,20 @@
package com.itfsw.mybatis.generator.plugins;
import com.itfsw.mybatis.generator.plugins.utils.CommentTools;
import com.itfsw.mybatis.generator.plugins.utils.PluginTools;
import org.mybatis.generator.api.IntrospectedTable;
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.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.ArrayList;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
/**
* ---------------------------------------------------------------------------
......@@ -49,7 +54,7 @@ public class SelectiveEnhancedPlugin extends PluginAdapter {
}
// 插件使用前提是使用了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插件使用!");
return false;
}
......@@ -66,7 +71,154 @@ public class SelectiveEnhancedPlugin extends PluginAdapter {
*/
@Override
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;
}
/**
* 查找当前节点下的指定节点
* @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);
}
}
......@@ -98,7 +98,7 @@ public class UpsertPlugin extends PluginAdapter {
// 添加参数
mUpsert.addParameter(new Parameter(introspectedTable.getRules().calculateAllFieldsClass(), "record"));
// 添加方法说明
CommentTools.addGeneralMethodComment(mUpsert, introspectedTable);
CommentTools.addMethodComment(mUpsert, introspectedTable);
// interface 增加方法
interfaze.addMethod(mUpsert);
logger.debug("itfsw(存在即更新插件):" + interfaze.getType().getShortName() + "增加upsert方法。");
......@@ -110,7 +110,7 @@ public class UpsertPlugin extends PluginAdapter {
// 添加参数
mUpsertSelective.addParameter(new Parameter(introspectedTable.getRules().calculateAllFieldsClass(), "record"));
// 添加方法说明
CommentTools.addGeneralMethodComment(mUpsertSelective, introspectedTable);
CommentTools.addMethodComment(mUpsertSelective, introspectedTable);
// interface 增加方法
interfaze.addMethod(mUpsertSelective);
logger.debug("itfsw(存在即更新插件):" + interfaze.getType().getShortName() + "增加upsertSelective方法。");
......@@ -124,7 +124,7 @@ public class UpsertPlugin extends PluginAdapter {
mUpsertByExample.addParameter(new Parameter(introspectedTable.getRules().calculateAllFieldsClass(), "record", "@Param(\"record\")"));
mUpsertByExample.addParameter(new Parameter(new FullyQualifiedJavaType(introspectedTable.getExampleType()), "example", "@Param(\"example\")"));
// 添加方法说明
CommentTools.addGeneralMethodComment(mUpsertByExample, introspectedTable);
CommentTools.addMethodComment(mUpsertByExample, introspectedTable);
// interface 增加方法
interfaze.addMethod(mUpsertByExample);
logger.debug("itfsw(存在即更新插件):" + interfaze.getType().getShortName() + "增加upsertByExample方法。");
......@@ -137,7 +137,7 @@ public class UpsertPlugin extends PluginAdapter {
mUpsertByExampleSelective.addParameter(new Parameter(introspectedTable.getRules().calculateAllFieldsClass(), "record", "@Param(\"record\")"));
mUpsertByExampleSelective.addParameter(new Parameter(new FullyQualifiedJavaType(introspectedTable.getExampleType()), "example", "@Param(\"example\")"));
// 添加方法说明
CommentTools.addGeneralMethodComment(mUpsertByExampleSelective, introspectedTable);
CommentTools.addMethodComment(mUpsertByExampleSelective, introspectedTable);
// interface 增加方法
interfaze.addMethod(mUpsertByExampleSelective);
logger.debug("itfsw(存在即更新插件):" + interfaze.getType().getShortName() + "增加upsertByExampleSelective方法。");
......
......@@ -99,7 +99,7 @@ public class CommentTools {
* @param method 方法
* @param introspectedTable 表
*/
public static void addGeneralMethodComment(Method method, IntrospectedTable introspectedTable) {
public static void addMethodComment(Method method, IntrospectedTable introspectedTable) {
StringBuilder sb = new StringBuilder();
method.addJavaDocLine("/**");
method.addJavaDocLine(" * 这是Mybatis Generator拓展插件生成的方法(请勿删除).");
......
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