update 修改用户注册报未登录警告

This commit is contained in:
疯狂的狮子li 2022-01-28 11:03:31 +08:00
parent 8c7e49dd54
commit 651867055c

View File

@ -27,26 +27,16 @@ public class CreateAndUpdateMetaObjectHandler implements MetaObjectHandler {
try { try {
if (ObjectUtil.isNotNull(metaObject) && metaObject.getOriginalObject() instanceof BaseEntity) { if (ObjectUtil.isNotNull(metaObject) && metaObject.getOriginalObject() instanceof BaseEntity) {
BaseEntity baseEntity = (BaseEntity) metaObject.getOriginalObject(); BaseEntity baseEntity = (BaseEntity) metaObject.getOriginalObject();
Date current = new Date(); Date current = ObjectUtil.isNotNull(baseEntity.getCreateTime())
// 创建时间为空 则填充 ? baseEntity.getCreateTime() : new Date();
if (ObjectUtil.isNull(baseEntity.getCreateTime())) { baseEntity.setCreateTime(current);
baseEntity.setCreateTime(current); baseEntity.setUpdateTime(current);
} String username = StringUtils.isNotBlank(baseEntity.getCreateBy())
// 更新时间为空 则填充 ? baseEntity.getCreateBy() : getLoginUsername();
if (ObjectUtil.isNull(baseEntity.getUpdateTime())) {
baseEntity.setUpdateTime(current);
}
String username = getLoginUsername();
// 当前已登录 创建人为空 则填充 // 当前已登录 创建人为空 则填充
if (StringUtils.isNotBlank(username) baseEntity.setCreateBy(username);
&& StringUtils.isBlank(baseEntity.getCreateBy())) {
baseEntity.setCreateBy(username);
}
// 当前已登录 更新人为空 则填充 // 当前已登录 更新人为空 则填充
if (StringUtils.isNotBlank(username) baseEntity.setUpdateBy(username);
&& StringUtils.isBlank(baseEntity.getUpdateBy())) {
baseEntity.setUpdateBy(username);
}
} }
} catch (Exception e) { } catch (Exception e) {
throw new ServiceException("自动注入异常 => " + e.getMessage(), HttpStatus.HTTP_UNAUTHORIZED); throw new ServiceException("自动注入异常 => " + e.getMessage(), HttpStatus.HTTP_UNAUTHORIZED);