diff --git a/src/main/java/com/glxp/udi/admin/config/WebMvcConfig.java b/src/main/java/com/glxp/udi/admin/config/WebMvcConfig.java index 9ea6cf0..d947293 100644 --- a/src/main/java/com/glxp/udi/admin/config/WebMvcConfig.java +++ b/src/main/java/com/glxp/udi/admin/config/WebMvcConfig.java @@ -2,7 +2,6 @@ package com.glxp.udi.admin.config; import cn.dev33.satoken.interceptor.SaInterceptor; -import com.glxp.udi.admin.config.saToken.StpInterfaceImpl; import org.springframework.context.annotation.Configuration; import org.springframework.web.servlet.config.annotation.CorsRegistry; import org.springframework.web.servlet.config.annotation.InterceptorRegistry; @@ -11,20 +10,20 @@ import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; @Configuration public class WebMvcConfig implements WebMvcConfigurer { -// @Override -// public void addCorsMappings(CorsRegistry registry) { -// //设置允许跨域的路径 -// registry.addMapping("/**") -// //设置允许跨域请求的域名 -// .allowedOriginPatterns("*") -// //是否允许证书 不再默认开启 -// .allowCredentials(true) -// //设置允许的方法 -// .allowedMethods("*") -// //跨域允许时间 -// .maxAge(3600); -// } - + @Override + public void addCorsMappings(CorsRegistry registry) { + //设置允许跨域的路径 + registry.addMapping("/**") + //设置允许跨域请求的域名 + .allowedOriginPatterns("*") + //是否允许证书 不再默认开启 + .allowCredentials(true) + //设置允许的方法 + .allowedMethods("*") + //跨域允许时间 + .maxAge(3600); + WebMvcConfigurer.super.addCorsMappings(registry); + } @Override public void addInterceptors(InterceptorRegistry registry) { diff --git a/src/main/java/com/glxp/udi/admin/config/saToken/SaTokenConfigure.java b/src/main/java/com/glxp/udi/admin/config/saToken/SaTokenConfigure.java index eaa79e4..4934cce 100644 --- a/src/main/java/com/glxp/udi/admin/config/saToken/SaTokenConfigure.java +++ b/src/main/java/com/glxp/udi/admin/config/saToken/SaTokenConfigure.java @@ -2,20 +2,13 @@ package com.glxp.udi.admin.config.saToken; import cn.dev33.satoken.config.SaTokenConfig; import cn.dev33.satoken.context.SaHolder; -import cn.dev33.satoken.exception.NotLoginException; -import cn.dev33.satoken.exception.NotPermissionException; import cn.dev33.satoken.filter.SaServletFilter; import cn.dev33.satoken.router.SaRouter; import cn.dev33.satoken.stp.StpUtil; import cn.dev33.satoken.util.SaResult; -import cn.hutool.http.ContentType; -import cn.hutool.json.JSONUtil; -import com.glxp.udi.admin.common.enums.ResultEnum; -import com.glxp.udi.admin.common.util.ResultVOUtils; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Primary; -import org.springframework.http.MediaType; import java.util.Arrays; import java.util.List; @@ -46,6 +39,7 @@ public class SaTokenConfigure { } + //白名单 private final List whiteList = Arrays.asList("/login", "/udiwarehouse/register/save", "udiwarehouse/register/getCheckcode"); /** diff --git a/src/main/java/com/glxp/udi/admin/config/saToken/StpInterfaceImpl.java b/src/main/java/com/glxp/udi/admin/config/saToken/StpInterfaceImpl.java index fd624a9..821c913 100644 --- a/src/main/java/com/glxp/udi/admin/config/saToken/StpInterfaceImpl.java +++ b/src/main/java/com/glxp/udi/admin/config/saToken/StpInterfaceImpl.java @@ -1,18 +1,12 @@ package com.glxp.udi.admin.config.saToken; import cn.dev33.satoken.stp.StpInterface; -import cn.hutool.core.collection.CollectionUtil; import cn.hutool.core.util.NumberUtil; -import com.glxp.udi.admin.entity.auth.AuthRoleAdmin; import com.glxp.udi.admin.service.auth.AuthLoginService; -import com.glxp.udi.admin.service.auth.AuthRoleAdminService; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; -import java.util.ArrayList; -import java.util.Arrays; import java.util.List; -import java.util.stream.Collectors; /** * 自定义权限验证接口扩展