提交 | 用户 | 时间
|
e7c126
|
1 |
package com.iailab.module.system.controller.admin.oauth2; |
H |
2 |
|
|
3 |
import com.iailab.framework.common.pojo.CommonResult; |
|
4 |
import com.iailab.framework.common.pojo.PageResult; |
|
5 |
import com.iailab.framework.common.util.object.BeanUtils; |
|
6 |
import com.iailab.module.system.controller.admin.oauth2.vo.token.OAuth2AccessTokenPageReqVO; |
|
7 |
import com.iailab.module.system.controller.admin.oauth2.vo.token.OAuth2AccessTokenRespVO; |
|
8 |
import com.iailab.module.system.dal.dataobject.oauth2.OAuth2AccessTokenDO; |
|
9 |
import com.iailab.module.system.enums.logger.LoginLogTypeEnum; |
|
10 |
import com.iailab.module.system.service.auth.AdminAuthService; |
|
11 |
import com.iailab.module.system.service.oauth2.OAuth2TokenService; |
|
12 |
import io.swagger.v3.oas.annotations.Operation; |
|
13 |
import io.swagger.v3.oas.annotations.Parameter; |
|
14 |
import io.swagger.v3.oas.annotations.tags.Tag; |
|
15 |
import org.springframework.security.access.prepost.PreAuthorize; |
|
16 |
import org.springframework.web.bind.annotation.*; |
|
17 |
|
|
18 |
import javax.annotation.Resource; |
|
19 |
import javax.validation.Valid; |
|
20 |
|
|
21 |
import static com.iailab.framework.common.pojo.CommonResult.success; |
|
22 |
|
|
23 |
@Tag(name = "管理后台 - OAuth2.0 令牌") |
|
24 |
@RestController |
|
25 |
@RequestMapping("/system/oauth2-token") |
|
26 |
public class OAuth2TokenController { |
|
27 |
|
|
28 |
@Resource |
|
29 |
private OAuth2TokenService oauth2TokenService; |
|
30 |
@Resource |
|
31 |
private AdminAuthService authService; |
|
32 |
|
|
33 |
@GetMapping("/page") |
|
34 |
@Operation(summary = "获得访问令牌分页", description = "只返回有效期内的") |
|
35 |
@PreAuthorize("@ss.hasPermission('system:oauth2-token:page')") |
|
36 |
public CommonResult<PageResult<OAuth2AccessTokenRespVO>> getAccessTokenPage(@Valid OAuth2AccessTokenPageReqVO reqVO) { |
|
37 |
PageResult<OAuth2AccessTokenDO> pageResult = oauth2TokenService.getAccessTokenPage(reqVO); |
|
38 |
return success(BeanUtils.toBean(pageResult, OAuth2AccessTokenRespVO.class)); |
|
39 |
} |
|
40 |
|
|
41 |
@DeleteMapping("/delete") |
|
42 |
@Operation(summary = "删除访问令牌") |
|
43 |
@Parameter(name = "accessToken", description = "访问令牌", required = true, example = "tudou") |
|
44 |
@PreAuthorize("@ss.hasPermission('system:oauth2-token:delete')") |
|
45 |
public CommonResult<Boolean> deleteAccessToken(@RequestParam("accessToken") String accessToken) { |
|
46 |
authService.logout(accessToken, LoginLogTypeEnum.LOGOUT_DELETE.getType()); |
|
47 |
return success(true); |
|
48 |
} |
|
49 |
|
|
50 |
} |