class rename

This commit is contained in:
none 2023-02-23 22:21:14 +08:00
parent bf2c5143c9
commit 2ca2b0989a
3 changed files with 8 additions and 8 deletions

View File

@ -4,11 +4,11 @@ import xyz.playedu.api.domain.AdminUser;
import java.util.LinkedHashMap;
public class PlayEduThreadLocal {
public class PlayEduBackendThreadLocal {
private static final java.lang.ThreadLocal<LinkedHashMap<String, Object>> THREAD_LOCAL = new java.lang.ThreadLocal<>();
public PlayEduThreadLocal() {
public PlayEduBackendThreadLocal() {
}
public static void put(String key, Object val) {

View File

@ -7,7 +7,7 @@ import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.web.servlet.HandlerInterceptor;
import xyz.playedu.api.PlayEduThreadLocal;
import xyz.playedu.api.PlayEduBackendThreadLocal;
import xyz.playedu.api.bus.AppBus;
import xyz.playedu.api.bus.BackendBus;
import xyz.playedu.api.constant.SystemConstant;
@ -56,8 +56,8 @@ public class AdminAuthMiddleware implements HandlerInterceptor {
return responseTransform(response, 403, "当前管理员禁止登录");
}
PlayEduThreadLocal.setAdminUserId(payload.getSub());
PlayEduThreadLocal.setAdminUser(adminUser);
PlayEduBackendThreadLocal.setAdminUserId(payload.getSub());
PlayEduBackendThreadLocal.setAdminUser(adminUser);
return HandlerInterceptor.super.preHandle(request, response, handler);
} catch (Exception e) {
@ -79,7 +79,7 @@ public class AdminAuthMiddleware implements HandlerInterceptor {
@Override
public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) throws Exception {
PlayEduThreadLocal.remove();
PlayEduBackendThreadLocal.remove();
HandlerInterceptor.super.afterCompletion(request, response, handler, ex);
}
}

View File

@ -8,7 +8,7 @@ import org.aspectj.lang.annotation.Pointcut;
import org.aspectj.lang.reflect.MethodSignature;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import xyz.playedu.api.PlayEduThreadLocal;
import xyz.playedu.api.PlayEduBackendThreadLocal;
import xyz.playedu.api.bus.BackendBus;
import xyz.playedu.api.middleware.BackendPermissionMiddleware;
import xyz.playedu.api.types.JsonResponse;
@ -35,7 +35,7 @@ public class BackendPermissionMiddlewareImpl {
public Object doAround(ProceedingJoinPoint joinPoint) throws Throwable {
MethodSignature signature = (MethodSignature) joinPoint.getSignature();
BackendPermissionMiddleware middleware = signature.getMethod().getAnnotation(BackendPermissionMiddleware.class);
Integer adminUserId = PlayEduThreadLocal.getAdminUserID();
Integer adminUserId = PlayEduBackendThreadLocal.getAdminUserID();
HashMap<String, Boolean> permissions = backendBus.adminUserPermissions(adminUserId);
if (permissions.get(middleware.slug()) == null) {
return JsonResponse.error("权限不足", 403);