Commit 128848f5 authored by fangxinjiang's avatar fangxinjiang

swagger3 鉴权调整

parent 8e369e01
......@@ -40,5 +40,6 @@
<module>yifu-common-security</module>
<module>yifu-common-test</module>
<module>yifu-common-dapr</module>
<module>yifu-common-swagger</module>
</modules>
</project>
......@@ -10,7 +10,7 @@
<modelVersion>4.0.0</modelVersion>
<description>dapr引入</description>
<artifactId>yifu-common-dapr</artifactId>
<packaging>jar</packaging>
<dependencies>
<dependency>
......
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>yifu-common</artifactId>
<groupId>com.yifu.cloud.plus.v1</groupId>
<version>1.0.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<description>swagger引入</description>
<artifactId>yifu-common-swagger</artifactId>
<name>yifu-common-swagger</name>
<packaging>jar</packaging>
<dependencies>
<dependency>
<groupId>io.swagger.core.v3</groupId>
<artifactId>swagger-annotations</artifactId>
<version>2.2.0</version>
</dependency>
<dependency>
<groupId>org.springdoc</groupId>
<artifactId>springdoc-openapi-ui</artifactId>
<version>1.6.8</version>
</dependency>
</dependencies>
<properties>
<maven.compiler.source>8</maven.compiler.source>
<maven.compiler.target>8</maven.compiler.target>
</properties>
</project>
package com.yifu.cloud.plus.v1.yifu.admin.config;
package com.yifu.cloud.plus.v1.yifu.common.swagger.config;
import io.swagger.v3.oas.annotations.ExternalDocumentation;
......@@ -9,6 +9,7 @@ import io.swagger.v3.oas.annotations.info.Contact;
import io.swagger.v3.oas.annotations.info.Info;
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
import io.swagger.v3.oas.annotations.security.SecurityScheme;
import org.springframework.context.annotation.Configuration;
/**
* @author fxj * @date 2022年05月31日 17:29 @description
......@@ -26,6 +27,7 @@ import io.swagger.v3.oas.annotations.security.SecurityScheme;
)
)
@SecurityScheme(type = SecuritySchemeType.HTTP, name = "JWT", scheme = "bearer", in = SecuritySchemeIn.HEADER)
@Configuration
//@SecurityScheme(type = SecuritySchemeType.OAUTH2,flows = @OAuthFlow( implicit = @OAuthFlow(authorizationUrl = "http://yifu-auth/oauth/check_token",
// scopes = @OAuthScope(name = "write:pets", description = "modify pets in your account"))))
public class Swagger3Config {
......
org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
com.yifu.cloud.plus.v1.yifu.common.swagger.config.Swagger3Config
......@@ -62,9 +62,8 @@
<version>3.0.0</version>
</dependency>-->
<dependency>
<groupId>org.springdoc</groupId>
<artifactId>springdoc-openapi-ui</artifactId>
<version>1.6.8</version>
<groupId>com.yifu.cloud.plus.v1</groupId>
<artifactId>yifu-common-swagger</artifactId>
</dependency>
<!--<dependency>
<groupId>com.yifu.cloud.plus.v1</groupId>
......@@ -104,11 +103,7 @@
<groupId>com.yifu.cloud.plus.v1</groupId>
<artifactId>yifu-common-test</artifactId>
</dependency>
<dependency>
<groupId>io.swagger.core.v3</groupId>
<artifactId>swagger-models</artifactId>
<version>2.1.12</version>
</dependency>
</dependencies>
<build>
......
......@@ -26,7 +26,6 @@ import org.springframework.web.bind.annotation.RestController;
@AllArgsConstructor
@RequestMapping("/app")
@Tag(name = "移动端登录模块")
@SecurityRequirement(name = HttpHeaders.AUTHORIZATION)
public class AppController {
private final AppService appService;
......
......@@ -44,7 +44,6 @@ import java.util.List;
@RequiredArgsConstructor
@RequestMapping("/dept")
@Tag(name = "部门管理模块")
@SecurityRequirement(name = HttpHeaders.AUTHORIZATION)
public class DeptController {
private final SysDeptService sysDeptService;
......
......@@ -51,7 +51,6 @@ import java.util.List;
@RequiredArgsConstructor
@RequestMapping("/dict")
@Tag(name = "字典管理模块")
@SecurityRequirement(name = HttpHeaders.AUTHORIZATION)
public class DictController {
private final SysDictItemService sysDictItemService;
......
......@@ -49,7 +49,6 @@ import javax.servlet.http.HttpServletResponse;
@RequiredArgsConstructor
@RequestMapping("/sys-file")
@Tag(name = "文件管理模块")
@SecurityRequirement(name = HttpHeaders.AUTHORIZATION)
public class FileController {
private final SysFileService sysFileService;
......
......@@ -45,7 +45,6 @@ import java.util.List;
@RequiredArgsConstructor
@RequestMapping("/log")
@Tag(name = "日志管理模块")
@SecurityRequirement(name = HttpHeaders.AUTHORIZATION)
public class LogController {
private final SysLogService sysLogService;
......
......@@ -43,7 +43,6 @@ import java.util.stream.Collectors;
@RequiredArgsConstructor
@RequestMapping("/menu")
@Tag(name = "菜单管理模块")
@SecurityRequirement(name = HttpHeaders.AUTHORIZATION)
public class MenuController {
private final SysMenuService sysMenuService;
......
......@@ -45,7 +45,6 @@ import java.util.List;
@RequiredArgsConstructor
@RequestMapping("/client")
@Tag(name = "客户端管理模块")
@SecurityRequirement(name = HttpHeaders.AUTHORIZATION)
public class OauthClientDetailsController {
private final SysOauthClientDetailsService sysOauthClientDetailsService;
......
......@@ -45,7 +45,6 @@ import java.util.List;
@RequiredArgsConstructor
@RequestMapping("/post")
@Tag(name = "岗位管理模块")
@SecurityRequirement(name = HttpHeaders.AUTHORIZATION)
public class PostController {
private final SysPostService sysPostService;
......
......@@ -42,7 +42,6 @@ import org.springframework.web.bind.annotation.*;
@RequiredArgsConstructor
@RequestMapping("/param")
@Tag(name = "公共参数配置")
@SecurityRequirement(name = HttpHeaders.AUTHORIZATION)
public class PublicParamController {
private final SysPublicParamService sysPublicParamService;
......
......@@ -7,10 +7,7 @@ import com.yifu.cloud.plus.v1.yifu.common.log.annotation.SysLog;
import com.yifu.cloud.plus.v1.yifu.common.security.annotation.Inner;
import lombok.RequiredArgsConstructor;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
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.*;
/**
* @author lengleng
......@@ -38,4 +35,10 @@ public class RegisterController {
return userService.registerUser(userDto);
}
@SysLog("test")
@GetMapping("/test")
public R<String> registerUser(String name) {
return R.ok(name);
}
}
......@@ -47,7 +47,6 @@ import java.util.List;
@RequiredArgsConstructor
@RequestMapping("/role")
@Tag(name = "角色管理模块")
@SecurityRequirement(name = HttpHeaders.AUTHORIZATION)
public class RoleController {
private final SysRoleService sysRoleService;
......
......@@ -34,7 +34,6 @@ import java.util.Map;
@RequiredArgsConstructor
@RequestMapping("/token")
@Tag(name = "令牌管理模块")
@SecurityRequirement(name = HttpHeaders.AUTHORIZATION)
public class TokenController {
//private final RemoteTokenService remoteTokenService;
......
......@@ -56,8 +56,6 @@ import java.util.Set;
@RestController
@RequiredArgsConstructor
@RequestMapping("/user")
@Tag(name = "用户管理模块")
@SecurityRequirement(name = HttpHeaders.AUTHORIZATION)
public class UserController {
private final SysUserService userService;
......
......@@ -32,10 +32,10 @@
<dependencies>
<!--接口文档-->
<!-- <dependency>
<dependency>
<groupId>com.yifu.cloud.plus.v1</groupId>
<artifactId>yifu-common-swagger</artifactId>
</dependency>-->
</dependency>
<!--注册中心客户端-->
<!--<dependency>
<groupId>com.alibaba.cloud</groupId>
......
......@@ -39,3 +39,24 @@ ignore:
urls:
- /v2/api-docs
- /actuator/**
springdoc:
api-docs:
#是否开启文档功能
enabled: true
#swagger后端请求地址
path: /api-docs
swagger-ui:
#自定义swagger前端请求路径,输入http:127.0.0.1:8080/test会自动重定向到swagger页面
path: /api/codegen
#包扫描路径
packages-to-scan: com.yifu.cloud.plus.v1.yifu.codegen.controller
#这里定义了两个分组,可定义多个,也可以不定义
group-configs:
#分组名
#- group: admin
#按路径匹配
# pathsToMatch: /admin/**
#分组名
- group: codegen
#按包路径匹配
packagesToScan: com.yifu.cloud.plus.v1.yifu.codegen.controller
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment