highgo
This commit is contained in:
@@ -8,6 +8,8 @@ import com.ruoyi.common.utils.spring.SpringUtils;
|
||||
import org.apache.ibatis.reflection.MetaObject;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.Date;
|
||||
import java.util.Objects;
|
||||
|
||||
@@ -30,19 +32,20 @@ public class FieldMetaObjectConfig implements MetaObjectHandler {
|
||||
@Override
|
||||
public void insertFill(MetaObject metaObject) {
|
||||
|
||||
Date date = new Date();
|
||||
LocalDateTime now = LocalDateTime.now();
|
||||
String formattedDate = now.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
|
||||
if(SecurityUtils.isLogin()) {
|
||||
LoginUser loginUser = SecurityUtils.getLoginUser();
|
||||
// 创建者
|
||||
strictInsertFill(metaObject, CREATE_BY, String.class, loginUser.getUsername());
|
||||
strictInsertFill(metaObject, CREATE_BY_ID, Long.class, loginUser.getUserId());
|
||||
// 创建时间
|
||||
strictInsertFill(metaObject, CREATE_TIME, Date.class, date);
|
||||
strictInsertFill(metaObject, CREATE_TIME, String.class, formattedDate);
|
||||
// 更新者
|
||||
strictInsertFill(metaObject, UPDATE_BY, String.class, loginUser.getUsername());
|
||||
strictInsertFill(metaObject, UPDATE_BY_ID, Long.class, loginUser.getUserId());
|
||||
// 更新时间
|
||||
strictInsertFill(metaObject, UPDATE_TIME, Date.class, date);
|
||||
strictInsertFill(metaObject, UPDATE_TIME, String.class, formattedDate);
|
||||
// 删除标识
|
||||
strictInsertFill(metaObject, DEL_FLAG, String.class, "0");
|
||||
}else {
|
||||
@@ -50,12 +53,12 @@ public class FieldMetaObjectConfig implements MetaObjectHandler {
|
||||
strictInsertFill(metaObject, CREATE_BY, String.class, "匿名登录");
|
||||
strictInsertFill(metaObject, CREATE_BY_ID, Long.class, 0l);
|
||||
// 创建时间
|
||||
strictInsertFill(metaObject, CREATE_TIME, Date.class, date);
|
||||
strictInsertFill(metaObject, CREATE_TIME, String.class, formattedDate);
|
||||
// 更新者
|
||||
strictInsertFill(metaObject, UPDATE_BY, String.class, "匿名登录");
|
||||
strictInsertFill(metaObject, UPDATE_BY_ID, Long.class, 0l);
|
||||
// 更新时间
|
||||
strictInsertFill(metaObject, UPDATE_TIME, Date.class, date);
|
||||
strictInsertFill(metaObject, UPDATE_TIME, String.class, formattedDate);
|
||||
// 删除标识
|
||||
strictInsertFill(metaObject, DEL_FLAG, String.class, "0");
|
||||
}
|
||||
@@ -64,9 +67,10 @@ public class FieldMetaObjectConfig implements MetaObjectHandler {
|
||||
|
||||
@Override
|
||||
public void updateFill(MetaObject metaObject) {
|
||||
|
||||
LocalDateTime now = LocalDateTime.now();
|
||||
String formattedDate = now.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
|
||||
if(!SecurityUtils.isLogin()){
|
||||
strictUpdateFill(metaObject, UPDATE_TIME, Date.class, new Date());
|
||||
strictUpdateFill(metaObject, UPDATE_TIME, String.class, formattedDate);
|
||||
return;
|
||||
}
|
||||
LoginUser loginUser = SecurityUtils.getLoginUser();
|
||||
@@ -77,6 +81,6 @@ public class FieldMetaObjectConfig implements MetaObjectHandler {
|
||||
strictUpdateFill(metaObject, UPDATE_BY, String.class, loginUser.getUsername());
|
||||
strictUpdateFill(metaObject, UPDATE_BY_ID, Long.class, loginUser.getUserId());
|
||||
// 更新时间
|
||||
strictUpdateFill(metaObject, UPDATE_TIME, Date.class, new Date());
|
||||
strictUpdateFill(metaObject, UPDATE_TIME, String.class, formattedDate);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user