Commit c485d7be authored by hewei's avatar hewei

统一命名格式

parent 03116e71
...@@ -29,7 +29,7 @@ import java.util.Properties; ...@@ -29,7 +29,7 @@ import java.util.Properties;
* --------------------------------------------------------------------------- * ---------------------------------------------------------------------------
*/ */
public class CommentPlugin extends BasePlugin { public class CommentPlugin extends BasePlugin {
public static final String PRE_TEMPLATE = "template"; // 模板 property public static final String PRO_TEMPLATE = "template"; // 模板 property
/** /**
* 插件具体实现查看BasePlugin * 插件具体实现查看BasePlugin
......
...@@ -35,7 +35,7 @@ import java.util.Properties; ...@@ -35,7 +35,7 @@ import java.util.Properties;
* --------------------------------------------------------------------------- * ---------------------------------------------------------------------------
*/ */
public class ExampleTargetPlugin extends BasePlugin { public class ExampleTargetPlugin extends BasePlugin {
public static final String TARGET_PACKAGE_KEY = "targetPackage"; // 配置targetPackage名 public static final String PRO_TARGET_PACKAGE = "targetPackage"; // 配置targetPackage名
private static String targetPackage; // 目标包 private static String targetPackage; // 目标包
/** /**
...@@ -45,7 +45,7 @@ public class ExampleTargetPlugin extends BasePlugin { ...@@ -45,7 +45,7 @@ public class ExampleTargetPlugin extends BasePlugin {
public boolean validate(List<String> warnings) { public boolean validate(List<String> warnings) {
// 获取配置的目标package // 获取配置的目标package
Properties properties = getProperties(); Properties properties = getProperties();
this.targetPackage = properties.getProperty(TARGET_PACKAGE_KEY); this.targetPackage = properties.getProperty(PRO_TARGET_PACKAGE);
if (this.targetPackage == null){ if (this.targetPackage == null){
warnings.add("请配置com.itfsw.mybatis.generator.plugins.ExampleTargetPlugin插件的目标包名(targetPackage)!"); warnings.add("请配置com.itfsw.mybatis.generator.plugins.ExampleTargetPlugin插件的目标包名(targetPackage)!");
return false; return false;
......
...@@ -36,7 +36,7 @@ import java.util.List; ...@@ -36,7 +36,7 @@ import java.util.List;
* --------------------------------------------------------------------------- * ---------------------------------------------------------------------------
*/ */
public class IncrementsPlugin extends BasePlugin { public class IncrementsPlugin extends BasePlugin {
public static final String PRE_INCREMENTS_COLUMNS = "incrementsColumns"; // incrementsColumns property public static final String PRO_INCREMENTS_COLUMNS = "incrementsColumns"; // incrementsColumns property
public static final String FIELD_INC_MAP = "incrementsColumnsInfoMap"; // 为了防止和用户数据库字段冲突,特殊命名 public static final String FIELD_INC_MAP = "incrementsColumnsInfoMap"; // 为了防止和用户数据库字段冲突,特殊命名
public static final String METHOD_INC_CHECK = "hasIncsForColumn"; // inc 检查方法名称 public static final String METHOD_INC_CHECK = "hasIncsForColumn"; // inc 检查方法名称
private IncrementsPluginTools incTools; // 增量插件工具 private IncrementsPluginTools incTools; // 增量插件工具
......
...@@ -43,9 +43,9 @@ public class LogicalDeletePlugin extends BasePlugin { ...@@ -43,9 +43,9 @@ public class LogicalDeletePlugin extends BasePlugin {
public static final String METHOD_LOGICAL_DELETE_BY_EXAMPLE = "logicalDeleteByExample"; // 方法名 public static final String METHOD_LOGICAL_DELETE_BY_EXAMPLE = "logicalDeleteByExample"; // 方法名
public static final String METHOD_LOGICAL_DELETE_BY_PRIMARY_KEY = "logicalDeleteByPrimaryKey"; // 方法名 public static final String METHOD_LOGICAL_DELETE_BY_PRIMARY_KEY = "logicalDeleteByPrimaryKey"; // 方法名
public static final String LOGICAL_DELETE_COLUMN_KEY = "logicalDeleteColumn"; // 逻辑删除列-Key public static final String PRO_LOGICAL_DELETE_COLUMN = "logicalDeleteColumn"; // 逻辑删除列-Key
public static final String LOGICAL_DELETE_VALUE_KEY = "logicalDeleteValue"; // 逻辑删除值-Key public static final String PRO_LOGICAL_DELETE_VALUE = "logicalDeleteValue"; // 逻辑删除值-Key
public static final String LOGICAL_UN_DELETE_VALUE_KEY = "logicalUnDeleteValue"; // 逻辑删除未删除值-Key public static final String PRO_LOGICAL_UN_DELETE_VALUE = "logicalUnDeleteValue"; // 逻辑删除未删除值-Key
public static final String DEL_FLAG_NAME = "DEL_FLAG_OFF"; // 逻辑删除标志位常量名称 public static final String DEL_FLAG_NAME = "DEL_FLAG_OFF"; // 逻辑删除标志位常量名称
public static final String UN_DEL_FLAG_NAME = "DEL_FLAG_ON"; // 逻辑删除标志位常量名称(未删除) public static final String UN_DEL_FLAG_NAME = "DEL_FLAG_ON"; // 逻辑删除标志位常量名称(未删除)
...@@ -67,18 +67,18 @@ public class LogicalDeletePlugin extends BasePlugin { ...@@ -67,18 +67,18 @@ public class LogicalDeletePlugin extends BasePlugin {
public void initialized(IntrospectedTable introspectedTable) { public void initialized(IntrospectedTable introspectedTable) {
// 1. 首先获取全局配置 // 1. 首先获取全局配置
Properties properties = getProperties(); Properties properties = getProperties();
String logicalDeleteColumn = properties.getProperty(LOGICAL_DELETE_COLUMN_KEY); String logicalDeleteColumn = properties.getProperty(PRO_LOGICAL_DELETE_COLUMN);
this.logicalDeleteValue = properties.getProperty(LOGICAL_DELETE_VALUE_KEY); this.logicalDeleteValue = properties.getProperty(PRO_LOGICAL_DELETE_VALUE);
this.logicalUnDeleteValue = properties.getProperty(LOGICAL_UN_DELETE_VALUE_KEY); this.logicalUnDeleteValue = properties.getProperty(PRO_LOGICAL_UN_DELETE_VALUE);
// 2. 获取表单独配置,如果有则覆盖全局配置 // 2. 获取表单独配置,如果有则覆盖全局配置
if (introspectedTable.getTableConfigurationProperty(LOGICAL_DELETE_COLUMN_KEY) != null){ if (introspectedTable.getTableConfigurationProperty(PRO_LOGICAL_DELETE_COLUMN) != null){
logicalDeleteColumn = introspectedTable.getTableConfigurationProperty(LOGICAL_DELETE_COLUMN_KEY); logicalDeleteColumn = introspectedTable.getTableConfigurationProperty(PRO_LOGICAL_DELETE_COLUMN);
} }
if (introspectedTable.getTableConfigurationProperty(LOGICAL_DELETE_VALUE_KEY) != null){ if (introspectedTable.getTableConfigurationProperty(PRO_LOGICAL_DELETE_VALUE) != null){
this.logicalDeleteValue = introspectedTable.getTableConfigurationProperty(LOGICAL_DELETE_VALUE_KEY); this.logicalDeleteValue = introspectedTable.getTableConfigurationProperty(PRO_LOGICAL_DELETE_VALUE);
} }
if (introspectedTable.getTableConfigurationProperty(LOGICAL_UN_DELETE_VALUE_KEY) != null){ if (introspectedTable.getTableConfigurationProperty(PRO_LOGICAL_UN_DELETE_VALUE) != null){
this.logicalUnDeleteValue = introspectedTable.getTableConfigurationProperty(LOGICAL_UN_DELETE_VALUE_KEY); this.logicalUnDeleteValue = introspectedTable.getTableConfigurationProperty(PRO_LOGICAL_UN_DELETE_VALUE);
} }
// 3. 判断该表是否存在逻辑删除列 // 3. 判断该表是否存在逻辑删除列
this.logicalDeleteColumn = null; this.logicalDeleteColumn = null;
...@@ -105,13 +105,13 @@ public class LogicalDeletePlugin extends BasePlugin { ...@@ -105,13 +105,13 @@ public class LogicalDeletePlugin extends BasePlugin {
|| JDBCType.VARCHAR == type){ || JDBCType.VARCHAR == type){
this.logicalDeleteColumn = column; this.logicalDeleteColumn = column;
} else { } else {
warnings.add("itfsw(逻辑删除插件):"+introspectedTable.getFullyQualifiedTable()+"逻辑删除列("+introspectedTable.getTableConfigurationProperty(LOGICAL_DELETE_COLUMN_KEY)+")的类型不在支持范围(请使用数字列,字符串列,布尔列)!"); warnings.add("itfsw(逻辑删除插件):"+introspectedTable.getFullyQualifiedTable()+"逻辑删除列("+introspectedTable.getTableConfigurationProperty(PRO_LOGICAL_DELETE_COLUMN)+")的类型不在支持范围(请使用数字列,字符串列,布尔列)!");
} }
} }
} }
if (introspectedTable.getTableConfigurationProperty(LOGICAL_DELETE_COLUMN_KEY) != null && this.logicalDeleteColumn == null){ if (introspectedTable.getTableConfigurationProperty(PRO_LOGICAL_DELETE_COLUMN) != null && this.logicalDeleteColumn == null){
warnings.add("itfsw(逻辑删除插件):"+introspectedTable.getFullyQualifiedTable()+"没有找到您配置的逻辑删除列("+introspectedTable.getTableConfigurationProperty(LOGICAL_DELETE_COLUMN_KEY)+")!"); warnings.add("itfsw(逻辑删除插件):"+introspectedTable.getFullyQualifiedTable()+"没有找到您配置的逻辑删除列("+introspectedTable.getTableConfigurationProperty(PRO_LOGICAL_DELETE_COLUMN)+")!");
} }
// 4. 判断逻辑删除值是否配置了 // 4. 判断逻辑删除值是否配置了
......
...@@ -33,7 +33,7 @@ import java.util.List; ...@@ -33,7 +33,7 @@ import java.util.List;
*/ */
public class TablePrefixPlugin extends BasePlugin { public class TablePrefixPlugin extends BasePlugin {
public static final String PRE_PREFIX = "prefix"; // 前缀 property public static final String PRO_PREFIX = "prefix"; // 前缀 property
private String prefix; // 前缀 private String prefix; // 前缀
/** /**
...@@ -62,14 +62,14 @@ public class TablePrefixPlugin extends BasePlugin { ...@@ -62,14 +62,14 @@ public class TablePrefixPlugin extends BasePlugin {
@Override @Override
public void initialized(IntrospectedTable introspectedTable) { public void initialized(IntrospectedTable introspectedTable) {
// 1. 首先获取全局配置 // 1. 首先获取全局配置
this.prefix = getProperties().getProperty(PRE_PREFIX); this.prefix = getProperties().getProperty(PRO_PREFIX);
// 2. 获取每个table 具体的 // 2. 获取每个table 具体的
if (introspectedTable.getTableConfigurationProperty(PRE_PREFIX) != null) { if (introspectedTable.getTableConfigurationProperty(PRO_PREFIX) != null) {
this.prefix = introspectedTable.getTableConfigurationProperty(PRE_PREFIX); this.prefix = introspectedTable.getTableConfigurationProperty(PRO_PREFIX);
} }
// 3. 判断是否配置了前缀 // 3. 判断是否配置了前缀
// !!! TableRenamePlugin 插件的 tableOverride 优先级最高 // !!! TableRenamePlugin 插件的 tableOverride 优先级最高
if (this.prefix != null && introspectedTable.getTableConfigurationProperty(TableRenamePlugin.PRE_TABLE_OVERRIDE) == null) { if (this.prefix != null && introspectedTable.getTableConfigurationProperty(TableRenamePlugin.PRO_TABLE_OVERRIDE) == null) {
String domainObjectName = introspectedTable.getFullyQualifiedTable().getDomainObjectName(); String domainObjectName = introspectedTable.getFullyQualifiedTable().getDomainObjectName();
domainObjectName = prefix + domainObjectName; domainObjectName = prefix + domainObjectName;
try { try {
......
...@@ -34,9 +34,9 @@ import java.util.regex.Pattern; ...@@ -34,9 +34,9 @@ import java.util.regex.Pattern;
* --------------------------------------------------------------------------- * ---------------------------------------------------------------------------
*/ */
public class TableRenamePlugin extends BasePlugin { public class TableRenamePlugin extends BasePlugin {
public static final String PRE_SEARCH_STRING = "searchString"; // 查找 property public static final String PRO_SEARCH_STRING = "searchString"; // 查找 property
public static final String PRE_REPLACE_STRING = "replaceString"; // 替换 property public static final String PRO_REPLACE_STRING = "replaceString"; // 替换 property
public static final String PRE_TABLE_OVERRIDE = "tableOverride"; // table 重命名 property public static final String PRO_TABLE_OVERRIDE = "tableOverride"; // table 重命名 property
/** /**
* {@inheritDoc} * {@inheritDoc}
...@@ -45,8 +45,8 @@ public class TableRenamePlugin extends BasePlugin { ...@@ -45,8 +45,8 @@ public class TableRenamePlugin extends BasePlugin {
public boolean validate(List<String> warnings) { public boolean validate(List<String> warnings) {
// 如果配置了searchString 或者 replaceString,二者不允许单独存在 // 如果配置了searchString 或者 replaceString,二者不允许单独存在
if ((getProperties().getProperty(PRE_SEARCH_STRING) == null && getProperties().getProperty(PRE_REPLACE_STRING) != null) if ((getProperties().getProperty(PRO_SEARCH_STRING) == null && getProperties().getProperty(PRO_REPLACE_STRING) != null)
|| (getProperties().getProperty(PRE_SEARCH_STRING) != null && getProperties().getProperty(PRE_REPLACE_STRING) == null)) { || (getProperties().getProperty(PRO_SEARCH_STRING) != null && getProperties().getProperty(PRO_REPLACE_STRING) == null)) {
warnings.add("itfsw:插件" + this.getClass().getTypeName() + "插件的searchString、replaceString属性需配合使用,不能单独存在!"); warnings.add("itfsw:插件" + this.getClass().getTypeName() + "插件的searchString、replaceString属性需配合使用,不能单独存在!");
return false; return false;
} }
...@@ -71,16 +71,16 @@ public class TableRenamePlugin extends BasePlugin { ...@@ -71,16 +71,16 @@ public class TableRenamePlugin extends BasePlugin {
@Override @Override
public void initialized(IntrospectedTable introspectedTable) { public void initialized(IntrospectedTable introspectedTable) {
// 1. 获取表单独配置 // 1. 获取表单独配置
if (introspectedTable.getTableConfigurationProperty(PRE_TABLE_OVERRIDE) != null) { if (introspectedTable.getTableConfigurationProperty(PRO_TABLE_OVERRIDE) != null) {
String override = introspectedTable.getTableConfigurationProperty(PRE_TABLE_OVERRIDE); String override = introspectedTable.getTableConfigurationProperty(PRO_TABLE_OVERRIDE);
try { try {
IntrospectedTableTools.setDomainObjectName(introspectedTable, getContext(), override); IntrospectedTableTools.setDomainObjectName(introspectedTable, getContext(), override);
} catch (Exception e) { } catch (Exception e) {
logger.error("itfsw:插件" + this.getClass().getTypeName() + "使用tableOverride替换时异常!", e); logger.error("itfsw:插件" + this.getClass().getTypeName() + "使用tableOverride替换时异常!", e);
} }
} else if (getProperties().getProperty(PRE_SEARCH_STRING) != null) { } else if (getProperties().getProperty(PRO_SEARCH_STRING) != null) {
String searchString = getProperties().getProperty(PRE_SEARCH_STRING); String searchString = getProperties().getProperty(PRO_SEARCH_STRING);
String replaceString = getProperties().getProperty(PRE_REPLACE_STRING); String replaceString = getProperties().getProperty(PRO_REPLACE_STRING);
String domainObjectName = introspectedTable.getFullyQualifiedTable().getDomainObjectName(); String domainObjectName = introspectedTable.getFullyQualifiedTable().getDomainObjectName();
Pattern pattern = Pattern.compile(searchString); Pattern pattern = Pattern.compile(searchString);
......
...@@ -46,7 +46,7 @@ public class UpsertPlugin extends BasePlugin { ...@@ -46,7 +46,7 @@ public class UpsertPlugin extends BasePlugin {
public static final String METHOD_UPSERT_BY_EXAMPLE_SELECTIVE = "upsertByExampleSelective"; // 方法名 public static final String METHOD_UPSERT_BY_EXAMPLE_SELECTIVE = "upsertByExampleSelective"; // 方法名
public static final String PRE_ALLOW_MULTI_QUERIES = "allowMultiQueries"; // property allowMultiQueries public static final String PRO_ALLOW_MULTI_QUERIES = "allowMultiQueries"; // property allowMultiQueries
private boolean allowMultiQueries = false; // 是否允许多sql提交 private boolean allowMultiQueries = false; // 是否允许多sql提交
/** /**
...@@ -63,7 +63,7 @@ public class UpsertPlugin extends BasePlugin { ...@@ -63,7 +63,7 @@ public class UpsertPlugin extends BasePlugin {
// 插件是否开启了多sql提交 // 插件是否开启了多sql提交
Properties properties = this.getProperties(); Properties properties = this.getProperties();
String allowMultiQueries = properties.getProperty(PRE_ALLOW_MULTI_QUERIES); String allowMultiQueries = properties.getProperty(PRO_ALLOW_MULTI_QUERIES);
this.allowMultiQueries = allowMultiQueries == null ? false : StringUtility.isTrue(allowMultiQueries); this.allowMultiQueries = allowMultiQueries == null ? false : StringUtility.isTrue(allowMultiQueries);
if (this.allowMultiQueries) { if (this.allowMultiQueries) {
// 提示用户注意信息 // 提示用户注意信息
......
...@@ -56,7 +56,7 @@ public class BasePlugin extends PluginAdapter { ...@@ -56,7 +56,7 @@ public class BasePlugin extends PluginAdapter {
// 配置插件使用的模板引擎 // 配置插件使用的模板引擎
PluginConfiguration cfg = PluginTools.getPluginConfiguration(context, CommentPlugin.class); PluginConfiguration cfg = PluginTools.getPluginConfiguration(context, CommentPlugin.class);
if (cfg == null || cfg.getProperty(CommentPlugin.PRE_TEMPLATE) == null){ if (cfg == null || cfg.getProperty(CommentPlugin.PRO_TEMPLATE) == null){
if (context.getCommentGenerator() instanceof DefaultCommentGenerator){ if (context.getCommentGenerator() instanceof DefaultCommentGenerator){
// 使用默认模板引擎 // 使用默认模板引擎
commentGenerator = new TemplateCommentGenerator("default-comment.ftl", true); commentGenerator = new TemplateCommentGenerator("default-comment.ftl", true);
...@@ -65,7 +65,7 @@ public class BasePlugin extends PluginAdapter { ...@@ -65,7 +65,7 @@ public class BasePlugin extends PluginAdapter {
commentGenerator = context.getCommentGenerator(); commentGenerator = context.getCommentGenerator();
} }
} else { } else {
TemplateCommentGenerator templateCommentGenerator = new TemplateCommentGenerator(cfg.getProperty(CommentPlugin.PRE_TEMPLATE), false); TemplateCommentGenerator templateCommentGenerator = new TemplateCommentGenerator(cfg.getProperty(CommentPlugin.PRO_TEMPLATE), false);
// ITFSW 插件使用的注释生成器 // ITFSW 插件使用的注释生成器
commentGenerator = templateCommentGenerator; commentGenerator = templateCommentGenerator;
......
...@@ -69,7 +69,7 @@ public class IncrementsPluginTools { ...@@ -69,7 +69,7 @@ public class IncrementsPluginTools {
IncrementsPluginTools tools = new IncrementsPluginTools(context, introspectedTable); IncrementsPluginTools tools = new IncrementsPluginTools(context, introspectedTable);
// 判断是否启用了插件 // 判断是否启用了插件
if (PluginTools.getPluginConfiguration(context, IncrementsPlugin.class) != null) { if (PluginTools.getPluginConfiguration(context, IncrementsPlugin.class) != null) {
String incrementsColumns = introspectedTable.getTableConfigurationProperty(IncrementsPlugin.PRE_INCREMENTS_COLUMNS); String incrementsColumns = introspectedTable.getTableConfigurationProperty(IncrementsPlugin.PRO_INCREMENTS_COLUMNS);
if (StringUtility.stringHasValue(incrementsColumns)) { if (StringUtility.stringHasValue(incrementsColumns)) {
// 切分 // 切分
String[] incrementsColumnsStrs = incrementsColumns.split(","); String[] incrementsColumnsStrs = incrementsColumns.split(",");
......
...@@ -71,12 +71,12 @@ public class IntrospectedTableTools { ...@@ -71,12 +71,12 @@ public class IntrospectedTableTools {
// 注意!! 如果配置了ExampleTargetPlugin插件,要修正Example 位置 // 注意!! 如果配置了ExampleTargetPlugin插件,要修正Example 位置
PluginConfiguration configuration = PluginTools.getPluginConfiguration(context, ExampleTargetPlugin.class); PluginConfiguration configuration = PluginTools.getPluginConfiguration(context, ExampleTargetPlugin.class);
if (configuration != null && configuration.getProperty(ExampleTargetPlugin.TARGET_PACKAGE_KEY) != null) { if (configuration != null && configuration.getProperty(ExampleTargetPlugin.PRO_TARGET_PACKAGE) != null) {
String exampleType = introspectedTable.getExampleType(); String exampleType = introspectedTable.getExampleType();
// 修改包名 // 修改包名
JavaModelGeneratorConfiguration javaModelGeneratorConfiguration = context.getJavaModelGeneratorConfiguration(); JavaModelGeneratorConfiguration javaModelGeneratorConfiguration = context.getJavaModelGeneratorConfiguration();
String targetPackage = javaModelGeneratorConfiguration.getTargetPackage(); String targetPackage = javaModelGeneratorConfiguration.getTargetPackage();
String newExampleType = exampleType.replace(targetPackage, configuration.getProperty(ExampleTargetPlugin.TARGET_PACKAGE_KEY)); String newExampleType = exampleType.replace(targetPackage, configuration.getProperty(ExampleTargetPlugin.PRO_TARGET_PACKAGE));
introspectedTable.setExampleType(newExampleType); introspectedTable.setExampleType(newExampleType);
} }
......
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