com.zopen.wechat.mp.task.WechatInfo 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.mp.task;
import com.zcj.util.UtilString;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
public class WechatInfo {
private static Map openIdInfoMap = new ConcurrentHashMap<>();
private String appId;
private String appSecret;
private String accessToken;
private String jsapiTicket;
private WechatInfo() {
}
public static synchronized void saveAccessToken(final String appId, final String appSecret,
final String appAccessToken, final String jsapiTicket) {
if (UtilString.isBlank(appId) || UtilString.isBlank(appSecret) || UtilString.isBlank(appAccessToken)) {
return;
}
WechatInfo wechatInfo = new WechatInfo();
wechatInfo.appId = appId;
wechatInfo.appSecret = appSecret;
wechatInfo.accessToken = appAccessToken;
wechatInfo.jsapiTicket = jsapiTicket;
openIdInfoMap.put(appId, wechatInfo);
}
public static String getAccessToken(final String appId) {
if (UtilString.isBlank(appId)) {
return null;
}
WechatInfo wechatInfo = openIdInfoMap.get(appId);
if (wechatInfo == null) {
return null;
}
return wechatInfo.accessToken;
}
public static String getAppSecret(final String appId) {
if (UtilString.isBlank(appId)) {
return null;
}
WechatInfo wechatInfo = openIdInfoMap.get(appId);
if (wechatInfo == null) {
return null;
}
return wechatInfo.appSecret;
}
public static String getJsapiTicket(final String appId) {
if (UtilString.isBlank(appId)) {
return null;
}
WechatInfo wechatInfo = openIdInfoMap.get(appId);
if (wechatInfo == null) {
return null;
}
return wechatInfo.jsapiTicket;
}
public static Map getOpenIdInfoMap() {
return openIdInfoMap;
}
public String getAppId() {
return appId;
}
public String getAppSecret() {
return appSecret;
}
}