fix 修复 InjectionMetaObjectHandler 已存在数据依旧会获取用户信息报异常问题

2.X
疯狂的狮子Li 1 year ago
parent 1325972141
commit 7bb33e6b3d

@ -29,10 +29,10 @@ public class InjectionMetaObjectHandler implements MetaObjectHandler {
? baseEntity.getCreateTime() : new Date();
baseEntity.setCreateTime(current);
baseEntity.setUpdateTime(current);
if (ObjectUtil.isNull(baseEntity.getCreateBy())) {
LoginUser loginUser = getLoginUser();
if (ObjectUtil.isNotNull(loginUser)) {
Long userId = ObjectUtil.isNotNull(baseEntity.getCreateBy())
? baseEntity.getCreateBy() : loginUser.getUserId();
Long userId = loginUser.getUserId();
// 当前已登录 且 创建人为空 则填充
baseEntity.setCreateBy(userId);
// 当前已登录 且 更新人为空 则填充
@ -41,6 +41,7 @@ public class InjectionMetaObjectHandler implements MetaObjectHandler {
? baseEntity.getCreateDept() : loginUser.getDeptId());
}
}
}
} catch (Exception e) {
throw new ServiceException("自动注入异常 => " + e.getMessage(), HttpStatus.HTTP_UNAUTHORIZED);
}
@ -54,12 +55,14 @@ public class InjectionMetaObjectHandler implements MetaObjectHandler {
Date current = new Date();
// 更新时间填充(不管为不为空)
baseEntity.setUpdateTime(current);
if (ObjectUtil.isNull(baseEntity.getUpdateBy())) {
LoginUser loginUser = getLoginUser();
// 当前已登录 更新人填充(不管为不为空)
if (ObjectUtil.isNotNull(loginUser)) {
baseEntity.setUpdateBy(loginUser.getUserId());
}
}
}
} catch (Exception e) {
throw new ServiceException("自动注入异常 => " + e.getMessage(), HttpStatus.HTTP_UNAUTHORIZED);
}

Loading…
Cancel
Save