fix: 修复定时任务获取用户信息报错的问题

This commit is contained in:
曹鹏飞 2024-05-23 11:13:18 +08:00
parent 71563c1e55
commit 430fbd127d
1 changed files with 11 additions and 3 deletions

View File

@ -20,22 +20,30 @@ public class MybatisPlusHandler implements MetaObjectHandler {
public void insertFill(MetaObject metaObject) {
this.strictInsertFill(metaObject, "createdBy", String.class, getUserName());
this.strictInsertFill(metaObject, "createdTime", LocalDateTime.class, LocalDateTime.now());
this.strictInsertFill(metaObject, "updatedBy", String.class, getUserName());
this.strictInsertFill(metaObject, "updatedBy", String.class, getRealName());
this.strictInsertFill(metaObject, "updatedTime", LocalDateTime.class, LocalDateTime.now());
}
@Override
public void updateFill(MetaObject metaObject) {
this.strictInsertFill(metaObject, "updatedBy", String.class, getUserName());
this.strictInsertFill(metaObject, "updatedBy", String.class, getRealName());
this.strictInsertFill(metaObject, "updatedTime", LocalDateTime.class, LocalDateTime.now());
}
private String getUserName() {
private String getRealName() {
try {
return StrUtil.isNotBlank(SessionUtil.getRealName()) ? SessionUtil.getRealName() : SessionUtil.getUserName();
} catch (NflgBusinessException e) {
return "admin";
}
}
private String getUserName() {
try {
return SessionUtil.getUserName();
} catch (NflgBusinessException e) {
return "admin";
}
}
}