临时提交
This commit is contained in:
parent
961bfb2baa
commit
4294808f98
|
|
@ -2,6 +2,7 @@ package com.electromagnetic.industry.software.manage.aop;
|
||||||
|
|
||||||
import cn.hutool.json.JSONUtil;
|
import cn.hutool.json.JSONUtil;
|
||||||
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;
|
||||||
|
|
@ -66,11 +67,13 @@ 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();
|
||||||
|
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,10 +117,17 @@ public class LoginInterceptor implements HandlerInterceptor {
|
||||||
.accessSuccess(true)
|
.accessSuccess(true)
|
||||||
.createTime(new Date())
|
.createTime(new Date())
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
|
ElectromagneticResult<?> result = UserThreadLocal.getResult();
|
||||||
|
if (result != null) {
|
||||||
if (!result.getSuccess()) {
|
if (!result.getSuccess()) {
|
||||||
userAccessLog.setAccessSuccess(false);
|
userAccessLog.setAccessSuccess(false);
|
||||||
userAccessLog.setFailureReason(result.getErrorMessage());
|
userAccessLog.setFailureReason(result.getErrorMessage());
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
userAccessLog.setAccessSuccess(false);
|
||||||
|
}
|
||||||
|
|
||||||
// TODO 如果是下载的文件,那么返回的是ResponseEntity而不是ElectromagneticResult
|
// 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.VIEW)
|
@RequiredPermission(value = FilePermission.DOWNLOAD)
|
||||||
@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