mirror of
https://github.com/PlayEdu/PlayEdu
synced 2025-12-25 20:35:35 +08:00
added: 学员,我的课程
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.PlayEduBContext;
|
||||
import xyz.playedu.api.PlayEduBCtx;
|
||||
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();
|
||||
PlayEduBContext.setConfig(systemConfig);
|
||||
PlayEduBCtx.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, "当前管理员禁止登录");
|
||||
}
|
||||
|
||||
PlayEduBContext.setAdminUserId(payload.getSub());
|
||||
PlayEduBContext.setAdminUser(adminUser);
|
||||
PlayEduBContext.setAdminPer(backendBus.adminUserPermissions(adminUser.getId()));
|
||||
PlayEduBCtx.setAdminUserId(payload.getSub());
|
||||
PlayEduBCtx.setAdminUser(adminUser);
|
||||
PlayEduBCtx.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 {
|
||||
PlayEduBContext.remove();
|
||||
PlayEduBCtx.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.PlayEduFContext;
|
||||
import xyz.playedu.api.PlayEduFCtx;
|
||||
import xyz.playedu.api.constant.FrontendConstant;
|
||||
import xyz.playedu.api.constant.SystemConstant;
|
||||
import xyz.playedu.api.domain.User;
|
||||
@@ -18,7 +18,6 @@ import xyz.playedu.api.util.HelperUtil;
|
||||
import xyz.playedu.api.util.RequestUtil;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
|
||||
/**
|
||||
* @Author 杭州白书科技有限公司
|
||||
@@ -50,21 +49,22 @@ public class FrontMiddleware implements HandlerInterceptor {
|
||||
}
|
||||
|
||||
try {
|
||||
JWTPayload payload = jwtService.parse(token, SystemConstant.JWT_PRV_ADMIN_USER);
|
||||
JWTPayload payload = jwtService.parse(token, SystemConstant.JWT_PRV_USER);
|
||||
|
||||
User user = userService.find(payload.getSub());
|
||||
if (user == null) {
|
||||
return responseTransform(response, 404, "管理员不存在");
|
||||
return responseTransform(response, 404, "请重新登录");
|
||||
}
|
||||
if (user.getIsLock() == 1) {
|
||||
return responseTransform(response, 403, "当前学员已锁定");
|
||||
return responseTransform(response, 403, "当前学员已锁定无法登录");
|
||||
}
|
||||
|
||||
PlayEduFContext.setUserId(user.getId());
|
||||
PlayEduFContext.setUser(user);
|
||||
PlayEduFCtx.setUserId(user.getId());
|
||||
PlayEduFCtx.setUser(user);
|
||||
|
||||
return HandlerInterceptor.super.preHandle(request, response, handler);
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage());
|
||||
return responseTransform(response, 401, "请重新登录");
|
||||
}
|
||||
}
|
||||
@@ -78,7 +78,7 @@ public class FrontMiddleware implements HandlerInterceptor {
|
||||
|
||||
@Override
|
||||
public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) throws Exception {
|
||||
PlayEduFContext.remove();
|
||||
PlayEduFCtx.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.PlayEduBContext;
|
||||
import xyz.playedu.api.PlayEduBCtx;
|
||||
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 = PlayEduBContext.getAdminUserID();
|
||||
Integer adminUserId = PlayEduBCtx.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