mirror of
https://github.com/PlayEdu/PlayEdu
synced 2026-02-03 15:22:19 +08:00
@@ -6,35 +6,32 @@
|
||||
<parent>
|
||||
<groupId>xyz.playedu</groupId>
|
||||
<artifactId>playedu</artifactId>
|
||||
<version>1.2</version>
|
||||
<version>1.0</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>playedu-api</artifactId>
|
||||
|
||||
<properties>
|
||||
<java.version>17</java.version>
|
||||
</properties>
|
||||
<version>1.9</version>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>xyz.playedu</groupId>
|
||||
<artifactId>playedu-common</artifactId>
|
||||
<version>1.2</version>
|
||||
<version>1.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>xyz.playedu</groupId>
|
||||
<artifactId>playedu-system</artifactId>
|
||||
<version>1.2</version>
|
||||
<version>1.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>xyz.playedu</groupId>
|
||||
<artifactId>playedu-course</artifactId>
|
||||
<version>1.2</version>
|
||||
<version>1.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>xyz.playedu</groupId>
|
||||
<artifactId>playedu-resource</artifactId>
|
||||
<version>1.2</version>
|
||||
<version>1.0</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
@@ -44,7 +41,7 @@
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
<version>3.1.2</version>
|
||||
<version>3.3.4</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<goals>
|
||||
|
||||
@@ -45,20 +45,13 @@ public class ApiInterceptor implements HandlerInterceptor {
|
||||
public boolean preHandle(
|
||||
HttpServletRequest request, HttpServletResponse response, Object handler)
|
||||
throws Exception {
|
||||
response.setHeader("Access-Control-Allow-Origin", "*");
|
||||
response.setHeader("Access-Control-Allow-Headers", "*");
|
||||
response.setHeader("Access-Control-Allow-Methods", "GET, POST, PUT, DELETE, OPTIONS");
|
||||
response.setHeader("Access-Control-Max-Age", "86400");
|
||||
|
||||
if ("OPTIONS".equals(request.getMethod())) {
|
||||
response.setStatus(204);
|
||||
// 返回false意味着整个请求执行到这里结束,不会继续乡下执行了
|
||||
return false;
|
||||
}
|
||||
|
||||
// 当前api的请求路径
|
||||
String path = request.getRequestURI();
|
||||
// 白名单过滤 || OPTIONS请求
|
||||
// 白名单过滤
|
||||
if (BackendConstant.API_LIMIT_WHITELIST.contains(path)) {
|
||||
return HandlerInterceptor.super.preHandle(request, response, handler);
|
||||
}
|
||||
|
||||
@@ -21,6 +21,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
|
||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
||||
import org.springframework.web.servlet.config.annotation.CorsRegistry;
|
||||
|
||||
@Configuration
|
||||
@Slf4j
|
||||
@@ -38,4 +39,13 @@ public class WebMvcConfig implements WebMvcConfigurer {
|
||||
registry.addInterceptor(adminInterceptor).addPathPatterns("/backend/**");
|
||||
registry.addInterceptor(frontInterceptor).addPathPatterns("/api/v1/**");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addCorsMappings(CorsRegistry registry) {
|
||||
registry.addMapping("/**")
|
||||
.allowedOrigins("*")
|
||||
.allowedMethods("*")
|
||||
.allowedHeaders("*")
|
||||
.maxAge(1_296_000);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -55,14 +55,14 @@ mybatis-plus:
|
||||
banner: false
|
||||
|
||||
sa-token:
|
||||
is-print: false
|
||||
token-name: "Authorization"
|
||||
timeout: 1296000 #token有效期[单位:秒,默认15天]
|
||||
is-concurrent: false #限制同时登录
|
||||
is-share: false
|
||||
jwt-secret-key: "playeduxyz"
|
||||
token-prefix: "Bearer"
|
||||
is-print: false
|
||||
is-log: true
|
||||
is-log: false
|
||||
log-level: "warn"
|
||||
|
||||
playedu:
|
||||
|
||||
Reference in New Issue
Block a user