mirror of https://gitee.com/xiaonuobase/snowy
【通用】恢复插入的创建时间、更新时间
parent
ebcdd75204
commit
65ac41e50a
|
@ -21,6 +21,7 @@ import cn.dev33.satoken.router.SaRouter;
|
||||||
import cn.dev33.satoken.stp.StpUtil;
|
import cn.dev33.satoken.stp.StpUtil;
|
||||||
import cn.hutool.core.collection.CollectionUtil;
|
import cn.hutool.core.collection.CollectionUtil;
|
||||||
import cn.hutool.core.convert.Convert;
|
import cn.hutool.core.convert.Convert;
|
||||||
|
import cn.hutool.core.date.DateTime;
|
||||||
import cn.hutool.core.date.DateUtil;
|
import cn.hutool.core.date.DateUtil;
|
||||||
import cn.hutool.core.util.*;
|
import cn.hutool.core.util.*;
|
||||||
import cn.hutool.extra.spring.SpringUtil;
|
import cn.hutool.extra.spring.SpringUtil;
|
||||||
|
@ -80,8 +81,6 @@ import java.lang.reflect.Array;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import java.sql.Connection;
|
import java.sql.Connection;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
import java.time.LocalDateTime;
|
|
||||||
import java.time.format.DateTimeFormatter;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -612,9 +611,7 @@ public class GlobalConfigure implements WebMvcConfigurer {
|
||||||
//为空则设置createTime
|
//为空则设置createTime
|
||||||
Object createTime = metaObject.getValue(CREATE_TIME);
|
Object createTime = metaObject.getValue(CREATE_TIME);
|
||||||
if (ObjectUtil.isNull(createTime)) {
|
if (ObjectUtil.isNull(createTime)) {
|
||||||
LocalDateTime dt = LocalDateTime.now();
|
setFieldValByName(CREATE_TIME, DateTime.now(), metaObject);
|
||||||
String now = dt.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
|
|
||||||
setFieldValByName(CREATE_TIME, now, metaObject);
|
|
||||||
}
|
}
|
||||||
} catch (ReflectionException ignored) {
|
} catch (ReflectionException ignored) {
|
||||||
}
|
}
|
||||||
|
@ -629,9 +626,7 @@ public class GlobalConfigure implements WebMvcConfigurer {
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
//设置updateTime
|
//设置updateTime
|
||||||
LocalDateTime dt = LocalDateTime.now();
|
setFieldValByName(UPDATE_TIME, DateTime.now(), metaObject);
|
||||||
String now = dt.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
|
|
||||||
setFieldValByName(UPDATE_TIME, now, metaObject);
|
|
||||||
} catch (ReflectionException ignored) {
|
} catch (ReflectionException ignored) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue