Commit ed3a2504 authored by 33's avatar 33

更新OBS配置

parent 9fd32f46
......@@ -106,10 +106,10 @@ copyright:
huaweiyun:
obs:
app-key: HIULSHJZJOTWB72Z38ZB
app-secret: GI0oWEGRJuMKmPXJq2fCmuMpFPIITLmjeCQxo2tA
app-key: CYEVMBJZJA1EXTNOOIGQ
app-secret: L4jnRHdXINzcOpUhxkrLSfHrOgOBGk10xRoPPple
end-point: obs.cn-east-3.myhuaweicloud.com
bucket: filmchain-file
bucket: inmvo-obs
wx-pay:
app-id: wxbdddd81913c795e9
......
......@@ -106,10 +106,10 @@ copyright:
huaweiyun:
obs:
app-key: HIULSHJZJOTWB72Z38ZB
app-secret: GI0oWEGRJuMKmPXJq2fCmuMpFPIITLmjeCQxo2tA
app-key: CYEVMBJZJA1EXTNOOIGQ
app-secret: L4jnRHdXINzcOpUhxkrLSfHrOgOBGk10xRoPPple
end-point: obs.cn-east-3.myhuaweicloud.com
bucket: filmchain-file
bucket: inmvo-obs
wx-pay:
app-id: wxbdddd81913c795e9
......
package com.fzm.portal.aop;
import com.alibaba.fastjson.JSON;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.After;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.aspectj.lang.annotation.Pointcut;
import org.aspectj.lang.annotation.*;
import org.aspectj.lang.reflect.MethodSignature;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.annotation.Order;
......@@ -20,6 +18,7 @@ import org.springframework.web.bind.annotation.RequestParam;
import javax.servlet.http.HttpServletRequest;
import java.lang.reflect.Method;
import java.lang.reflect.Parameter;
import java.time.Instant;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
......@@ -38,7 +37,7 @@ public class LogAop {
private final HttpServletRequest request;
private static final ThreadLocal<Long> threadLocal = new ThreadLocal<>();
private static final ThreadLocal<Long> local = new ThreadLocal<>();
@Pointcut(value = "execution(public * com.fzm.portal.controller..*.*(..))")
public void pointCut() {
......@@ -52,41 +51,42 @@ public class LogAop {
*/
@Before("pointCut()")
public void deBefore(JoinPoint joinPoint) {
// 记录此次请求的开始时间
long start = System.currentTimeMillis();
threadLocal.set(start);
// 获取请求路径
long start = Instant.now().toEpochMilli();
local.set(start);
}
@AfterReturning(pointcut = "pointCut()")
public void logAfterReturning(JoinPoint joinPoint) {
log(joinPoint, null);
}
@AfterThrowing(pointcut = "pointCut()", throwing = "e")
public void logAfterThrowing(JoinPoint joinPoint, Throwable e) {
log(joinPoint, e);
}
private void log(JoinPoint joinPoint, Throwable e) {
String requestURI = request.getRequestURI();
// 获取请求参数
MethodSignature signature = (MethodSignature) joinPoint.getSignature();
Method method = signature.getMethod();
List<Object> parameter = getParameter(method, joinPoint.getArgs());
log.info("请求路径: {},请求参数:{}", requestURI, parameter);
}
long duration = Instant.now().toEpochMilli() - local.get();
/**
* 后置通知
*
* @param joinPoint
*/
@After("pointCut()")
public void doAfter(JoinPoint joinPoint) {
long end = System.currentTimeMillis();
Long start = threadLocal.get();
long l = end - start;
String requestURI = request.getRequestURI();
log.info("请求路径:{},接口耗时:{}ms", requestURI, l);
String msg = duration + "ms "
+ request.getMethod() + " "
+ requestURI + " "
+ JSON.toJSONString(parameter) + (e == null ? "" : " " + e.getMessage());
log.info(msg);
}
/**
* 根据方法和传入的参数获取请求参数
*/
private List<Object> getParameter(Method method, Object[] args) {
List<Object> argList = new ArrayList<>();
List<Object> argList = new ArrayList<>(args.length);
Parameter[] parameters = method.getParameters();
for (int i = 0; i < parameters.length; i++) {
//将RequestBody注解修饰的参数作为请求参数
RequestBody requestBody = parameters[i].getAnnotation(RequestBody.class);
if (requestBody != null) {
argList.add(args[i]);
......@@ -95,18 +95,16 @@ public class LogAop {
if (modelAttribute != null) {
argList.add(args[i]);
}
//将RequestParam注解修饰的参数作为请求参数
RequestParam requestParam = parameters[i].getAnnotation(RequestParam.class);
if (requestParam != null) {
Map<String, Object> map = new HashMap<>();
String key = parameters[i].getName();
if (!StringUtils.isEmpty(requestParam.value())) {
if (StringUtils.isNotBlank(requestParam.value())) {
key = requestParam.value();
}
map.put(key, args[i]);
argList.add(map);
}
// PathVariable修饰的请求参数
PathVariable pathVariable = parameters[i].getAnnotation(PathVariable.class);
if (pathVariable != null) {
Map<String, Object> map = new HashMap<>();
......
......@@ -120,10 +120,10 @@ chain:
huaweiyun:
obs:
app-key: HIULSHJZJOTWB72Z38ZB
app-secret: GI0oWEGRJuMKmPXJq2fCmuMpFPIITLmjeCQxo2tA
app-key: CYEVMBJZJA1EXTNOOIGQ
app-secret: L4jnRHdXINzcOpUhxkrLSfHrOgOBGk10xRoPPple
end-point: obs.cn-east-3.myhuaweicloud.com
bucket: filmchain-file
bucket: inmvo-obs
wx-pay:
app-id: wxbdddd81913c795e9
......
......@@ -120,10 +120,10 @@ chain:
huaweiyun:
obs:
app-key: HIULSHJZJOTWB72Z38ZB
app-secret: GI0oWEGRJuMKmPXJq2fCmuMpFPIITLmjeCQxo2tA
app-key: CYEVMBJZJA1EXTNOOIGQ
app-secret: L4jnRHdXINzcOpUhxkrLSfHrOgOBGk10xRoPPple
end-point: obs.cn-east-3.myhuaweicloud.com
bucket: filmchain-file
bucket: inmvo-obs
wx-pay:
app-id: wxbdddd81913c795e9
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment