|
|
|
@ -7,7 +7,7 @@ import com.ruoyi.common.utils.SecurityUtils;
|
|
|
|
|
import org.apache.ibatis.reflection.MetaObject;
|
|
|
|
|
import org.springframework.stereotype.Component;
|
|
|
|
|
|
|
|
|
|
import java.time.LocalDateTime;
|
|
|
|
|
import java.util.Date;
|
|
|
|
|
import java.util.Objects;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
@ -24,21 +24,28 @@ public class MyMetaObjectHandler implements MetaObjectHandler {
|
|
|
|
|
// 获取当前登录用户
|
|
|
|
|
LoginUser loginUser = SecurityUtils.getLoginUser();
|
|
|
|
|
String userName = loginUser.getUsername();
|
|
|
|
|
Long userId = SecurityUtils.getUserId();
|
|
|
|
|
if (!Objects.equals(userName, "")) {
|
|
|
|
|
this.strictInsertFill(metaObject, "createBy", String.class, userName);
|
|
|
|
|
}
|
|
|
|
|
this.strictInsertFill(metaObject, "createTime", LocalDateTime.class, LocalDateTime.now());
|
|
|
|
|
if (userId!=null) {
|
|
|
|
|
this.strictInsertFill(metaObject, "createId", Long.class, userId);
|
|
|
|
|
}
|
|
|
|
|
this.strictInsertFill(metaObject, "createTime", Date.class, new Date());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void updateFill(MetaObject metaObject) {
|
|
|
|
|
// 获取当前登录用户
|
|
|
|
|
LoginUser loginUser = SecurityUtils.getLoginUser();
|
|
|
|
|
|
|
|
|
|
String userName = loginUser.getUsername();
|
|
|
|
|
Long userId = SecurityUtils.getUserId();
|
|
|
|
|
if (userId!=null) {
|
|
|
|
|
this.strictUpdateFill(metaObject, "updateId", Long.class, userId);
|
|
|
|
|
}
|
|
|
|
|
if (!Objects.equals(userName, "")) {
|
|
|
|
|
this.strictInsertFill(metaObject, "createBy", String.class, userName);
|
|
|
|
|
this.strictUpdateFill(metaObject, "updateBy", String.class, userName);
|
|
|
|
|
}
|
|
|
|
|
this.strictInsertFill(metaObject, "createTime", LocalDateTime.class, LocalDateTime.now());
|
|
|
|
|
this.strictUpdateFill(metaObject, "updateTime", Date.class, new Date());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|