提交 | 用户 | 时间
|
e7c126
|
1 |
package com.iailab.module.system.api.oauth2; |
H |
2 |
|
|
3 |
import com.iailab.framework.common.pojo.CommonResult; |
|
4 |
import com.iailab.framework.common.util.object.BeanUtils; |
|
5 |
import com.iailab.module.system.api.oauth2.dto.OAuth2AccessTokenCheckRespDTO; |
|
6 |
import com.iailab.module.system.api.oauth2.dto.OAuth2AccessTokenCreateReqDTO; |
|
7 |
import com.iailab.module.system.api.oauth2.dto.OAuth2AccessTokenRespDTO; |
|
8 |
import com.iailab.module.system.dal.dataobject.oauth2.OAuth2AccessTokenDO; |
|
9 |
import com.iailab.module.system.service.oauth2.OAuth2TokenService; |
|
10 |
import io.swagger.v3.oas.annotations.Operation; |
|
11 |
import org.springframework.validation.annotation.Validated; |
|
12 |
import org.springframework.web.bind.annotation.RestController; |
|
13 |
|
|
14 |
import javax.annotation.Resource; |
|
15 |
|
|
16 |
import static com.iailab.framework.common.pojo.CommonResult.success; |
|
17 |
|
|
18 |
@RestController // 提供 RESTful API 接口,给 Feign 调用 |
|
19 |
@Validated |
|
20 |
public class OAuth2TokenApiImpl implements OAuth2TokenApi { |
|
21 |
|
|
22 |
@Resource |
|
23 |
private OAuth2TokenService oauth2TokenService; |
|
24 |
|
|
25 |
@Override |
|
26 |
public CommonResult<OAuth2AccessTokenRespDTO> createAccessToken(OAuth2AccessTokenCreateReqDTO reqDTO) { |
|
27 |
OAuth2AccessTokenDO accessTokenDO = oauth2TokenService.createAccessToken( |
|
28 |
reqDTO.getUserId(), reqDTO.getUserType(), reqDTO.getClientId(), reqDTO.getScopes()); |
|
29 |
return success(BeanUtils.toBean(accessTokenDO, OAuth2AccessTokenRespDTO.class)); |
|
30 |
} |
|
31 |
|
|
32 |
@Override |
|
33 |
public CommonResult<OAuth2AccessTokenCheckRespDTO> checkAccessToken(String accessToken) { |
|
34 |
OAuth2AccessTokenDO accessTokenDO = oauth2TokenService.checkAccessToken(accessToken); |
|
35 |
return success(BeanUtils.toBean(accessTokenDO, OAuth2AccessTokenCheckRespDTO.class)); |
|
36 |
} |
|
37 |
|
|
38 |
@Override |
|
39 |
public CommonResult<OAuth2AccessTokenRespDTO> removeAccessToken(String accessToken) { |
|
40 |
OAuth2AccessTokenDO accessTokenDO = oauth2TokenService.removeAccessToken(accessToken); |
|
41 |
return success(BeanUtils.toBean(accessTokenDO, OAuth2AccessTokenRespDTO.class)); |
|
42 |
} |
|
43 |
|
|
44 |
@Override |
|
45 |
public CommonResult<OAuth2AccessTokenRespDTO> refreshAccessToken(String refreshToken, String clientId) { |
|
46 |
OAuth2AccessTokenDO accessTokenDO = oauth2TokenService.refreshAccessToken(refreshToken, clientId); |
|
47 |
return success(BeanUtils.toBean(accessTokenDO, OAuth2AccessTokenRespDTO.class)); |
|
48 |
} |
|
49 |
|
|
50 |
} |