1
This commit is contained in:
@@ -0,0 +1,98 @@
|
||||
package com.ruoyi.jarvis.config;
|
||||
|
||||
import com.ruoyi.common.utils.StringUtils;
|
||||
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;
|
||||
|
||||
/**
|
||||
* 金山文档开放平台(个人云)配置
|
||||
*
|
||||
* @see <a href="https://developer.kdocs.cn">developer.kdocs.cn</a>
|
||||
*/
|
||||
@Configuration
|
||||
@Component
|
||||
@ConfigurationProperties(prefix = "kdocs")
|
||||
public class KdocsCloudConfig {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(KdocsCloudConfig.class);
|
||||
|
||||
/** API 与授权页主机,默认 https://developer.kdocs.cn */
|
||||
private String apiHost = "https://developer.kdocs.cn";
|
||||
|
||||
/** 应用 app_id */
|
||||
private String appId;
|
||||
|
||||
/** 应用 app_key */
|
||||
private String appKey;
|
||||
|
||||
/** OAuth 回调地址(须在开发者后台登记) */
|
||||
private String redirectUri;
|
||||
|
||||
/**
|
||||
* 授权 scope,逗号分隔。
|
||||
* 参考:https://developer.kdocs.cn/server/guide/permission.html
|
||||
*/
|
||||
private String scope = "user_basic,access_personal_files,edit_personal_files";
|
||||
|
||||
@PostConstruct
|
||||
public void init() {
|
||||
log.info("Kdocs 配置加载 - apiHost: {}, redirectUri: {}, appId: {}",
|
||||
apiHost,
|
||||
redirectUri,
|
||||
appId != null && appId.length() > 8 ? appId.substring(0, 8) + "..." : appId);
|
||||
if (StringUtils.isBlank(appId)) {
|
||||
log.warn("kdocs.app-id 未配置,请在 application.yml 中填写金山文档开放平台应用信息");
|
||||
}
|
||||
if (StringUtils.isBlank(appKey)) {
|
||||
log.warn("kdocs.app-key 未配置");
|
||||
}
|
||||
if (StringUtils.isBlank(redirectUri)) {
|
||||
log.warn("kdocs.redirect-uri 未配置");
|
||||
}
|
||||
}
|
||||
|
||||
public String getApiHost() {
|
||||
return apiHost;
|
||||
}
|
||||
|
||||
public void setApiHost(String apiHost) {
|
||||
this.apiHost = apiHost;
|
||||
}
|
||||
|
||||
public String getAppId() {
|
||||
return appId;
|
||||
}
|
||||
|
||||
public void setAppId(String appId) {
|
||||
this.appId = appId;
|
||||
}
|
||||
|
||||
public String getAppKey() {
|
||||
return appKey;
|
||||
}
|
||||
|
||||
public void setAppKey(String appKey) {
|
||||
this.appKey = appKey;
|
||||
}
|
||||
|
||||
public String getRedirectUri() {
|
||||
return redirectUri;
|
||||
}
|
||||
|
||||
public void setRedirectUri(String redirectUri) {
|
||||
this.redirectUri = redirectUri;
|
||||
}
|
||||
|
||||
public String getScope() {
|
||||
return scope;
|
||||
}
|
||||
|
||||
public void setScope(String scope) {
|
||||
this.scope = scope;
|
||||
}
|
||||
}
|
||||
@@ -1,132 +0,0 @@
|
||||
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;
|
||||
|
||||
/**
|
||||
* WPS365开放平台配置
|
||||
*
|
||||
* @author system
|
||||
*/
|
||||
@Configuration
|
||||
@Component
|
||||
@ConfigurationProperties(prefix = "wps365")
|
||||
public class WPS365Config {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(WPS365Config.class);
|
||||
|
||||
/** 应用ID(AppId) */
|
||||
private String appId;
|
||||
|
||||
/** 应用密钥(AppKey) */
|
||||
private String appKey;
|
||||
|
||||
/** 授权回调地址 */
|
||||
private String redirectUri;
|
||||
|
||||
/** API基础地址 */
|
||||
private String apiBaseUrl = "https://openapi.wps.cn/api/v1";
|
||||
|
||||
/** OAuth授权地址 */
|
||||
private String oauthUrl = "https://openapi.wps.cn/oauth2/auth";
|
||||
|
||||
/** 获取Token地址 */
|
||||
private String tokenUrl = "https://openapi.wps.cn/oauth2/token";
|
||||
|
||||
/** 刷新Token地址 */
|
||||
private String refreshTokenUrl = "https://openapi.wps.cn/oauth2/token";
|
||||
|
||||
/** OAuth授权请求的scope权限(可选,如果不配置则使用默认值) */
|
||||
private String scope;
|
||||
|
||||
/**
|
||||
* 配置初始化后验证
|
||||
*/
|
||||
@PostConstruct
|
||||
public void init() {
|
||||
log.info("WPS365配置加载 - 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("WPS365应用ID未配置!请检查application.yml中的wps365.app-id");
|
||||
}
|
||||
if (appKey == null || appKey.trim().isEmpty()) {
|
||||
log.warn("WPS365应用密钥未配置!请检查application.yml中的wps365.app-key");
|
||||
}
|
||||
if (redirectUri == null || redirectUri.trim().isEmpty()) {
|
||||
log.warn("WPS365回调地址未配置!请检查application.yml中的wps365.redirect-uri");
|
||||
}
|
||||
}
|
||||
|
||||
public String getAppId() {
|
||||
return appId;
|
||||
}
|
||||
|
||||
public void setAppId(String appId) {
|
||||
this.appId = appId;
|
||||
}
|
||||
|
||||
public String getAppKey() {
|
||||
return appKey;
|
||||
}
|
||||
|
||||
public void setAppKey(String appKey) {
|
||||
this.appKey = appKey;
|
||||
}
|
||||
|
||||
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 getScope() {
|
||||
return scope;
|
||||
}
|
||||
|
||||
public void setScope(String scope) {
|
||||
this.scope = scope;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user