Compare commits

..

No commits in common. "50e8af4a39ff2652249a3e4277341d2ee24c08e8" and "ff9b219ef32c4ce7934d1d2bdc2b9f81c78fda37" have entirely different histories.

3 changed files with 7 additions and 23 deletions

View File

@ -1,9 +1,7 @@
package com.electromagnetic.industry.software.manage.aop;
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.util.ElectromagneticResultUtil;
import com.electromagnetic.industry.software.common.util.UserThreadLocal;
import lombok.extern.slf4j.Slf4j;
import org.aspectj.lang.ProceedingJoinPoint;
@ -19,7 +17,6 @@ import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
@Aspect
@Component
@ -69,19 +66,11 @@ public class ServiceAspect {
StopWatch stopwatch = new StopWatch();
stopwatch.start("接口:" + methodInfo);
Object rvt = jp.proceed();
if (Objects.isNull(UserThreadLocal.getUser())) {
UserLoginInfo userLoginInfo = new UserLoginInfo();
UserThreadLocal.set(userLoginInfo);
}
UserThreadLocal.setReqArgs(paramInfo);
if (rvt instanceof ResponseEntity) {
UserThreadLocal.setRes(ElectromagneticResultUtil.success(""));
return rvt;
}
UserThreadLocal.setRes((ElectromagneticResult)rvt);
UserThreadLocal.setReqArgs(paramInfo);
String returnInfo = JSONUtil.toJsonStr(rvt);
log.info("请求接口结束:{},返回参数:{},接口耗时:{}", methodInfo, returnInfo, (System.currentTimeMillis() - startTime) + "毫秒");
stopwatch.stop();

View File

@ -100,10 +100,10 @@ public class LoginInterceptor implements HandlerInterceptor {
public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) throws Exception {
long accessStartTime = (long)request.getSession().getAttribute("accessStartTime");
ElectromagneticResult<?> result = UserThreadLocal.getResult();
String reqArgs = UserThreadLocal.getReqArgs();
long accessEndTime = System.currentTimeMillis();
UserOperation userOperation = ((HandlerMethod) handler).getMethod().getAnnotation(UserOperation.class);
String reqArgs = UserThreadLocal.getReqArgs();
UserAccessLog userAccessLog = UserAccessLog.builder()
.id(IdWorker.getSnowFlakeIdString())
.userId(UserThreadLocal.getUserId())
@ -117,16 +117,11 @@ public class LoginInterceptor implements HandlerInterceptor {
.accessSuccess(true)
.createTime(new Date())
.build();
ElectromagneticResult<?> result = UserThreadLocal.getResult();
if (result != null) {
if (!result.getSuccess()) {
userAccessLog.setAccessSuccess(false);
userAccessLog.setFailureReason(result.getErrorMessage());
}
} else { // 返回为ResponseEntity且状态为失败
if (!result.getSuccess()) {
userAccessLog.setAccessSuccess(false);
userAccessLog.setFailureReason(result.getErrorMessage());
}
// TODO 如果是下载的文件那么返回的是ResponseEntity而不是ElectromagneticResult
userAccessLogMapper.insert(userAccessLog);
UserThreadLocal.remove();
}

View File

@ -133,7 +133,7 @@ public class EdFileInfoController {
return edFileInfoService.queryChildFolder(parentId);
}
@RequiredPermission(value = FilePermission.DOWNLOAD)
@RequiredPermission(value = FilePermission.VIEW)
@RequestMapping(value = "preview", method = RequestMethod.GET)
public ResponseEntity<InputStreamResource> preview(@RequestParam String id, HttpServletResponse response) {
return edFileInfoService.preview(id, response);