【fix sonar】OnlineInterceptor文件

This commit is contained in:
梁琦涛
2023-03-06 15:11:32 +08:00
parent 1cd95092cd
commit a456ea7743
@@ -1,13 +1,6 @@
package com.jero.generater.interceptor;
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.vo.Result;
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.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
public class OnlineInterceptor implements HandlerInterceptor {
private IOnlineBaseAPI b;
private IOnlineBaseAPI iOnlineBaseAPI;
private ISysBaseAPI sysBaseAPI;
private static final String d = "/online/cgform";
private static final String[] e = new String[]{"/online/cgformInnerTableList",
private static final String CG_FORM_CONSTANT = "/online/cgform";
private static final String[] ONLINE_CONSTANT = new String[]{"/online/cgformInnerTableList",
"/online/cgformErpList",
"/online/cgformList",
"/online/cgformTreeList",
"/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);
if (bool) {
OnlineAuth onlineAuth = (OnlineAuth) ((HandlerMethod) handler).getMethodAnnotation(OnlineAuth.class);
OnlineAuth onlineAuth = ((HandlerMethod) handler).getMethodAnnotation(OnlineAuth.class);
if (onlineAuth != null) {
log.debug("===== online 菜单访问拦截器 =====");
@@ -53,26 +53,26 @@ public class OnlineInterceptor implements HandlerInterceptor {
}
String str4 = request.getParameter("tabletype");
if (this.b == null) {
this.b = (IOnlineBaseAPI) SpringContextUtils.getBean(IOnlineBaseAPI.class);
if (this.iOnlineBaseAPI == null) {
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);
}
if (this.sysBaseAPI == null) {
this.sysBaseAPI = (ISysBaseAPI) SpringContextUtils.getBean(ISysBaseAPI.class);
this.sysBaseAPI = SpringContextUtils.getBean(ISysBaseAPI.class);
}
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);
@@ -91,7 +91,7 @@ public class OnlineInterceptor implements HandlerInterceptor {
if (oConvertUtils.isNotEmpty(paramString)) {
str = paramString.replace("\\", "/")
.replace("//", "/");
if (str.indexOf("//") >= 0) {
if (str.contains("//")) {
str = a(str);
}
}
@@ -114,8 +114,9 @@ public class OnlineInterceptor implements HandlerInterceptor {
} catch (IOException iOException) {
log.error(iOException.getMessage());
} finally {
if (printWriter != null)
printWriter.close();
if (printWriter != null) {
printWriter.close();
}
}
}
}
}