mirror of
https://github.com/BgaSol/sol-cloud
synced 2026-05-22 08:38:42 +00:00
docs(common-auth): Add a comment description
This commit is contained in:
parent
2c5f3becc8
commit
e167761df0
11 changed files with 21 additions and 20 deletions
|
|
@ -5,6 +5,7 @@ import org.springframework.lang.NonNull;
|
|||
import org.springframework.web.servlet.config.annotation.CorsRegistry;
|
||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
||||
|
||||
/// 跨域配置
|
||||
@Configuration
|
||||
public class CorsConfigure implements WebMvcConfigurer {
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -13,9 +13,7 @@ import org.springframework.lang.NonNull;
|
|||
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
|
||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
||||
|
||||
/**
|
||||
* Sa-Token 权限认证 配置类
|
||||
*/
|
||||
/// Sa-Token 权限认证 配置类
|
||||
@Configuration
|
||||
@Slf4j
|
||||
public class SaTokenConfigure implements WebMvcConfigurer {
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ import com.bgasol.common.constant.value.GatewayConfigValues;
|
|||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
|
||||
/// 重写sa-token的注解拦截器
|
||||
public class SaTokenInterceptor extends SaInterceptor {
|
||||
@Override
|
||||
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
|
||||
|
|
|
|||
|
|
@ -26,6 +26,7 @@ import java.util.List;
|
|||
import java.util.Set;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
/// 扫描controller
|
||||
@Component
|
||||
@RequiredArgsConstructor
|
||||
@Slf4j
|
||||
|
|
@ -39,9 +40,7 @@ public class ControllerScanner {
|
|||
|
||||
private final static String controllerPackage = "com.bgasol.web.**.controller";
|
||||
|
||||
/**
|
||||
* 扫描controller类和方法,将权限信息存入数据库
|
||||
*/
|
||||
/// 扫描controller类和方法,将权限信息存入数据库
|
||||
public void scanController(Class<?> controllerClass) {
|
||||
// 只扫描controller的类
|
||||
PermissionEntity parentPermissionEntity = new PermissionEntity();
|
||||
|
|
@ -123,6 +122,7 @@ public class ControllerScanner {
|
|||
}
|
||||
}
|
||||
|
||||
/// 开始扫描controller
|
||||
@EventListener(InstanceRegisteredEvent.class)
|
||||
@Async()
|
||||
public void scanControllers() throws ClassNotFoundException, InterruptedException {
|
||||
|
|
|
|||
|
|
@ -12,9 +12,7 @@ import org.springframework.stereotype.Component;
|
|||
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
/**
|
||||
* Same-Token,定时刷新(分布式锁保证同一时刻只有一个实例执行)
|
||||
*/
|
||||
/// Same-Token,定时刷新(分布式锁保证同一时刻只有一个实例执行)
|
||||
@Component
|
||||
@RequiredArgsConstructor
|
||||
@Slf4j
|
||||
|
|
|
|||
|
|
@ -17,9 +17,7 @@ import java.util.Set;
|
|||
|
||||
import static com.bgasol.common.constant.value.SystemConfigValues.ADMIN_USER_ID;
|
||||
|
||||
/**
|
||||
* 自定义权限验证接口扩展
|
||||
*/
|
||||
/// 权限数据加载源
|
||||
@Component
|
||||
@RequiredArgsConstructor
|
||||
public class StpInterfaceImpl implements StpInterface {
|
||||
|
|
@ -34,9 +32,7 @@ public class StpInterfaceImpl implements StpInterface {
|
|||
return userEntityBaseVo.getData();
|
||||
}
|
||||
|
||||
/**
|
||||
* 返回一个账号所拥有的权限码集合
|
||||
*/
|
||||
/// 返回一个账号所拥有的权限码集合
|
||||
@Override
|
||||
public List<String> getPermissionList(Object loginId, String loginType) {
|
||||
UserEntity user = this.getUser((String) loginId, loginType);
|
||||
|
|
@ -55,9 +51,7 @@ public class StpInterfaceImpl implements StpInterface {
|
|||
return new ArrayList<>(permissions);
|
||||
}
|
||||
|
||||
/**
|
||||
* 返回一个账号所拥有的角色标识集合 (权限与角色可分开校验)
|
||||
*/
|
||||
/// 返回一个账号所拥有的角色标识集合 (权限与角色可分开校验)
|
||||
@Override
|
||||
public List<String> getRoleList(Object loginId, String loginType) {
|
||||
UserEntity user = this.getUser((String) loginId, loginType);
|
||||
|
|
|
|||
|
|
@ -66,5 +66,3 @@ public class StringToStringListConverter implements Converter<List<String>> {
|
|||
};
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ import com.bgasol.common.core.base.vo.ResponseType;
|
|||
import lombok.Getter;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
/// 自定义通用异常
|
||||
@Getter
|
||||
@Slf4j
|
||||
public class BaseException extends RuntimeException {
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ import lombok.extern.slf4j.Slf4j;
|
|||
|
||||
import java.util.List;
|
||||
|
||||
/// 自定义验证异常
|
||||
@Slf4j
|
||||
@Getter
|
||||
public class VerificationException extends RuntimeException {
|
||||
|
|
|
|||
|
|
@ -15,18 +15,23 @@ import java.util.List;
|
|||
@NoArgsConstructor
|
||||
@Schema(description = "基础响应数据")
|
||||
public class BaseVo<T> {
|
||||
/// 响应码
|
||||
@Schema(description = "响应码")
|
||||
private Integer code;
|
||||
|
||||
/// 响应消息
|
||||
@Schema(description = "响应消息")
|
||||
private String message;
|
||||
|
||||
/// 响应数据
|
||||
@Schema(description = "响应数据")
|
||||
private T data;
|
||||
|
||||
/// 响应时间
|
||||
@Schema(description = "响应时间")
|
||||
private Date time;
|
||||
|
||||
/// 响应类型
|
||||
@Schema(description = "响应类型")
|
||||
private ResponseType type;
|
||||
|
||||
|
|
|
|||
|
|
@ -6,18 +6,22 @@ import lombok.NoArgsConstructor;
|
|||
import lombok.Setter;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
|
||||
/// 参数校验结果
|
||||
@Schema(description = "参数校验结果")
|
||||
@Getter
|
||||
@Setter
|
||||
@SuperBuilder
|
||||
@NoArgsConstructor
|
||||
public class VerificationResult {
|
||||
/// 校验结果
|
||||
@Schema(description = "校验结果")
|
||||
private boolean result;
|
||||
|
||||
/// 校验字段
|
||||
@Schema(description = "校验字段")
|
||||
private String field;
|
||||
|
||||
/// 校验消息
|
||||
@Schema(description = "校验消息")
|
||||
private String message;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue