This commit is contained in:
2025-11-06 00:13:02 +08:00
parent c771c99d6e
commit 8a678d409b
4 changed files with 46 additions and 0 deletions

View File

@@ -97,5 +97,13 @@ public interface ITencentDocService {
* @return 工作表列表
*/
JSONObject getSheetList(String accessToken, String fileId);
/**
* 获取用户信息
*
* @param accessToken 访问令牌
* @return 用户信息
*/
JSONObject getUserInfo(String accessToken);
}

View File

@@ -219,5 +219,15 @@ public class TencentDocServiceImpl implements ITencentDocService {
throw new RuntimeException("获取工作表列表失败: " + e.getMessage(), e);
}
}
@Override
public JSONObject getUserInfo(String accessToken) {
try {
return TencentDocApiUtil.getUserInfo(accessToken);
} catch (Exception e) {
log.error("获取用户信息失败", e);
throw new RuntimeException("获取用户信息失败: " + e.getMessage(), e);
}
}
}

View File

@@ -351,5 +351,17 @@ public class TencentDocApiUtil {
String apiUrl = String.format("%s/files/%s/sheets", apiBaseUrl, fileId);
return callApi(accessToken, apiUrl, "GET", null);
}
/**
* 获取用户信息
*
* @param accessToken 访问令牌
* @return 用户信息
*/
public static JSONObject getUserInfo(String accessToken) {
// 腾讯文档用户信息接口https://docs.qq.com/open/document/app/oauth2/userinfo.html
String apiUrl = "https://docs.qq.com/oauth/v2/userinfo";
return callApi(accessToken, apiUrl, "GET", null);
}
}