全局 日志

领取红包 返回
This commit is contained in:
wangw 2024-12-05 16:06:50 +08:00
parent 3416b0ef7f
commit 2ea9a4d813
2 changed files with 52 additions and 1 deletions

View File

@ -0,0 +1,51 @@
package com.sqx.common.aspect;
import com.google.gson.Gson;
import com.sqx.common.utils.HttpContextUtils;
import com.sqx.common.utils.IPUtils;
import lombok.extern.slf4j.Slf4j;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;
import org.aspectj.lang.reflect.MethodSignature;
import org.springframework.stereotype.Component;
import javax.servlet.http.HttpServletRequest;
/**
* 方法调用统一切面处理
*/
@Aspect
@Component
@Slf4j
public class AppApiMethodAspect {
@Pointcut("execution(public * (" +
"com.sqx.modules.*.controller.* " +
").*(..))")
public void pkg() {
}
@Around("pkg()")
// @SuppressWarnings("unchecked")
public Object around(ProceedingJoinPoint pjp) throws Throwable {
// 执行被拦截的方法
Object result = pjp.proceed();
//请求的参数
Object[] args = pjp.getArgs();
String params = new Gson().toJson(args);
//获取request
HttpServletRequest request = HttpContextUtils.getHttpServletRequest();
MethodSignature signature = (MethodSignature) pjp.getSignature();
// String className = pjp.getTarget().getClass().getName();
String methodName = signature.getName();
log.info("\n>>>>>>{} {}\n>>>>>>{}\n>>>>>>Request: {}\n>>>>>>Response: {}"
, methodName, request.getRequestURL(), IPUtils.getIpAddr(request),
params,
result
);
return result;
}
}

View File

@ -9,7 +9,7 @@ public interface UserMoneyDao extends BaseMapper<UserMoney> {
void updateMayMoney(@Param("type") Integer type, @Param("userId")Long userId, @Param("money") Double money);
void updateMayAmount(@Param("type") Integer type, @Param("userId")Long userId, @Param("money") Double amount);
void updateMayAmount(@Param("type") Integer type, @Param("userId")Long userId, @Param("amount") Double amount);
void updateSysMoney(@Param("type") Integer type, @Param("sysUserId")Long sysUserId, @Param("money") Double money);