使用spring-ai-alibaba重构项目
This commit is contained in:
22
src/main/java/com/qingqiu/interview/config/CorsConfig.java
Normal file
22
src/main/java/com/qingqiu/interview/config/CorsConfig.java
Normal file
@@ -0,0 +1,22 @@
|
||||
package com.qingqiu.interview.config;
|
||||
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.web.servlet.config.annotation.CorsRegistry;
|
||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
||||
|
||||
@Configuration
|
||||
public class CorsConfig implements WebMvcConfigurer {
|
||||
@Override
|
||||
public void addCorsMappings(CorsRegistry registry) {
|
||||
registry.addMapping("/**").
|
||||
allowedOriginPatterns("*") //允许跨域的域名,可以用*表示允许任何域名使用
|
||||
// allowedOrigins("*"). //在Springboot2.4对应Spring5.3后在设置allowCredentials(true)的基础上不能直接使用通配符设置allowedOrigins,而是需要指定特定的URL。如果需要设置通配符,需要通过allowedOriginPatterns指定
|
||||
.allowedMethods("GET", "POST", "DELETE", "PUT") //允许任何方法(post、get等)
|
||||
.allowedHeaders("*") //允许任何请求头
|
||||
.allowCredentials(true) //带上cookie信息
|
||||
.exposedHeaders(HttpHeaders.SET_COOKIE).maxAge(3600L); //maxAge(3600)表明在3600秒内,不需要再发送预检验请求,可以缓存该结果
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -3,12 +3,10 @@ package com.qingqiu.interview.controller;
|
||||
|
||||
import com.qingqiu.interview.common.res.R;
|
||||
import com.qingqiu.interview.dto.QuestionProgressPageParams;
|
||||
import com.qingqiu.interview.entity.InterviewQuestionProgress;
|
||||
import com.qingqiu.interview.service.IInterviewQuestionProgressService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
@@ -27,6 +25,7 @@ public class InterviewQuestionProgressController {
|
||||
|
||||
/**
|
||||
* 面试问题进度列表
|
||||
*
|
||||
* @param params 查询参数
|
||||
* @return data
|
||||
*/
|
||||
@@ -35,4 +34,16 @@ public class InterviewQuestionProgressController {
|
||||
return R.success(service.pageList(params));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取面试问题进度详情
|
||||
*
|
||||
* @param id id
|
||||
* @return data
|
||||
*/
|
||||
@GetMapping("/{id}")
|
||||
public R<InterviewQuestionProgress> getDetail(@PathVariable Long id) {
|
||||
return R.success(service.getById(id));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user