提交修改
This commit is contained in:
parent
b664c0c1a2
commit
92798b99a0
@ -75,7 +75,7 @@ public class LogAop {
|
|||||||
String uri = "";
|
String uri = "";
|
||||||
ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
|
ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
|
||||||
String traceId = attributes.getRequest().getHeader("traceId");
|
String traceId = attributes.getRequest().getHeader("traceId");
|
||||||
if(StringUtils.isBlank(traceId)){
|
if (StringUtils.isBlank(traceId)) {
|
||||||
traceId = OrderUtil.getUserPoolOrder("on");
|
traceId = OrderUtil.getUserPoolOrder("on");
|
||||||
}
|
}
|
||||||
LogAspect.threadLocalNo.set(traceId);
|
LogAspect.threadLocalNo.set(traceId);
|
||||||
@ -83,15 +83,11 @@ public class LogAop {
|
|||||||
HttpServletRequest request = attributes.getRequest();
|
HttpServletRequest request = attributes.getRequest();
|
||||||
uri = attributes.getRequest().getRequestURI();
|
uri = attributes.getRequest().getRequestURI();
|
||||||
|
|
||||||
if(uri.startsWith("/mm/") || uri.startsWith("/app/")){
|
if (uri.startsWith("/mm/") || uri.startsWith("/app/")) {
|
||||||
return point.proceed();
|
return point.proceed();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
try {
|
|
||||||
|
|
||||||
|
|
||||||
args = recordRequestLog(point.getArgs(), uri);
|
args = recordRequestLog(point.getArgs(), uri);
|
||||||
Signature sig = point.getSignature();
|
Signature sig = point.getSignature();
|
||||||
Method method = ((MethodSignature) sig).getMethod();
|
Method method = ((MethodSignature) sig).getMethod();
|
||||||
@ -110,7 +106,6 @@ public class LogAop {
|
|||||||
.append("uri:").append(uri);
|
.append("uri:").append(uri);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// 默认对有的接口进行拦截
|
// 默认对有的接口进行拦截
|
||||||
Boolean intercept = faceAuthMap.get(className);
|
Boolean intercept = faceAuthMap.get(className);
|
||||||
Boolean classMethodConfigNotIntercept = faceAuthMap.get(classNameAndMethodName);
|
Boolean classMethodConfigNotIntercept = faceAuthMap.get(classNameAndMethodName);
|
||||||
@ -125,12 +120,17 @@ public class LogAop {
|
|||||||
|
|
||||||
faceAuthMap.put(className, intercept);
|
faceAuthMap.put(className, intercept);
|
||||||
faceAuthMap.put(classNameAndMethodName, classMethodConfigNotIntercept);
|
faceAuthMap.put(classNameAndMethodName, classMethodConfigNotIntercept);
|
||||||
faceAuthTentMap.put(classNameAndMethodNametencent , tencent);
|
faceAuthTentMap.put(classNameAndMethodNametencent, tencent);
|
||||||
log.info("LogAop one cache className:{},classNameAndMethodName:{},classNameAndMethodNametencent:{}", intercept, classMethodConfigNotIntercept, tencent);
|
log.info("LogAop one cache className:{},classNameAndMethodName:{},classNameAndMethodNametencent:{}", intercept, classMethodConfigNotIntercept, tencent);
|
||||||
}
|
}
|
||||||
|
if (classMethodConfigNotIntercept) {
|
||||||
|
return point.proceed();
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
|
||||||
|
|
||||||
// 如果方法和类上都没有配置NotIntercept注解 ,则需要拦截 ,是linux才进行拦截
|
// 如果方法和类上都没有配置NotIntercept注解 ,则需要拦截 ,是linux才进行拦截
|
||||||
if (intercept && classMethodConfigNotIntercept && OsUtil.isLinux()) {
|
if (intercept && OsUtil.isLinux()) {
|
||||||
String authConfig = request.getHeader("X-TCloudMarket-Custom-AuthConfig");
|
String authConfig = request.getHeader("X-TCloudMarket-Custom-AuthConfig");
|
||||||
if (StringUtils.isBlank(authConfig) || !authConfig.startsWith("{")) {
|
if (StringUtils.isBlank(authConfig) || !authConfig.startsWith("{")) {
|
||||||
log.info("LogAop authConfig value:{} auth error ", authConfig);
|
log.info("LogAop authConfig value:{} auth error ", authConfig);
|
||||||
@ -142,7 +142,7 @@ public class LogAop {
|
|||||||
String auth = faceAuthTentMap.get(classNameAndMethodNametencent);
|
String auth = faceAuthTentMap.get(classNameAndMethodNametencent);
|
||||||
Object tAuth = authConfigMap.get(ApiConstants.t_auth);
|
Object tAuth = authConfigMap.get(ApiConstants.t_auth);
|
||||||
|
|
||||||
if (StringUtils.isBlank(auth) || !auth.equals(tAuth+"")) {
|
if (StringUtils.isBlank(auth) || !auth.equals(tAuth + "")) {
|
||||||
log.info("LogAop authConfig:{},auth:{},tAuth:{} auth error ", authConfig, auth, tAuth);
|
log.info("LogAop authConfig:{},auth:{},tAuth:{} auth error ", authConfig, auth, tAuth);
|
||||||
result = R.error("auth error");
|
result = R.error("auth error");
|
||||||
return result;
|
return result;
|
||||||
@ -172,9 +172,6 @@ public class LogAop {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private String recordRequestLog(Object[] argArrs, String uri) {
|
private String recordRequestLog(Object[] argArrs, String uri) {
|
||||||
String mediaType = "";
|
String mediaType = "";
|
||||||
String args = null;
|
String args = null;
|
||||||
@ -184,9 +181,9 @@ public class LogAop {
|
|||||||
for (Object arg1 : argArrs) {
|
for (Object arg1 : argArrs) {
|
||||||
if (arg1 instanceof MultipartFile) {
|
if (arg1 instanceof MultipartFile) {
|
||||||
continue;
|
continue;
|
||||||
}else if (arg1 instanceof HttpServletRequest) {
|
} else if (arg1 instanceof HttpServletRequest) {
|
||||||
continue;
|
continue;
|
||||||
}else if (arg1 instanceof HttpServletResponse) {
|
} else if (arg1 instanceof HttpServletResponse) {
|
||||||
continue;
|
continue;
|
||||||
} else if (arg1 instanceof MultipartFile[]) {
|
} else if (arg1 instanceof MultipartFile[]) {
|
||||||
continue;
|
continue;
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
package com.heyu.api.controller.vv;
|
package com.heyu.api.controller.vv;
|
||||||
|
|
||||||
|
|
||||||
|
import com.heyu.api.data.annotation.NotIntercept;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
@ -10,11 +11,13 @@ import javax.servlet.http.HttpServletResponse;
|
|||||||
|
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@RestController
|
@RestController
|
||||||
|
@NotIntercept
|
||||||
public class AppOssAuthController {
|
public class AppOssAuthController {
|
||||||
|
|
||||||
|
|
||||||
|
// http://localhost:8888/auth
|
||||||
@RequestMapping("/auth")
|
@RequestMapping("/auth")
|
||||||
public HttpServletResponse auth(HttpServletRequest request, HttpServletResponse response) {
|
public int auth(HttpServletRequest request, HttpServletResponse response) {
|
||||||
|
|
||||||
String uri = request.getRequestURI();
|
String uri = request.getRequestURI();
|
||||||
|
|
||||||
@ -22,7 +25,7 @@ public class AppOssAuthController {
|
|||||||
|
|
||||||
response.setStatus(HttpServletResponse.SC_OK);
|
response.setStatus(HttpServletResponse.SC_OK);
|
||||||
|
|
||||||
return response;
|
return 200;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user