feat: swagger
This commit is contained in:
@@ -77,5 +77,11 @@
|
||||
<version>1.37.0</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>io.springfox</groupId>
|
||||
<artifactId>springfox-boot-starter</artifactId>
|
||||
<version>3.0.0</version>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
</project>
|
||||
|
@@ -42,6 +42,9 @@ public class SaTokenConfigure implements WebMvcConfigurer {
|
||||
//拦截所有接口
|
||||
.addPathPatterns("/**")
|
||||
//不拦截/user/doLogin登录接口
|
||||
.excludePathPatterns("/swagger-ui/**")
|
||||
.excludePathPatterns("/swagger-ui.html")
|
||||
.excludePathPatterns("/swagger-resources/**","/swagger-ui/**", "/v3/**", "/error")
|
||||
.excludePathPatterns("/student/login");
|
||||
}
|
||||
}
|
||||
|
@@ -0,0 +1,31 @@
|
||||
package com.landaiqing.auth.common.config;
|
||||
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import springfox.documentation.builders.RequestHandlerSelectors;
|
||||
import springfox.documentation.oas.annotations.EnableOpenApi;
|
||||
import springfox.documentation.service.ApiInfo;
|
||||
import springfox.documentation.spi.DocumentationType;
|
||||
import springfox.documentation.spring.web.plugins.Docket;
|
||||
|
||||
/**
|
||||
* @Classname SwaggerConfig
|
||||
* @BelongsProject: student-Management-system
|
||||
* @BelongsPackage: com.landaiqing.auth.common.config
|
||||
* @Author: landaiqing
|
||||
* @CreateTime: 2024-03-05 19:36
|
||||
* @Description: TODO
|
||||
* @Version: 1.0
|
||||
*/
|
||||
@Configuration
|
||||
@EnableOpenApi
|
||||
public class SwaggerConfig {
|
||||
@Bean
|
||||
public Docket docket(){
|
||||
return new Docket(DocumentationType.OAS_30)
|
||||
.enable(true)//关闭Swagger
|
||||
.select()
|
||||
.apis(RequestHandlerSelectors.basePackage("com.landaiqing.controller"))
|
||||
.build();
|
||||
}
|
||||
}
|
@@ -17,6 +17,8 @@ import com.landaiqing.domain.service.StudentDomainService;
|
||||
import com.landaiqing.domain.service.StudentPermissionDomainService;
|
||||
import com.landaiqing.dto.PermissionDTO;
|
||||
import com.landaiqing.dto.StudentDTO;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
@@ -39,6 +41,7 @@ import java.util.Map;
|
||||
@RestController
|
||||
@RequestMapping("/student/")
|
||||
@Slf4j
|
||||
@Api(tags = "学生controller")
|
||||
public class StudentController {
|
||||
@Resource
|
||||
private StudentDomainService studentDomainService;
|
||||
@@ -54,6 +57,7 @@ public class StudentController {
|
||||
* @date: 2024/3/4 23:47
|
||||
*/
|
||||
@PostMapping("upload")
|
||||
@ApiOperation(value = "上传头像")
|
||||
public Result<Boolean> uploadAvatar(@RequestBody StudentDTO studentDTO) {
|
||||
try {
|
||||
if (log.isInfoEnabled()) {
|
||||
@@ -77,6 +81,7 @@ public class StudentController {
|
||||
* @date: 2024/3/5 12:03
|
||||
*/
|
||||
@RequestMapping("queryAllStudent")
|
||||
@ApiOperation(value = "分页查询学生")
|
||||
public Result<PageResult<StudentDTO>> queryAllStudent(@RequestBody StudentDTO studentDTO) {
|
||||
try {
|
||||
if (log.isInfoEnabled()) {
|
||||
@@ -101,6 +106,7 @@ public class StudentController {
|
||||
* @date: 2024/3/5 12:03
|
||||
*/
|
||||
@RequestMapping("queryPermission")
|
||||
@ApiOperation(value = "权限查询")
|
||||
public Result<List<PermissionDTO>> queryStudentPermission(@RequestBody StudentDTO studentDTO) {
|
||||
try {
|
||||
if (log.isInfoEnabled()) {
|
||||
@@ -122,6 +128,7 @@ public class StudentController {
|
||||
* zh_CN 中文 http://127.0.0.1:3001/zh_CN
|
||||
*/
|
||||
@GetMapping("/{language}")
|
||||
@ApiOperation(value = "国际化测试")
|
||||
public String test(@PathVariable String language) {
|
||||
|
||||
String text2 = MessageUtil.get("sutdent_center", language);
|
||||
@@ -136,6 +143,7 @@ public class StudentController {
|
||||
* @date: 2024/3/5 17:28
|
||||
*/
|
||||
@RequestMapping("login")
|
||||
@ApiOperation(value = "登录")
|
||||
public Result<SaTokenInfo> login(@RequestBody StudentDTO studentDTO) {
|
||||
try {
|
||||
if (log.isInfoEnabled()) {
|
||||
|
@@ -4,6 +4,7 @@ import org.mybatis.spring.annotation.MapperScan;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.context.annotation.ComponentScan;
|
||||
import springfox.documentation.oas.annotations.EnableOpenApi;
|
||||
|
||||
/**
|
||||
* 服务启动类
|
||||
@@ -14,6 +15,7 @@ import org.springframework.context.annotation.ComponentScan;
|
||||
@SpringBootApplication
|
||||
@ComponentScan("com.landaiqing")
|
||||
@MapperScan("com.landaiqing.**.dao")
|
||||
@EnableOpenApi
|
||||
public class AuthApplication {
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(AuthApplication.class);
|
||||
|
@@ -80,3 +80,4 @@ sa-token:
|
||||
|
||||
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user