Commit c485d7be authored by hewei's avatar hewei

统一命名格式

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