Compare commits
No commits in common. "50e8af4a39ff2652249a3e4277341d2ee24c08e8" and "ff9b219ef32c4ce7934d1d2bdc2b9f81c78fda37" have entirely different histories.
50e8af4a39
...
ff9b219ef3
|
|
@ -1,9 +1,7 @@
|
||||||
package com.electromagnetic.industry.software.manage.aop;
|
package com.electromagnetic.industry.software.manage.aop;
|
||||||
|
|
||||||
import cn.hutool.json.JSONUtil;
|
import cn.hutool.json.JSONUtil;
|
||||||
import com.electromagnetic.industry.software.common.pojo.UserLoginInfo;
|
|
||||||
import com.electromagnetic.industry.software.common.resp.ElectromagneticResult;
|
import com.electromagnetic.industry.software.common.resp.ElectromagneticResult;
|
||||||
import com.electromagnetic.industry.software.common.util.ElectromagneticResultUtil;
|
|
||||||
import com.electromagnetic.industry.software.common.util.UserThreadLocal;
|
import com.electromagnetic.industry.software.common.util.UserThreadLocal;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.aspectj.lang.ProceedingJoinPoint;
|
import org.aspectj.lang.ProceedingJoinPoint;
|
||||||
|
|
@ -19,7 +17,6 @@ import javax.servlet.ServletRequest;
|
||||||
import javax.servlet.ServletResponse;
|
import javax.servlet.ServletResponse;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Objects;
|
|
||||||
|
|
||||||
@Aspect
|
@Aspect
|
||||||
@Component
|
@Component
|
||||||
|
|
@ -69,19 +66,11 @@ public class ServiceAspect {
|
||||||
StopWatch stopwatch = new StopWatch();
|
StopWatch stopwatch = new StopWatch();
|
||||||
stopwatch.start("接口:" + methodInfo);
|
stopwatch.start("接口:" + methodInfo);
|
||||||
Object rvt = jp.proceed();
|
Object rvt = jp.proceed();
|
||||||
|
|
||||||
if (Objects.isNull(UserThreadLocal.getUser())) {
|
|
||||||
UserLoginInfo userLoginInfo = new UserLoginInfo();
|
|
||||||
UserThreadLocal.set(userLoginInfo);
|
|
||||||
}
|
|
||||||
|
|
||||||
UserThreadLocal.setReqArgs(paramInfo);
|
|
||||||
if (rvt instanceof ResponseEntity) {
|
if (rvt instanceof ResponseEntity) {
|
||||||
UserThreadLocal.setRes(ElectromagneticResultUtil.success(""));
|
|
||||||
return rvt;
|
return rvt;
|
||||||
}
|
}
|
||||||
UserThreadLocal.setRes((ElectromagneticResult)rvt);
|
UserThreadLocal.setRes((ElectromagneticResult)rvt);
|
||||||
|
UserThreadLocal.setReqArgs(paramInfo);
|
||||||
String returnInfo = JSONUtil.toJsonStr(rvt);
|
String returnInfo = JSONUtil.toJsonStr(rvt);
|
||||||
log.info("请求接口结束:{},返回参数:{},接口耗时:{}", methodInfo, returnInfo, (System.currentTimeMillis() - startTime) + "毫秒");
|
log.info("请求接口结束:{},返回参数:{},接口耗时:{}", methodInfo, returnInfo, (System.currentTimeMillis() - startTime) + "毫秒");
|
||||||
stopwatch.stop();
|
stopwatch.stop();
|
||||||
|
|
|
||||||
|
|
@ -100,10 +100,10 @@ public class LoginInterceptor implements HandlerInterceptor {
|
||||||
public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) throws Exception {
|
public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) throws Exception {
|
||||||
|
|
||||||
long accessStartTime = (long)request.getSession().getAttribute("accessStartTime");
|
long accessStartTime = (long)request.getSession().getAttribute("accessStartTime");
|
||||||
|
ElectromagneticResult<?> result = UserThreadLocal.getResult();
|
||||||
|
String reqArgs = UserThreadLocal.getReqArgs();
|
||||||
long accessEndTime = System.currentTimeMillis();
|
long accessEndTime = System.currentTimeMillis();
|
||||||
UserOperation userOperation = ((HandlerMethod) handler).getMethod().getAnnotation(UserOperation.class);
|
UserOperation userOperation = ((HandlerMethod) handler).getMethod().getAnnotation(UserOperation.class);
|
||||||
String reqArgs = UserThreadLocal.getReqArgs();
|
|
||||||
|
|
||||||
UserAccessLog userAccessLog = UserAccessLog.builder()
|
UserAccessLog userAccessLog = UserAccessLog.builder()
|
||||||
.id(IdWorker.getSnowFlakeIdString())
|
.id(IdWorker.getSnowFlakeIdString())
|
||||||
.userId(UserThreadLocal.getUserId())
|
.userId(UserThreadLocal.getUserId())
|
||||||
|
|
@ -117,16 +117,11 @@ public class LoginInterceptor implements HandlerInterceptor {
|
||||||
.accessSuccess(true)
|
.accessSuccess(true)
|
||||||
.createTime(new Date())
|
.createTime(new Date())
|
||||||
.build();
|
.build();
|
||||||
|
if (!result.getSuccess()) {
|
||||||
ElectromagneticResult<?> result = UserThreadLocal.getResult();
|
|
||||||
if (result != null) {
|
|
||||||
if (!result.getSuccess()) {
|
|
||||||
userAccessLog.setAccessSuccess(false);
|
|
||||||
userAccessLog.setFailureReason(result.getErrorMessage());
|
|
||||||
}
|
|
||||||
} else { // 返回为ResponseEntity,且状态为失败。
|
|
||||||
userAccessLog.setAccessSuccess(false);
|
userAccessLog.setAccessSuccess(false);
|
||||||
|
userAccessLog.setFailureReason(result.getErrorMessage());
|
||||||
}
|
}
|
||||||
|
// TODO 如果是下载的文件,那么返回的是ResponseEntity而不是ElectromagneticResult
|
||||||
userAccessLogMapper.insert(userAccessLog);
|
userAccessLogMapper.insert(userAccessLog);
|
||||||
UserThreadLocal.remove();
|
UserThreadLocal.remove();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -133,7 +133,7 @@ public class EdFileInfoController {
|
||||||
return edFileInfoService.queryChildFolder(parentId);
|
return edFileInfoService.queryChildFolder(parentId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequiredPermission(value = FilePermission.DOWNLOAD)
|
@RequiredPermission(value = FilePermission.VIEW)
|
||||||
@RequestMapping(value = "preview", method = RequestMethod.GET)
|
@RequestMapping(value = "preview", method = RequestMethod.GET)
|
||||||
public ResponseEntity<InputStreamResource> preview(@RequestParam String id, HttpServletResponse response) {
|
public ResponseEntity<InputStreamResource> preview(@RequestParam String id, HttpServletResponse response) {
|
||||||
return edFileInfoService.preview(id, response);
|
return edFileInfoService.preview(id, response);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue