【fix sonar】OnlineInterceptor文件
This commit is contained in:
+23
-22
@@ -1,13 +1,6 @@
|
|||||||
package com.jero.generater.interceptor;
|
package com.jero.generater.interceptor;
|
||||||
|
|
||||||
import com.alibaba.fastjson.JSON;
|
import com.alibaba.fastjson.JSON;
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.PrintWriter;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
|
||||||
import javax.servlet.http.HttpServletResponse;
|
|
||||||
|
|
||||||
import com.jero.common.api.dto.OnlineAuthDTO;
|
import com.jero.common.api.dto.OnlineAuthDTO;
|
||||||
import com.jero.common.api.vo.Result;
|
import com.jero.common.api.vo.Result;
|
||||||
import com.jero.common.aspect.annotation.OnlineAuth;
|
import com.jero.common.aspect.annotation.OnlineAuth;
|
||||||
@@ -20,25 +13,32 @@ import lombok.extern.slf4j.Slf4j;
|
|||||||
import org.springframework.web.method.HandlerMethod;
|
import org.springframework.web.method.HandlerMethod;
|
||||||
import org.springframework.web.servlet.HandlerInterceptor;
|
import org.springframework.web.servlet.HandlerInterceptor;
|
||||||
|
|
||||||
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.PrintWriter;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
@Slf4j
|
@Slf4j
|
||||||
public class OnlineInterceptor implements HandlerInterceptor {
|
public class OnlineInterceptor implements HandlerInterceptor {
|
||||||
|
|
||||||
private IOnlineBaseAPI b;
|
private IOnlineBaseAPI iOnlineBaseAPI;
|
||||||
private ISysBaseAPI sysBaseAPI;
|
private ISysBaseAPI sysBaseAPI;
|
||||||
private static final String d = "/online/cgform";
|
private static final String CG_FORM_CONSTANT = "/online/cgform";
|
||||||
private static final String[] e = new String[]{"/online/cgformInnerTableList",
|
private static final String[] ONLINE_CONSTANT = new String[]{"/online/cgformInnerTableList",
|
||||||
"/online/cgformErpList",
|
"/online/cgformErpList",
|
||||||
"/online/cgformList",
|
"/online/cgformList",
|
||||||
"/online/cgformTreeList",
|
"/online/cgformTreeList",
|
||||||
"/online/cgformTabList"};
|
"/online/cgformTabList"};
|
||||||
|
|
||||||
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
|
@Override
|
||||||
|
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) {
|
||||||
|
|
||||||
boolean bool = handler.getClass().isAssignableFrom(HandlerMethod.class);
|
boolean bool = handler.getClass().isAssignableFrom(HandlerMethod.class);
|
||||||
|
|
||||||
if (bool) {
|
if (bool) {
|
||||||
|
|
||||||
OnlineAuth onlineAuth = (OnlineAuth) ((HandlerMethod) handler).getMethodAnnotation(OnlineAuth.class);
|
OnlineAuth onlineAuth = ((HandlerMethod) handler).getMethodAnnotation(OnlineAuth.class);
|
||||||
|
|
||||||
if (onlineAuth != null) {
|
if (onlineAuth != null) {
|
||||||
log.debug("===== online 菜单访问拦截器 =====");
|
log.debug("===== online 菜单访问拦截器 =====");
|
||||||
@@ -53,26 +53,26 @@ public class OnlineInterceptor implements HandlerInterceptor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
String str4 = request.getParameter("tabletype");
|
String str4 = request.getParameter("tabletype");
|
||||||
if (this.b == null) {
|
if (this.iOnlineBaseAPI == null) {
|
||||||
this.b = (IOnlineBaseAPI) SpringContextUtils.getBean(IOnlineBaseAPI.class);
|
this.iOnlineBaseAPI = SpringContextUtils.getBean(IOnlineBaseAPI.class);
|
||||||
}
|
}
|
||||||
str3 = this.b.getOnlineErpCode(str3, str4);
|
str3 = this.iOnlineBaseAPI.getOnlineErpCode(str3, str4);
|
||||||
|
|
||||||
ArrayList<String> arrayList = new ArrayList();
|
ArrayList<String> arrayList = new ArrayList<>();
|
||||||
|
|
||||||
for (String str : e) {
|
for (String str : ONLINE_CONSTANT) {
|
||||||
|
|
||||||
arrayList.add(str + str3);
|
arrayList.add(str + str3);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.sysBaseAPI == null) {
|
if (this.sysBaseAPI == null) {
|
||||||
|
|
||||||
this.sysBaseAPI = (ISysBaseAPI) SpringContextUtils.getBean(ISysBaseAPI.class);
|
this.sysBaseAPI = SpringContextUtils.getBean(ISysBaseAPI.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
String str5 = JwtUtil.getUserNameByToken(request);
|
String str5 = JwtUtil.getUserNameByToken(request);
|
||||||
|
|
||||||
OnlineAuthDTO onlineAuthDTO = new OnlineAuthDTO(str5, arrayList, "/online/cgform");
|
OnlineAuthDTO onlineAuthDTO = new OnlineAuthDTO(str5, arrayList, CG_FORM_CONSTANT);
|
||||||
|
|
||||||
boolean bool1 = this.sysBaseAPI.hasOnlineAuth(onlineAuthDTO);
|
boolean bool1 = this.sysBaseAPI.hasOnlineAuth(onlineAuthDTO);
|
||||||
|
|
||||||
@@ -91,7 +91,7 @@ public class OnlineInterceptor implements HandlerInterceptor {
|
|||||||
if (oConvertUtils.isNotEmpty(paramString)) {
|
if (oConvertUtils.isNotEmpty(paramString)) {
|
||||||
str = paramString.replace("\\", "/")
|
str = paramString.replace("\\", "/")
|
||||||
.replace("//", "/");
|
.replace("//", "/");
|
||||||
if (str.indexOf("//") >= 0) {
|
if (str.contains("//")) {
|
||||||
str = a(str);
|
str = a(str);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -114,8 +114,9 @@ public class OnlineInterceptor implements HandlerInterceptor {
|
|||||||
} catch (IOException iOException) {
|
} catch (IOException iOException) {
|
||||||
log.error(iOException.getMessage());
|
log.error(iOException.getMessage());
|
||||||
} finally {
|
} finally {
|
||||||
if (printWriter != null)
|
if (printWriter != null) {
|
||||||
printWriter.close();
|
printWriter.close();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user