com.zopen.wechat.work.task.WechatWorkInfo Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of zopen-ato-starter Show documentation
Show all versions of zopen-ato-starter Show documentation
Alibaba Tencent And Others For Spring Boot.
package com.zopen.wechat.work.task;
import com.zcj.util.UtilString;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
public class WechatWorkInfo {
private static Map agentIdInfoMap = new ConcurrentHashMap<>();
private String corpId;// 企业ID
private String agentId;// 应用ID
private String corpSecret;// 应用秘钥
private String accessToken;// 用于 API 调用的 TOKEN
private WechatWorkInfo() {
}
public static synchronized void saveAccessToken(final String corpId, final String agentId, final String corpSecret, final String appAccessToken) {
if (UtilString.isBlank(corpId) || UtilString.isBlank(agentId) || UtilString.isBlank(corpSecret) || UtilString.isBlank(appAccessToken)) {
return;
}
WechatWorkInfo wechatInfo = new WechatWorkInfo();
wechatInfo.corpId = corpId;
wechatInfo.agentId = agentId;
wechatInfo.corpSecret = corpSecret;
wechatInfo.accessToken = appAccessToken;
agentIdInfoMap.put(agentId, wechatInfo);
}
public static String getAccessToken(final String agentId) {
if (UtilString.isBlank(agentId)) {
return null;
}
WechatWorkInfo wechatInfo = agentIdInfoMap.get(agentId);
if (wechatInfo == null) {
return null;
}
return wechatInfo.accessToken;
}
public static String getCorpSecret(final String agentId) {
if (UtilString.isBlank(agentId)) {
return null;
}
WechatWorkInfo wechatInfo = agentIdInfoMap.get(agentId);
if (wechatInfo == null) {
return null;
}
return wechatInfo.corpSecret;
}
public static String getCorpId(final String agentId) {
if (UtilString.isBlank(agentId)) {
return null;
}
WechatWorkInfo wechatInfo = agentIdInfoMap.get(agentId);
if (wechatInfo == null) {
return null;
}
return wechatInfo.corpId;
}
public static Map getAgentIdInfoMap() {
return agentIdInfoMap;
}
public String getCorpId() {
return corpId;
}
public String getAgentId() {
return agentId;
}
public String getCorpSecret() {
return corpSecret;
}
public String getAccessToken() {
return accessToken;
}
}