Commit ed3a2504 authored by 33's avatar 33

更新OBS配置

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