常量优化

This commit is contained in:
none 2023-03-20 11:00:36 +08:00
parent 337e600432
commit dfce2fc477
4 changed files with 13 additions and 7 deletions

View File

@ -27,7 +27,7 @@ public class BackendBus {
private AdminUserService adminUserService; private AdminUserService adminUserService;
public static boolean inUnAuthWhitelist(String uri) { public static boolean inUnAuthWhitelist(String uri) {
return Arrays.stream(BackendConstant.UN_AUTH_URI_WHITELIST).toList().contains(uri); return BackendConstant.UN_AUTH_URI_WHITELIST.contains(uri);
} }
public HashMap<String, Boolean> adminUserPermissions(Integer userId) { public HashMap<String, Boolean> adminUserPermissions(Integer userId) {

View File

@ -7,7 +7,10 @@ import java.util.List;
public class BackendConstant { public class BackendConstant {
public final static String SUPER_ADMIN_ROLE = "super-role"; public final static String SUPER_ADMIN_ROLE = "super-role";
public final static String[] UN_AUTH_URI_WHITELIST = {"/backend/v1/system/image-captcha", "/backend/v1/auth/login",}; public final static List<String> UN_AUTH_URI_WHITELIST = new ArrayList<>() {{
add("/backend/v1/system/image-captcha");
add("/backend/v1/auth/login");
}};
public final static String RESOURCE_TYPE_VIDEO = "VIDEO"; public final static String RESOURCE_TYPE_VIDEO = "VIDEO";
public final static String RESOURCE_TYPE_IMAGE = "IMAGE"; public final static String RESOURCE_TYPE_IMAGE = "IMAGE";

View File

@ -1,14 +1,17 @@
package xyz.playedu.api.constant; package xyz.playedu.api.constant;
import java.util.ArrayList;
import java.util.List;
/** /**
* @Author 杭州白书科技有限公司 * @Author 杭州白书科技有限公司
* @create 2023/3/13 14:07 * @create 2023/3/13 14:07
*/ */
public class FrontendConstant { public class FrontendConstant {
public final static String[] UN_AUTH_URI_WHITELIST = { public final static List<String> UN_AUTH_URI_WHITELIST = new ArrayList<>() {{
"/api/v1/system/config", add("/api/v1/system/config");
"/api/v1/system/image-captcha", add("/api/v1/system/image-captcha");
}; }};
} }

View File

@ -40,7 +40,7 @@ public class FrontMiddleware implements HandlerInterceptor {
return HandlerInterceptor.super.preHandle(request, response, handler); return HandlerInterceptor.super.preHandle(request, response, handler);
} }
if (Arrays.stream(FrontendConstant.UN_AUTH_URI_WHITELIST).toList().contains(request.getRequestURI())) { if (FrontendConstant.UN_AUTH_URI_WHITELIST.contains(request.getRequestURI())) {
return HandlerInterceptor.super.preHandle(request, response, handler); return HandlerInterceptor.super.preHandle(request, response, handler);
} }