日志增加shopId,改动打印机,增加注册时默认四种支付方式
This commit is contained in:
@@ -17,10 +17,10 @@ package cn.ysk.cashier.aspect;
|
||||
|
||||
import cn.ysk.cashier.domain.Log;
|
||||
import cn.ysk.cashier.service.LogService;
|
||||
import cn.ysk.cashier.utils.RequestHolder;
|
||||
import cn.ysk.cashier.utils.SecurityUtils;
|
||||
import cn.ysk.cashier.utils.StringUtils;
|
||||
import cn.ysk.cashier.utils.ThrowableUtil;
|
||||
import cn.ysk.cashier.utils.*;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.aspectj.lang.JoinPoint;
|
||||
import org.aspectj.lang.ProceedingJoinPoint;
|
||||
@@ -28,6 +28,8 @@ import org.aspectj.lang.annotation.AfterThrowing;
|
||||
import org.aspectj.lang.annotation.Around;
|
||||
import org.aspectj.lang.annotation.Aspect;
|
||||
import org.aspectj.lang.annotation.Pointcut;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.stereotype.Component;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
@@ -41,6 +43,9 @@ import javax.servlet.http.HttpServletRequest;
|
||||
public class LogAspect {
|
||||
|
||||
private final LogService logService;
|
||||
@Lazy
|
||||
@Autowired
|
||||
private RedisUtils redisUtils;
|
||||
|
||||
ThreadLocal<Long> currentTime = new ThreadLocal<>();
|
||||
|
||||
@@ -69,7 +74,16 @@ public class LogAspect {
|
||||
Log log = new Log("INFO",System.currentTimeMillis() - currentTime.get());
|
||||
currentTime.remove();
|
||||
HttpServletRequest request = RequestHolder.getHttpServletRequest();
|
||||
logService.save(getUsername(), StringUtils.getBrowser(request), StringUtils.getIp(request),joinPoint, log);
|
||||
|
||||
Object o = redisUtils.get("online-token-"+getToken(request));
|
||||
JSONObject jsonObject = null;
|
||||
Integer shopId = null;
|
||||
if (o!= null){
|
||||
String jsonString = JSON.toJSONString(o);
|
||||
jsonObject = JSONObject.parseObject(jsonString);
|
||||
shopId = (Integer)jsonObject.get("shopId");
|
||||
}
|
||||
logService.save(getUsername(), StringUtils.getBrowser(request), StringUtils.getIp(request),joinPoint, log, shopId);
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -85,7 +99,15 @@ public class LogAspect {
|
||||
currentTime.remove();
|
||||
log.setExceptionDetail(ThrowableUtil.getStackTrace(e).getBytes());
|
||||
HttpServletRequest request = RequestHolder.getHttpServletRequest();
|
||||
logService.save(getUsername(), StringUtils.getBrowser(request), StringUtils.getIp(request), (ProceedingJoinPoint)joinPoint, log);
|
||||
Object o = redisUtils.get("online-token-"+getToken(request));
|
||||
JSONObject jsonObject = null;
|
||||
Integer shopId = null;
|
||||
if (o!= null){
|
||||
String jsonString = JSON.toJSONString(o);
|
||||
jsonObject = JSONObject.parseObject(jsonString);
|
||||
shopId = (Integer)jsonObject.get("shopId");
|
||||
}
|
||||
logService.save(getUsername(), StringUtils.getBrowser(request), StringUtils.getIp(request), (ProceedingJoinPoint)joinPoint, log, shopId);
|
||||
}
|
||||
|
||||
public String getUsername() {
|
||||
@@ -95,4 +117,11 @@ public class LogAspect {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
public String getToken(HttpServletRequest request) {
|
||||
final String requestHeader = request.getHeader("Authorization");
|
||||
if (requestHeader != null && requestHeader.startsWith("Bearer")) {
|
||||
return requestHeader.substring(7);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user