【fix sonar】OnlineInterceptor文件
This commit is contained in:
+38
-35
@@ -10,6 +10,7 @@ import com.jero.common.util.SpringContextUtils;
|
||||
import com.jero.common.util.oConvertUtils;
|
||||
import com.jero.generater.modules.online.cgform.service.IOnlineBaseAPI;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.poi.ss.formula.functions.T;
|
||||
import org.springframework.web.method.HandlerMethod;
|
||||
import org.springframework.web.servlet.HandlerInterceptor;
|
||||
|
||||
@@ -18,6 +19,7 @@ import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Objects;
|
||||
|
||||
@Slf4j
|
||||
public class OnlineInterceptor implements HandlerInterceptor {
|
||||
@@ -36,52 +38,53 @@ public class OnlineInterceptor implements HandlerInterceptor {
|
||||
|
||||
boolean bool = handler.getClass().isAssignableFrom(HandlerMethod.class);
|
||||
|
||||
if (bool) {
|
||||
if (!bool) {
|
||||
return true;
|
||||
}
|
||||
|
||||
OnlineAuth onlineAuth = ((HandlerMethod) handler).getMethodAnnotation(OnlineAuth.class);
|
||||
OnlineAuth onlineAuth = ((HandlerMethod) handler).getMethodAnnotation(OnlineAuth.class);
|
||||
if(Objects.isNull(onlineAuth)){
|
||||
return true;
|
||||
}
|
||||
log.debug("===== online 菜单访问拦截器 =====");
|
||||
String str1 = request.getRequestURI().substring(request.getContextPath().length());
|
||||
str1 = a(str1);
|
||||
String str2 = onlineAuth.value();
|
||||
String str3 = str1.substring(str1.lastIndexOf(str2) + str2.length());
|
||||
log.debug("拦截请求(" + request.getMethod() + "):" + str1 + ",");
|
||||
|
||||
if (onlineAuth != null) {
|
||||
log.debug("===== online 菜单访问拦截器 =====");
|
||||
String str1 = request.getRequestURI().substring(request.getContextPath().length());
|
||||
str1 = a(str1);
|
||||
String str2 = onlineAuth.value();
|
||||
String str3 = str1.substring(str1.lastIndexOf(str2) + str2.length());
|
||||
log.debug("拦截请求(" + request.getMethod() + "):" + str1 + ",");
|
||||
if ("form".equals(str2) && "DELETE".equals(request.getMethod())) {
|
||||
str3 = str3.substring(0, str3.lastIndexOf("/"));
|
||||
}
|
||||
|
||||
if ("form".equals(str2) && "DELETE".equals(request.getMethod())) {
|
||||
str3 = str3.substring(0, str3.lastIndexOf("/"));
|
||||
}
|
||||
String str4 = request.getParameter("tabletype");
|
||||
if (this.iOnlineBaseAPI == null) {
|
||||
this.iOnlineBaseAPI = SpringContextUtils.getBean(IOnlineBaseAPI.class);
|
||||
}
|
||||
str3 = this.iOnlineBaseAPI.getOnlineErpCode(str3, str4);
|
||||
|
||||
String str4 = request.getParameter("tabletype");
|
||||
if (this.iOnlineBaseAPI == null) {
|
||||
this.iOnlineBaseAPI = SpringContextUtils.getBean(IOnlineBaseAPI.class);
|
||||
}
|
||||
str3 = this.iOnlineBaseAPI.getOnlineErpCode(str3, str4);
|
||||
ArrayList<String> arrayList = new ArrayList<>();
|
||||
|
||||
ArrayList<String> arrayList = new ArrayList<>();
|
||||
for (String str : ONLINE_CONSTANT) {
|
||||
|
||||
for (String str : ONLINE_CONSTANT) {
|
||||
arrayList.add(str + str3);
|
||||
}
|
||||
|
||||
arrayList.add(str + str3);
|
||||
}
|
||||
if (this.sysBaseAPI == null) {
|
||||
|
||||
if (this.sysBaseAPI == null) {
|
||||
this.sysBaseAPI = 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, CG_FORM_CONSTANT);
|
||||
|
||||
OnlineAuthDTO onlineAuthDTO = new OnlineAuthDTO(str5, arrayList, CG_FORM_CONSTANT);
|
||||
boolean bool1 = this.sysBaseAPI.hasOnlineAuth(onlineAuthDTO);
|
||||
|
||||
boolean bool1 = this.sysBaseAPI.hasOnlineAuth(onlineAuthDTO);
|
||||
|
||||
if (!bool1) {
|
||||
log.info("请求无权限(" + request.getMethod() + "):" + str1);
|
||||
a(response, str2);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (!bool1) {
|
||||
log.info("请求无权限(" + request.getMethod() + "):" + str1);
|
||||
a(response, str2);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -108,7 +111,7 @@ public class OnlineInterceptor implements HandlerInterceptor {
|
||||
if ("exportXls".equals(paramString)) {
|
||||
printWriter.print("");
|
||||
} else {
|
||||
Result result = Result.error("无权限访问(操作)");
|
||||
Result<T> result = Result.error("无权限访问(操作)");
|
||||
printWriter.print(JSON.toJSON(result));
|
||||
}
|
||||
} catch (IOException iOException) {
|
||||
|
||||
Reference in New Issue
Block a user