Commit 128848f5 authored by fangxinjiang's avatar fangxinjiang

swagger3 鉴权调整

parent 8e369e01
...@@ -40,5 +40,6 @@ ...@@ -40,5 +40,6 @@
<module>yifu-common-security</module> <module>yifu-common-security</module>
<module>yifu-common-test</module> <module>yifu-common-test</module>
<module>yifu-common-dapr</module> <module>yifu-common-dapr</module>
<module>yifu-common-swagger</module>
</modules> </modules>
</project> </project>
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<description>dapr引入</description> <description>dapr引入</description>
<artifactId>yifu-common-dapr</artifactId> <artifactId>yifu-common-dapr</artifactId>
<packaging>jar</packaging>
<dependencies> <dependencies>
<dependency> <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; import io.swagger.v3.oas.annotations.ExternalDocumentation;
...@@ -9,6 +9,7 @@ import io.swagger.v3.oas.annotations.info.Contact; ...@@ -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.info.Info;
import io.swagger.v3.oas.annotations.security.SecurityRequirement; import io.swagger.v3.oas.annotations.security.SecurityRequirement;
import io.swagger.v3.oas.annotations.security.SecurityScheme; import io.swagger.v3.oas.annotations.security.SecurityScheme;
import org.springframework.context.annotation.Configuration;
/** /**
* @author fxj * @date 2022年05月31日 17:29 @description * @author fxj * @date 2022年05月31日 17:29 @description
...@@ -26,6 +27,7 @@ import io.swagger.v3.oas.annotations.security.SecurityScheme; ...@@ -26,6 +27,7 @@ import io.swagger.v3.oas.annotations.security.SecurityScheme;
) )
) )
@SecurityScheme(type = SecuritySchemeType.HTTP, name = "JWT", scheme = "bearer", in = SecuritySchemeIn.HEADER) @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", //@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")))) // scopes = @OAuthScope(name = "write:pets", description = "modify pets in your account"))))
public class Swagger3Config { public class Swagger3Config {
......
org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
com.yifu.cloud.plus.v1.yifu.common.swagger.config.Swagger3Config
...@@ -62,9 +62,8 @@ ...@@ -62,9 +62,8 @@
<version>3.0.0</version> <version>3.0.0</version>
</dependency>--> </dependency>-->
<dependency> <dependency>
<groupId>org.springdoc</groupId> <groupId>com.yifu.cloud.plus.v1</groupId>
<artifactId>springdoc-openapi-ui</artifactId> <artifactId>yifu-common-swagger</artifactId>
<version>1.6.8</version>
</dependency> </dependency>
<!--<dependency> <!--<dependency>
<groupId>com.yifu.cloud.plus.v1</groupId> <groupId>com.yifu.cloud.plus.v1</groupId>
...@@ -104,11 +103,7 @@ ...@@ -104,11 +103,7 @@
<groupId>com.yifu.cloud.plus.v1</groupId> <groupId>com.yifu.cloud.plus.v1</groupId>
<artifactId>yifu-common-test</artifactId> <artifactId>yifu-common-test</artifactId>
</dependency> </dependency>
<dependency>
<groupId>io.swagger.core.v3</groupId>
<artifactId>swagger-models</artifactId>
<version>2.1.12</version>
</dependency>
</dependencies> </dependencies>
<build> <build>
......
...@@ -26,7 +26,6 @@ import org.springframework.web.bind.annotation.RestController; ...@@ -26,7 +26,6 @@ import org.springframework.web.bind.annotation.RestController;
@AllArgsConstructor @AllArgsConstructor
@RequestMapping("/app") @RequestMapping("/app")
@Tag(name = "移动端登录模块") @Tag(name = "移动端登录模块")
@SecurityRequirement(name = HttpHeaders.AUTHORIZATION)
public class AppController { public class AppController {
private final AppService appService; private final AppService appService;
......
...@@ -44,7 +44,6 @@ import java.util.List; ...@@ -44,7 +44,6 @@ import java.util.List;
@RequiredArgsConstructor @RequiredArgsConstructor
@RequestMapping("/dept") @RequestMapping("/dept")
@Tag(name = "部门管理模块") @Tag(name = "部门管理模块")
@SecurityRequirement(name = HttpHeaders.AUTHORIZATION)
public class DeptController { public class DeptController {
private final SysDeptService sysDeptService; private final SysDeptService sysDeptService;
......
...@@ -51,7 +51,6 @@ import java.util.List; ...@@ -51,7 +51,6 @@ import java.util.List;
@RequiredArgsConstructor @RequiredArgsConstructor
@RequestMapping("/dict") @RequestMapping("/dict")
@Tag(name = "字典管理模块") @Tag(name = "字典管理模块")
@SecurityRequirement(name = HttpHeaders.AUTHORIZATION)
public class DictController { public class DictController {
private final SysDictItemService sysDictItemService; private final SysDictItemService sysDictItemService;
......
...@@ -49,7 +49,6 @@ import javax.servlet.http.HttpServletResponse; ...@@ -49,7 +49,6 @@ import javax.servlet.http.HttpServletResponse;
@RequiredArgsConstructor @RequiredArgsConstructor
@RequestMapping("/sys-file") @RequestMapping("/sys-file")
@Tag(name = "文件管理模块") @Tag(name = "文件管理模块")
@SecurityRequirement(name = HttpHeaders.AUTHORIZATION)
public class FileController { public class FileController {
private final SysFileService sysFileService; private final SysFileService sysFileService;
......
...@@ -45,7 +45,6 @@ import java.util.List; ...@@ -45,7 +45,6 @@ import java.util.List;
@RequiredArgsConstructor @RequiredArgsConstructor
@RequestMapping("/log") @RequestMapping("/log")
@Tag(name = "日志管理模块") @Tag(name = "日志管理模块")
@SecurityRequirement(name = HttpHeaders.AUTHORIZATION)
public class LogController { public class LogController {
private final SysLogService sysLogService; private final SysLogService sysLogService;
......
...@@ -43,7 +43,6 @@ import java.util.stream.Collectors; ...@@ -43,7 +43,6 @@ import java.util.stream.Collectors;
@RequiredArgsConstructor @RequiredArgsConstructor
@RequestMapping("/menu") @RequestMapping("/menu")
@Tag(name = "菜单管理模块") @Tag(name = "菜单管理模块")
@SecurityRequirement(name = HttpHeaders.AUTHORIZATION)
public class MenuController { public class MenuController {
private final SysMenuService sysMenuService; private final SysMenuService sysMenuService;
......
...@@ -45,7 +45,6 @@ import java.util.List; ...@@ -45,7 +45,6 @@ import java.util.List;
@RequiredArgsConstructor @RequiredArgsConstructor
@RequestMapping("/client") @RequestMapping("/client")
@Tag(name = "客户端管理模块") @Tag(name = "客户端管理模块")
@SecurityRequirement(name = HttpHeaders.AUTHORIZATION)
public class OauthClientDetailsController { public class OauthClientDetailsController {
private final SysOauthClientDetailsService sysOauthClientDetailsService; private final SysOauthClientDetailsService sysOauthClientDetailsService;
......
...@@ -45,7 +45,6 @@ import java.util.List; ...@@ -45,7 +45,6 @@ import java.util.List;
@RequiredArgsConstructor @RequiredArgsConstructor
@RequestMapping("/post") @RequestMapping("/post")
@Tag(name = "岗位管理模块") @Tag(name = "岗位管理模块")
@SecurityRequirement(name = HttpHeaders.AUTHORIZATION)
public class PostController { public class PostController {
private final SysPostService sysPostService; private final SysPostService sysPostService;
......
...@@ -42,7 +42,6 @@ import org.springframework.web.bind.annotation.*; ...@@ -42,7 +42,6 @@ import org.springframework.web.bind.annotation.*;
@RequiredArgsConstructor @RequiredArgsConstructor
@RequestMapping("/param") @RequestMapping("/param")
@Tag(name = "公共参数配置") @Tag(name = "公共参数配置")
@SecurityRequirement(name = HttpHeaders.AUTHORIZATION)
public class PublicParamController { public class PublicParamController {
private final SysPublicParamService sysPublicParamService; private final SysPublicParamService sysPublicParamService;
......
...@@ -7,10 +7,7 @@ import com.yifu.cloud.plus.v1.yifu.common.log.annotation.SysLog; ...@@ -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 com.yifu.cloud.plus.v1.yifu.common.security.annotation.Inner;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/** /**
* @author lengleng * @author lengleng
...@@ -38,4 +35,10 @@ public class RegisterController { ...@@ -38,4 +35,10 @@ public class RegisterController {
return userService.registerUser(userDto); 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; ...@@ -47,7 +47,6 @@ import java.util.List;
@RequiredArgsConstructor @RequiredArgsConstructor
@RequestMapping("/role") @RequestMapping("/role")
@Tag(name = "角色管理模块") @Tag(name = "角色管理模块")
@SecurityRequirement(name = HttpHeaders.AUTHORIZATION)
public class RoleController { public class RoleController {
private final SysRoleService sysRoleService; private final SysRoleService sysRoleService;
......
...@@ -34,7 +34,6 @@ import java.util.Map; ...@@ -34,7 +34,6 @@ import java.util.Map;
@RequiredArgsConstructor @RequiredArgsConstructor
@RequestMapping("/token") @RequestMapping("/token")
@Tag(name = "令牌管理模块") @Tag(name = "令牌管理模块")
@SecurityRequirement(name = HttpHeaders.AUTHORIZATION)
public class TokenController { public class TokenController {
//private final RemoteTokenService remoteTokenService; //private final RemoteTokenService remoteTokenService;
......
...@@ -56,8 +56,6 @@ import java.util.Set; ...@@ -56,8 +56,6 @@ import java.util.Set;
@RestController @RestController
@RequiredArgsConstructor @RequiredArgsConstructor
@RequestMapping("/user") @RequestMapping("/user")
@Tag(name = "用户管理模块")
@SecurityRequirement(name = HttpHeaders.AUTHORIZATION)
public class UserController { public class UserController {
private final SysUserService userService; private final SysUserService userService;
......
...@@ -32,10 +32,10 @@ ...@@ -32,10 +32,10 @@
<dependencies> <dependencies>
<!--接口文档--> <!--接口文档-->
<!-- <dependency> <dependency>
<groupId>com.yifu.cloud.plus.v1</groupId> <groupId>com.yifu.cloud.plus.v1</groupId>
<artifactId>yifu-common-swagger</artifactId> <artifactId>yifu-common-swagger</artifactId>
</dependency>--> </dependency>
<!--注册中心客户端--> <!--注册中心客户端-->
<!--<dependency> <!--<dependency>
<groupId>com.alibaba.cloud</groupId> <groupId>com.alibaba.cloud</groupId>
......
...@@ -39,3 +39,24 @@ ignore: ...@@ -39,3 +39,24 @@ ignore:
urls: urls:
- /v2/api-docs - /v2/api-docs
- /actuator/** - /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