Commit 14a80f9cd99e1c782fb2e87ce633f72ed71d17b9
1 parent
33d7fded
feat: 新增批量删除访问令牌接口
Showing
1 changed file
with
13 additions
and
2 deletions
yudao-module-system/src/main/java/cn/iocoder/yudao/module/system/controller/admin/oauth2/OAuth2TokenController.java
| @@ -12,11 +12,12 @@ import cn.iocoder.yudao.module.system.service.oauth2.OAuth2TokenService; | @@ -12,11 +12,12 @@ import cn.iocoder.yudao.module.system.service.oauth2.OAuth2TokenService; | ||
| 12 | import io.swagger.v3.oas.annotations.Operation; | 12 | import io.swagger.v3.oas.annotations.Operation; |
| 13 | import io.swagger.v3.oas.annotations.Parameter; | 13 | import io.swagger.v3.oas.annotations.Parameter; |
| 14 | import io.swagger.v3.oas.annotations.tags.Tag; | 14 | import io.swagger.v3.oas.annotations.tags.Tag; |
| 15 | +import jakarta.annotation.Resource; | ||
| 16 | +import jakarta.validation.Valid; | ||
| 15 | import org.springframework.security.access.prepost.PreAuthorize; | 17 | import org.springframework.security.access.prepost.PreAuthorize; |
| 16 | import org.springframework.web.bind.annotation.*; | 18 | import org.springframework.web.bind.annotation.*; |
| 17 | 19 | ||
| 18 | -import jakarta.annotation.Resource; | ||
| 19 | -import jakarta.validation.Valid; | 20 | +import java.util.List; |
| 20 | 21 | ||
| 21 | import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; | 22 | import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; |
| 22 | 23 | ||
| @@ -47,4 +48,14 @@ public class OAuth2TokenController { | @@ -47,4 +48,14 @@ public class OAuth2TokenController { | ||
| 47 | return success(true); | 48 | return success(true); |
| 48 | } | 49 | } |
| 49 | 50 | ||
| 51 | + @DeleteMapping("/delete-list") | ||
| 52 | + @Operation(summary = "批量删除访问令牌") | ||
| 53 | + @Parameter(name = "accessTokens", description = "访问令牌数组", required = true) | ||
| 54 | + @PreAuthorize("@ss.hasPermission('system:oauth2-token:delete')") | ||
| 55 | + public CommonResult<Boolean> deleteAccessTokenList(@RequestParam("accessTokens") List<String> accessTokens) { | ||
| 56 | + accessTokens.forEach(accessToken -> | ||
| 57 | + authService.logout(accessToken, LoginLogTypeEnum.LOGOUT_DELETE.getType())); | ||
| 58 | + return success(true); | ||
| 59 | + } | ||
| 60 | + | ||
| 50 | } | 61 | } |