|
|
|
@ -1,5 +1,7 @@
|
|
|
|
package com.ruoyi.framework.handler;
|
|
|
|
package com.ruoyi.framework.handler;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
|
|
|
|
|
|
import cn.hutool.core.util.ObjUtil;
|
|
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
|
|
import cn.hutool.http.HttpStatus;
|
|
|
|
import cn.hutool.http.HttpStatus;
|
|
|
|
import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
|
|
|
|
import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
|
|
|
|
@ -11,6 +13,7 @@ import com.ruoyi.common.utils.StringUtils;
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
import org.apache.ibatis.reflection.MetaObject;
|
|
|
|
import org.apache.ibatis.reflection.MetaObject;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import java.beans.PropertyDescriptor;
|
|
|
|
import java.util.Date;
|
|
|
|
import java.util.Date;
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
@ -38,11 +41,25 @@ public class CreateAndUpdateMetaObjectHandler implements MetaObjectHandler {
|
|
|
|
// 当前已登录 且 更新人为空 则填充
|
|
|
|
// 当前已登录 且 更新人为空 则填充
|
|
|
|
baseEntity.setUpdateBy(username);
|
|
|
|
baseEntity.setUpdateBy(username);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this.strictInsertFill(metaObject, "createTime", Date.class, new Date());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
LoginUser loginUser = LoginHelper.getLoginUser();
|
|
|
|
|
|
|
|
this.strictInsertFill(metaObject, "createUserId", Long.class, loginUser.getUserId());
|
|
|
|
|
|
|
|
this.strictInsertFill(metaObject, "createUsername", String.class, loginUser.getUsername());
|
|
|
|
|
|
|
|
this.strictInsertFill(metaObject, "loginIp", String.class, loginUser.getIpaddr());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
|
|
|
log.debug("自动注入警告 => 用户未登录");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
} catch (Exception e) {
|
|
|
|
throw new ServiceException("自动注入异常 => " + e.getMessage(), HttpStatus.HTTP_UNAUTHORIZED);
|
|
|
|
throw new ServiceException("自动注入异常 => " + e.getMessage(), HttpStatus.HTTP_UNAUTHORIZED);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public void updateFill(MetaObject metaObject) {
|
|
|
|
public void updateFill(MetaObject metaObject) {
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
@ -57,6 +74,17 @@ public class CreateAndUpdateMetaObjectHandler implements MetaObjectHandler {
|
|
|
|
baseEntity.setUpdateBy(username);
|
|
|
|
baseEntity.setUpdateBy(username);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this.strictUpdateFill(metaObject, "updateTime", Date.class, new Date());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
LoginUser loginUser = LoginHelper.getLoginUser();
|
|
|
|
|
|
|
|
this.strictUpdateFill(metaObject, "updateUserId", Long.class, loginUser.getUserId());
|
|
|
|
|
|
|
|
this.strictUpdateFill(metaObject, "updateUsername", String.class, loginUser.getUsername());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
|
|
|
log.debug("自动注入警告 => 用户未登录");
|
|
|
|
|
|
|
|
}
|
|
|
|
} catch (Exception e) {
|
|
|
|
} catch (Exception e) {
|
|
|
|
throw new ServiceException("自动注入异常 => " + e.getMessage(), HttpStatus.HTTP_UNAUTHORIZED);
|
|
|
|
throw new ServiceException("自动注入异常 => " + e.getMessage(), HttpStatus.HTTP_UNAUTHORIZED);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|