mirror of
https://github.com/PlayEdu/PlayEdu
synced 2025-12-25 20:35:35 +08:00
优化
This commit is contained in:
@@ -6,7 +6,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.PlayEduBCtx;
|
||||
import xyz.playedu.api.BCtx;
|
||||
import xyz.playedu.api.bus.AppBus;
|
||||
import xyz.playedu.api.bus.BackendBus;
|
||||
import xyz.playedu.api.constant.SystemConstant;
|
||||
@@ -49,7 +49,7 @@ public class AdminMiddleware implements HandlerInterceptor {
|
||||
|
||||
// 读取全局配置
|
||||
Map<String, String> systemConfig = configService.keyValues();
|
||||
PlayEduBCtx.setConfig(systemConfig);
|
||||
BCtx.setConfig(systemConfig);
|
||||
|
||||
if (BackendBus.inUnAuthWhitelist(request.getRequestURI())) {
|
||||
return HandlerInterceptor.super.preHandle(request, response, handler);
|
||||
@@ -71,9 +71,9 @@ public class AdminMiddleware implements HandlerInterceptor {
|
||||
return responseTransform(response, 403, "当前管理员禁止登录");
|
||||
}
|
||||
|
||||
PlayEduBCtx.setAdminUserId(payload.getSub());
|
||||
PlayEduBCtx.setAdminUser(adminUser);
|
||||
PlayEduBCtx.setAdminPer(backendBus.adminUserPermissions(adminUser.getId()));
|
||||
BCtx.setAdminUserId(payload.getSub());
|
||||
BCtx.setAdminUser(adminUser);
|
||||
BCtx.setAdminPer(backendBus.adminUserPermissions(adminUser.getId()));
|
||||
|
||||
return HandlerInterceptor.super.preHandle(request, response, handler);
|
||||
} catch (Exception e) {
|
||||
@@ -93,7 +93,7 @@ public class AdminMiddleware implements HandlerInterceptor {
|
||||
|
||||
@Override
|
||||
public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) throws Exception {
|
||||
PlayEduBCtx.remove();
|
||||
BCtx.remove();
|
||||
HandlerInterceptor.super.afterCompletion(request, response, handler, ex);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,7 +6,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.PlayEduFCtx;
|
||||
import xyz.playedu.api.FCtx;
|
||||
import xyz.playedu.api.constant.FrontendConstant;
|
||||
import xyz.playedu.api.constant.SystemConstant;
|
||||
import xyz.playedu.api.domain.User;
|
||||
@@ -59,10 +59,10 @@ public class FrontMiddleware implements HandlerInterceptor {
|
||||
return responseTransform(response, 403, "当前学员已锁定无法登录");
|
||||
}
|
||||
|
||||
PlayEduFCtx.setUserId(user.getId());
|
||||
PlayEduFCtx.setUser(user);
|
||||
PlayEduFCtx.setJWtJti(token);
|
||||
PlayEduFCtx.setJWtJti(payload.getJti());
|
||||
FCtx.setUserId(user.getId());
|
||||
FCtx.setUser(user);
|
||||
FCtx.setJWtJti(token);
|
||||
FCtx.setJWtJti(payload.getJti());
|
||||
|
||||
return HandlerInterceptor.super.preHandle(request, response, handler);
|
||||
} catch (Exception e) {
|
||||
@@ -80,7 +80,7 @@ public class FrontMiddleware implements HandlerInterceptor {
|
||||
|
||||
@Override
|
||||
public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) throws Exception {
|
||||
PlayEduFCtx.remove();
|
||||
FCtx.remove();
|
||||
HandlerInterceptor.super.afterCompletion(request, response, handler, ex);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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.PlayEduBCtx;
|
||||
import xyz.playedu.api.BCtx;
|
||||
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 = PlayEduBCtx.getAdminUserID();
|
||||
Integer adminUserId = BCtx.getAdminUserID();
|
||||
HashMap<String, Boolean> permissions = backendBus.adminUserPermissions(adminUserId);
|
||||
if (permissions.get(middleware.slug()) == null) {
|
||||
return JsonResponse.error("权限不足", 403);
|
||||
|
||||
Reference in New Issue
Block a user