1
This commit is contained in:
@@ -112,15 +112,22 @@ public class WPS365Controller extends BaseController {
|
||||
@GetMapping("/tokenStatus")
|
||||
public AjaxResult getTokenStatus(@RequestParam(required = false) String userId) {
|
||||
try {
|
||||
// 如果没有提供userId,可以尝试从当前登录用户获取
|
||||
// 这里暂时需要前端传入userId,后续可以集成到认证系统中
|
||||
if (userId == null || userId.trim().isEmpty()) {
|
||||
return AjaxResult.error("userId不能为空");
|
||||
WPS365TokenInfo tokenInfo = null;
|
||||
|
||||
// 如果提供了userId,查询指定用户的token
|
||||
if (userId != null && !userId.trim().isEmpty()) {
|
||||
tokenInfo = wps365OAuthServiceImpl.getTokenByUserId(userId);
|
||||
} else {
|
||||
// 如果没有提供userId,尝试查找所有token(通常只有一个)
|
||||
// 这里使用getCurrentToken方法,它会尝试查找可用的token
|
||||
tokenInfo = wps365OAuthService.getCurrentToken();
|
||||
}
|
||||
|
||||
WPS365TokenInfo tokenInfo = wps365OAuthServiceImpl.getTokenByUserId(userId);
|
||||
|
||||
if (tokenInfo == null) {
|
||||
return AjaxResult.success("未授权", false);
|
||||
JSONObject result = new JSONObject();
|
||||
result.put("hasToken", false);
|
||||
result.put("isValid", false);
|
||||
return AjaxResult.success("未授权", result);
|
||||
}
|
||||
|
||||
boolean isValid = wps365OAuthService.isTokenValid(tokenInfo);
|
||||
@@ -129,6 +136,9 @@ public class WPS365Controller extends BaseController {
|
||||
result.put("isValid", isValid);
|
||||
result.put("userId", tokenInfo.getUserId());
|
||||
result.put("expired", tokenInfo.isExpired());
|
||||
if (tokenInfo.getExpiresIn() != null) {
|
||||
result.put("expiresIn", tokenInfo.getExpiresIn());
|
||||
}
|
||||
|
||||
return AjaxResult.success("获取Token状态成功", result);
|
||||
} catch (Exception e) {
|
||||
|
||||
Reference in New Issue
Block a user