This commit is contained in:
xxx
2023-08-27 10:05:18 +08:00
parent 54abd4ae6c
commit 30806bfdcf
93 changed files with 240 additions and 178 deletions

View File

@@ -17,8 +17,11 @@ package xyz.playedu.system.aspectj;
import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONUtil;
import jakarta.servlet.http.HttpServletRequest;
import lombok.extern.slf4j.Slf4j;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.AfterReturning;
import org.aspectj.lang.annotation.AfterThrowing;
@@ -27,6 +30,8 @@ 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.common.annotation.Log;
import xyz.playedu.common.constant.SystemConstant;
import xyz.playedu.common.domain.AdminLog;
import xyz.playedu.common.domain.AdminUser;
@@ -36,7 +41,6 @@ import xyz.playedu.common.service.BackendAuthService;
import xyz.playedu.common.util.IpUtil;
import xyz.playedu.common.util.RequestUtil;
import xyz.playedu.common.util.StringUtil;
import xyz.playedu.common.annotation.Log;
import java.lang.reflect.Method;
import java.util.Date;
@@ -54,7 +58,8 @@ public class AdminLogAspect {
@Autowired private AdminLogService adminLogService;
/** 排除敏感属性字段 */
public static final String EXCLUDE_PROPERTIES = "password,oldPassword,newPassword,confirmPassword,token";
public static final String EXCLUDE_PROPERTIES =
"password,oldPassword,newPassword,confirmPassword,token";
/** Controller层切点 注解拦截 */
@Pointcut("@annotation(xyz.playedu.common.annotation.Log)")
@@ -172,9 +177,9 @@ public class AdminLogAspect {
jsonObjectResult.put(key, excludeProperties(entry.getValue().toString()));
} else {
// 如果value是单纯的数据,执行脱敏操作
if(EXCLUDE_PROPERTIES.contains(key)){
if (EXCLUDE_PROPERTIES.contains(key)) {
jsonObjectResult.put(key, SystemConstant.CONFIG_MASK);
}else {
} else {
jsonObjectResult.put(key, value);
}
}

View File

@@ -16,6 +16,7 @@
package xyz.playedu.system.aspectj;
import lombok.extern.slf4j.Slf4j;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
@@ -23,10 +24,11 @@ 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.common.context.BCtx;
import xyz.playedu.common.bus.BackendBus;
import xyz.playedu.common.types.JsonResponse;
import xyz.playedu.common.annotation.BackendPermission;
import xyz.playedu.common.bus.BackendBus;
import xyz.playedu.common.context.BCtx;
import xyz.playedu.common.types.JsonResponse;
import java.util.HashMap;
@@ -43,8 +45,7 @@ public class BackendPermissionAspect {
@Around("doPointcut()")
public Object doAround(ProceedingJoinPoint joinPoint) throws Throwable {
MethodSignature signature = (MethodSignature) joinPoint.getSignature();
BackendPermission middleware =
signature.getMethod().getAnnotation(BackendPermission.class);
BackendPermission middleware = signature.getMethod().getAnnotation(BackendPermission.class);
Integer adminUserId = BCtx.getId();
HashMap<String, Boolean> permissions = backendBus.adminUserPermissions(adminUserId);
if (permissions.get(middleware.slug()) == null) {

View File

@@ -20,9 +20,10 @@ import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.reflect.MethodSignature;
import org.springframework.stereotype.Component;
import xyz.playedu.common.annotation.Lock;
import xyz.playedu.common.exception.LimitException;
import xyz.playedu.common.util.RedisDistributedLock;
import xyz.playedu.common.annotation.Lock;
import java.lang.reflect.Method;
import java.util.concurrent.TimeUnit;

View File

@@ -20,6 +20,7 @@ import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;
import xyz.playedu.common.constant.BPermissionConstant;
import xyz.playedu.common.domain.AdminPermission;
import xyz.playedu.common.service.AdminPermissionService;

View File

@@ -20,6 +20,7 @@ import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;
import xyz.playedu.common.constant.BackendConstant;
import xyz.playedu.common.domain.AdminRole;
import xyz.playedu.common.service.AdminRoleService;

View File

@@ -20,6 +20,7 @@ import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;
import xyz.playedu.common.constant.BackendConstant;
import xyz.playedu.common.constant.ConfigConstant;
import xyz.playedu.common.domain.AppConfig;

View File

@@ -20,6 +20,7 @@ import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;
import xyz.playedu.common.domain.AppConfig;
import xyz.playedu.common.service.AdminPermissionService;
import xyz.playedu.common.service.AppConfigService;

View File

@@ -17,13 +17,16 @@ package xyz.playedu.system.interceptor;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
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.common.context.BCtx;
import xyz.playedu.common.bus.BackendBus;
import xyz.playedu.common.config.PlayEduConfig;
import xyz.playedu.common.context.BCtx;
import xyz.playedu.common.domain.AdminUser;
import xyz.playedu.common.service.AdminUserService;
import xyz.playedu.common.service.AppConfigService;

View File

@@ -17,13 +17,16 @@ package xyz.playedu.system.interceptor;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
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.common.context.FCtx;
import xyz.playedu.common.config.PlayEduConfig;
import xyz.playedu.common.constant.FrontendConstant;
import xyz.playedu.common.context.FCtx;
import xyz.playedu.common.domain.User;
import xyz.playedu.common.service.FrontendAuthService;
import xyz.playedu.common.service.RateLimiterService;

View File

@@ -16,7 +16,9 @@
package xyz.playedu.system.interceptor;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.CorsRegistry;