Files
ruoyi-java/ruoyi-system/src/main/java/com/ruoyi/jarvis/config/TencentDocConfig.java
2025-11-06 17:53:16 +08:00

177 lines
4.6 KiB
Java
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package com.ruoyi.jarvis.config;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;
import org.springframework.stereotype.Component;
import javax.annotation.PostConstruct;
/**
* 腾讯文档开放平台配置
*
* @author system
*/
@Configuration
@Component
@ConfigurationProperties(prefix = "tencent.doc")
public class TencentDocConfig {
private static final Logger log = LoggerFactory.getLogger(TencentDocConfig.class);
/** 应用ID */
private String appId;
/** 应用密钥 */
private String appSecret;
/** 授权回调地址 */
private String redirectUri;
/** API基础地址 - V3版本实际路径/openapi/spreadsheet/v3 */
private String apiBaseUrl = "https://docs.qq.com/openapi/spreadsheet/v3";
/** OAuth授权地址 */
private String oauthUrl = "https://docs.qq.com/oauth/v2/authorize";
/** 获取Token地址 */
private String tokenUrl = "https://docs.qq.com/oauth/v2/token";
/** 刷新Token地址 */
private String refreshTokenUrl = "https://docs.qq.com/oauth/v2/token";
/** 访问令牌用于自动写入H-TF订单到腾讯文档 */
private String accessToken;
/** 文件IDH-TF订单的目标文档ID */
private String fileId;
/** 工作表IDH-TF订单的目标工作表ID */
private String sheetId;
/** 表头行号表头所在的行默认为2 */
private Integer headerRow = 2;
/** 起始行号数据开始的行从第几行开始搜索匹配单号默认为3 */
private Integer startRow = 3;
/**
* 配置初始化后验证
*/
@PostConstruct
public void init() {
log.info("腾讯文档配置加载 - appId: {}, redirectUri: {}, apiBaseUrl: {}",
appId != null && appId.length() > 10 ? appId.substring(0, 10) + "..." : (appId != null ? appId : "null"),
redirectUri != null ? redirectUri : "null",
apiBaseUrl);
if (appId == null || appId.trim().isEmpty()) {
log.warn("腾讯文档应用ID未配置请检查application-dev.yml中的tencent.doc.app-id");
}
if (appSecret == null || appSecret.trim().isEmpty()) {
log.warn("腾讯文档应用密钥未配置请检查application-dev.yml中的tencent.doc.app-secret");
}
if (redirectUri == null || redirectUri.trim().isEmpty()) {
log.warn("腾讯文档回调地址未配置请检查application-dev.yml中的tencent.doc.redirect-uri");
}
}
public String getAppId() {
return appId;
}
public void setAppId(String appId) {
this.appId = appId;
}
public String getAppSecret() {
return appSecret;
}
public void setAppSecret(String appSecret) {
this.appSecret = appSecret;
}
public String getRedirectUri() {
return redirectUri;
}
public void setRedirectUri(String redirectUri) {
this.redirectUri = redirectUri;
}
public String getApiBaseUrl() {
return apiBaseUrl;
}
public void setApiBaseUrl(String apiBaseUrl) {
this.apiBaseUrl = apiBaseUrl;
}
public String getOauthUrl() {
return oauthUrl;
}
public void setOauthUrl(String oauthUrl) {
this.oauthUrl = oauthUrl;
}
public String getTokenUrl() {
return tokenUrl;
}
public void setTokenUrl(String tokenUrl) {
this.tokenUrl = tokenUrl;
}
public String getRefreshTokenUrl() {
return refreshTokenUrl;
}
public void setRefreshTokenUrl(String refreshTokenUrl) {
this.refreshTokenUrl = refreshTokenUrl;
}
public String getAccessToken() {
return accessToken;
}
public void setAccessToken(String accessToken) {
this.accessToken = accessToken;
}
public String getFileId() {
return fileId;
}
public void setFileId(String fileId) {
this.fileId = fileId;
}
public String getSheetId() {
return sheetId;
}
public void setSheetId(String sheetId) {
this.sheetId = sheetId;
}
public Integer getHeaderRow() {
return headerRow;
}
public void setHeaderRow(Integer headerRow) {
this.headerRow = headerRow;
}
public Integer getStartRow() {
return startRow;
}
public void setStartRow(Integer startRow) {
this.startRow = startRow;
}
}