fix(登录): 修改操作日志用户id获取方式
This commit is contained in:
parent
8b4414dbc0
commit
c66c553315
@ -4,7 +4,9 @@ import com.qiwenshare.common.anno.MyLog;
|
|||||||
import com.qiwenshare.common.result.RestResult;
|
import com.qiwenshare.common.result.RestResult;
|
||||||
import com.qiwenshare.file.api.IOperationLogService;
|
import com.qiwenshare.file.api.IOperationLogService;
|
||||||
import com.qiwenshare.file.api.IUserService;
|
import com.qiwenshare.file.api.IUserService;
|
||||||
|
import com.qiwenshare.file.config.security.user.JwtUser;
|
||||||
import com.qiwenshare.file.util.OperationLogUtil;
|
import com.qiwenshare.file.util.OperationLogUtil;
|
||||||
|
import com.qiwenshare.file.util.SessionUtil;
|
||||||
import com.qiwenshare.file.vo.user.UserLoginVo;
|
import com.qiwenshare.file.vo.user.UserLoginVo;
|
||||||
import org.aspectj.lang.JoinPoint;
|
import org.aspectj.lang.JoinPoint;
|
||||||
import org.aspectj.lang.annotation.AfterReturning;
|
import org.aspectj.lang.annotation.AfterReturning;
|
||||||
@ -36,7 +38,6 @@ public class WebLogAcpect {
|
|||||||
|
|
||||||
private String operation = "";
|
private String operation = "";
|
||||||
private String module = "";
|
private String module = "";
|
||||||
private String token = "";
|
|
||||||
private HttpServletRequest request;
|
private HttpServletRequest request;
|
||||||
|
|
||||||
|
|
||||||
@ -58,7 +59,6 @@ public class WebLogAcpect {
|
|||||||
MethodSignature signature = (MethodSignature) joinPoint.getSignature();
|
MethodSignature signature = (MethodSignature) joinPoint.getSignature();
|
||||||
//获取切入点所在的方法
|
//获取切入点所在的方法
|
||||||
Method method = signature.getMethod();
|
Method method = signature.getMethod();
|
||||||
Map<String, Object> map = getNameAndValue(joinPoint);
|
|
||||||
|
|
||||||
//获取操作
|
//获取操作
|
||||||
MyLog myLog = method.getAnnotation(MyLog.class);
|
MyLog myLog = method.getAnnotation(MyLog.class);
|
||||||
@ -66,7 +66,6 @@ public class WebLogAcpect {
|
|||||||
if (myLog != null) {
|
if (myLog != null) {
|
||||||
operation = myLog.operation();
|
operation = myLog.operation();
|
||||||
module = myLog.module();
|
module = myLog.module();
|
||||||
token = (String) map.get("token");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 接收到请求,记录请求内容
|
// 接收到请求,记录请求内容
|
||||||
@ -82,7 +81,12 @@ public class WebLogAcpect {
|
|||||||
if (ret instanceof RestResult) {
|
if (ret instanceof RestResult) {
|
||||||
boolean isSuccess = ((RestResult) ret).getSuccess();
|
boolean isSuccess = ((RestResult) ret).getSuccess();
|
||||||
String errorMessage = ((RestResult) ret).getMessage();
|
String errorMessage = ((RestResult) ret).getMessage();
|
||||||
Long userId = userService.getUserIdByToken(token);
|
JwtUser sessionUser = SessionUtil.getSession();
|
||||||
|
Long userId = 0L;
|
||||||
|
if (sessionUser != null) {
|
||||||
|
userId = sessionUser.getUserId();
|
||||||
|
}
|
||||||
|
|
||||||
Integer code = ((RestResult) ret).getCode();
|
Integer code = ((RestResult) ret).getCode();
|
||||||
if (code != null && code == 200001) {
|
if (code != null && code == 200001) {
|
||||||
UserLoginVo data = (UserLoginVo) ((RestResult) ret).getData();
|
UserLoginVo data = (UserLoginVo) ((RestResult) ret).getData();
|
||||||
|
@ -30,6 +30,7 @@ public class OperationLogUtil {
|
|||||||
operationLogBean.setResult(isSuccess);
|
operationLogBean.setResult(isSuccess);
|
||||||
operationLogBean.setOperation(operation);
|
operationLogBean.setOperation(operation);
|
||||||
operationLogBean.setDetail(detail);
|
operationLogBean.setDetail(detail);
|
||||||
|
operationLogBean.setPlatform(3);
|
||||||
|
|
||||||
return operationLogBean;
|
return operationLogBean;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user