|
@@ -95,7 +95,7 @@ public class PropertyUpdateInterceptor implements Interceptor {
|
|
|
* @return 表达式实例
|
|
|
*/
|
|
|
private Expression datetime() {
|
|
|
- return new StringValue(DateUtils.DEFAULT_DATETIME_MILLIS_FORMATTER.format(LocalDateTime.now()));
|
|
|
+ return new StringValue(DateUtils.DEFAULT_TIMESTAMP_FORMATTER.format(LocalDateTime.now()));
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -177,8 +177,8 @@ public class PropertyUpdateInterceptor implements Interceptor {
|
|
|
}
|
|
|
|
|
|
// 设置创建人字段值
|
|
|
- boolean containCreator = this.isContains(insert.getColumns(), Expressions.CREATOR_COLUMN);
|
|
|
- if (!containCreator) {
|
|
|
+ boolean automaticCreator = !this.isContains(insert.getColumns(), Expressions.CREATOR_COLUMN);
|
|
|
+ if (automaticCreator) {
|
|
|
insert.addColumns(Expressions.CREATOR_COLUMN);
|
|
|
Expression operator = this.operator();
|
|
|
ItemsList items = insert.getItemsList();
|
|
@@ -190,8 +190,8 @@ public class PropertyUpdateInterceptor implements Interceptor {
|
|
|
}
|
|
|
|
|
|
// 设置创建时间字段值
|
|
|
- boolean containCreateTime = this.isContains(insert.getColumns(), Expressions.CREATE_TIME_COLUMN);
|
|
|
- if (!containCreateTime) {
|
|
|
+ boolean automaticCreateTime = !this.isContains(insert.getColumns(), Expressions.CREATE_TIME_COLUMN);
|
|
|
+ if (automaticCreateTime) {
|
|
|
insert.addColumns(Expressions.CREATE_TIME_COLUMN);
|
|
|
Expression datetime = this.datetime();
|
|
|
ItemsList items = insert.getItemsList();
|
|
@@ -201,7 +201,7 @@ public class PropertyUpdateInterceptor implements Interceptor {
|
|
|
((ExpressionList) items).getExpressions().add(datetime);
|
|
|
}
|
|
|
}
|
|
|
- return !(containCreator && containCreateTime);
|
|
|
+ return automaticCreator || automaticCreateTime;
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -217,8 +217,8 @@ public class PropertyUpdateInterceptor implements Interceptor {
|
|
|
}
|
|
|
|
|
|
// 设置更新人字段值
|
|
|
- boolean containUpdater = this.isContains(insert.getColumns(), Expressions.UPDATER_COLUMN);
|
|
|
- if (!containUpdater) {
|
|
|
+ boolean automaticUpdater = !this.isContains(insert.getColumns(), Expressions.UPDATER_COLUMN);
|
|
|
+ if (automaticUpdater) {
|
|
|
insert.addColumns(Expressions.UPDATER_COLUMN);
|
|
|
Expression operator = this.operator();
|
|
|
ItemsList items = insert.getItemsList();
|
|
@@ -230,8 +230,8 @@ public class PropertyUpdateInterceptor implements Interceptor {
|
|
|
}
|
|
|
|
|
|
// 设置更新时间字段值
|
|
|
- boolean containUpdateTime = this.isContains(insert.getColumns(), Expressions.UPDATE_TIME_COLUMN);
|
|
|
- if (!containUpdateTime) {
|
|
|
+ boolean automaticUpdateTime = !this.isContains(insert.getColumns(), Expressions.UPDATE_TIME_COLUMN);
|
|
|
+ if (automaticUpdateTime) {
|
|
|
insert.addColumns(Expressions.UPDATE_TIME_COLUMN);
|
|
|
Expression datetime = this.datetime();
|
|
|
ItemsList items = insert.getItemsList();
|
|
@@ -241,7 +241,7 @@ public class PropertyUpdateInterceptor implements Interceptor {
|
|
|
((ExpressionList) items).getExpressions().add(datetime);
|
|
|
}
|
|
|
}
|
|
|
- return !(containUpdater && containUpdateTime);
|
|
|
+ return automaticUpdater || automaticUpdateTime;
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -258,8 +258,10 @@ public class PropertyUpdateInterceptor implements Interceptor {
|
|
|
|
|
|
// 设置更新人字段值
|
|
|
Table table = update.getTable();
|
|
|
- boolean containUpdater = this.isContains(table, update.getColumns(), Expressions.UPDATER_COLUMN);
|
|
|
- if (!containUpdater) {
|
|
|
+ Expression operator = this.operator();
|
|
|
+ boolean automaticUpdater = operator != Expressions.NULL_VALUE
|
|
|
+ && !this.isContains(table, update.getColumns(), Expressions.UPDATER_COLUMN);
|
|
|
+ if (automaticUpdater) {
|
|
|
if (StringUtils.isEmpty(table.getAlias())) {
|
|
|
update.addColumns(Expressions.UPDATER_COLUMN);
|
|
|
} else {
|
|
@@ -269,8 +271,8 @@ public class PropertyUpdateInterceptor implements Interceptor {
|
|
|
}
|
|
|
|
|
|
// 设置更新时间字段值
|
|
|
- boolean containUpdateTime = this.isContains(table, update.getColumns(), Expressions.UPDATE_TIME_COLUMN);
|
|
|
- if (!containUpdateTime) {
|
|
|
+ boolean automaticUpdateTime = !this.isContains(table, update.getColumns(), Expressions.UPDATE_TIME_COLUMN);
|
|
|
+ if (automaticUpdateTime) {
|
|
|
if (StringUtils.isEmpty(table.getAlias())) {
|
|
|
update.addColumns(Expressions.UPDATE_TIME_COLUMN);
|
|
|
} else {
|
|
@@ -278,7 +280,7 @@ public class PropertyUpdateInterceptor implements Interceptor {
|
|
|
}
|
|
|
update.addExpressions(this.datetime());
|
|
|
}
|
|
|
- return !(containUpdater && containUpdateTime);
|
|
|
+ return automaticUpdater || automaticUpdateTime;
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -392,7 +394,7 @@ public class PropertyUpdateInterceptor implements Interceptor {
|
|
|
// 初始化参数默认值
|
|
|
Class<?> type = ObjectUtils.ifNull(table, TableInfo::getEntityType);
|
|
|
changed = type != null && (this.initializeCreatableValue(type, insert)
|
|
|
- || this.initializeUpdatableValue(type, insert) || this.initializeDeletableValue(type, insert));
|
|
|
+ | this.initializeUpdatableValue(type, insert) | this.initializeDeletableValue(type, insert));
|
|
|
} else if (statement instanceof Update) {
|
|
|
// 绑定参数TypeHandler
|
|
|
Update update = (Update) statement;
|