【fix sonar】OnlineInterceptor文件

This commit is contained in:
梁琦涛
2023-03-13 11:43:02 +08:00
parent f2bb2f6eab
commit 3272a22417
@@ -10,6 +10,7 @@ import com.jero.common.util.SpringContextUtils;
import com.jero.common.util.oConvertUtils; import com.jero.common.util.oConvertUtils;
import com.jero.generater.modules.online.cgform.service.IOnlineBaseAPI; import com.jero.generater.modules.online.cgform.service.IOnlineBaseAPI;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.poi.ss.formula.functions.T;
import org.springframework.web.method.HandlerMethod; import org.springframework.web.method.HandlerMethod;
import org.springframework.web.servlet.HandlerInterceptor; import org.springframework.web.servlet.HandlerInterceptor;
@@ -18,6 +19,7 @@ import javax.servlet.http.HttpServletResponse;
import java.io.IOException; import java.io.IOException;
import java.io.PrintWriter; import java.io.PrintWriter;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Objects;
@Slf4j @Slf4j
public class OnlineInterceptor implements HandlerInterceptor { public class OnlineInterceptor implements HandlerInterceptor {
@@ -36,11 +38,14 @@ public class OnlineInterceptor implements HandlerInterceptor {
boolean bool = handler.getClass().isAssignableFrom(HandlerMethod.class); 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)){
if (onlineAuth != null) { return true;
}
log.debug("===== online 菜单访问拦截器 ====="); log.debug("===== online 菜单访问拦截器 =====");
String str1 = request.getRequestURI().substring(request.getContextPath().length()); String str1 = request.getRequestURI().substring(request.getContextPath().length());
str1 = a(str1); str1 = a(str1);
@@ -81,8 +86,6 @@ public class OnlineInterceptor implements HandlerInterceptor {
a(response, str2); a(response, str2);
return false; return false;
} }
}
}
return true; return true;
} }
@@ -108,7 +111,7 @@ public class OnlineInterceptor implements HandlerInterceptor {
if ("exportXls".equals(paramString)) { if ("exportXls".equals(paramString)) {
printWriter.print(""); printWriter.print("");
} else { } else {
Result result = Result.error("无权限访问(操作)"); Result<T> result = Result.error("无权限访问(操作)");
printWriter.print(JSON.toJSON(result)); printWriter.print(JSON.toJSON(result));
} }
} catch (IOException iOException) { } catch (IOException iOException) {