mirror of
https://gitee.com/binary/weixin-java-tools.git
synced 2026-02-16 05:16:24 +08:00
This commit is contained in:
@@ -179,6 +179,12 @@ public interface WxMaService {
|
||||
*/
|
||||
WxMaSettingService getSettingService();
|
||||
|
||||
/**
|
||||
* 返回分享相关查询服务
|
||||
* @return WxMaShareService
|
||||
*/
|
||||
WxMaShareService getShareService();
|
||||
|
||||
/**
|
||||
* 初始化http请求对象.
|
||||
*/
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
package cn.binarywang.wx.miniapp.api;
|
||||
|
||||
import cn.binarywang.wx.miniapp.bean.WxMaShareInfo;
|
||||
|
||||
/**
|
||||
* 分享信息相关操作接口.
|
||||
*
|
||||
* @author zhfish
|
||||
*/
|
||||
public interface WxMaShareService {
|
||||
|
||||
/**
|
||||
* 解密分享敏感数据.
|
||||
*
|
||||
* @param sessionKey 会话密钥
|
||||
* @param encryptedData 消息密文
|
||||
* @param ivStr 加密算法的初始向量
|
||||
*/
|
||||
WxMaShareInfo getShareInfo(String sessionKey, String encryptedData, String ivStr);
|
||||
|
||||
}
|
||||
@@ -6,6 +6,7 @@ import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.locks.Lock;
|
||||
|
||||
import cn.binarywang.wx.miniapp.api.*;
|
||||
import org.apache.http.HttpHost;
|
||||
import org.apache.http.client.config.RequestConfig;
|
||||
import org.apache.http.client.methods.CloseableHttpResponse;
|
||||
@@ -15,16 +16,6 @@ import org.apache.http.impl.client.CloseableHttpClient;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import cn.binarywang.wx.miniapp.api.WxMaAnalysisService;
|
||||
import cn.binarywang.wx.miniapp.api.WxMaCodeService;
|
||||
import cn.binarywang.wx.miniapp.api.WxMaJsapiService;
|
||||
import cn.binarywang.wx.miniapp.api.WxMaMediaService;
|
||||
import cn.binarywang.wx.miniapp.api.WxMaMsgService;
|
||||
import cn.binarywang.wx.miniapp.api.WxMaQrcodeService;
|
||||
import cn.binarywang.wx.miniapp.api.WxMaService;
|
||||
import cn.binarywang.wx.miniapp.api.WxMaSettingService;
|
||||
import cn.binarywang.wx.miniapp.api.WxMaTemplateService;
|
||||
import cn.binarywang.wx.miniapp.api.WxMaUserService;
|
||||
import cn.binarywang.wx.miniapp.bean.WxMaJscode2SessionResult;
|
||||
import cn.binarywang.wx.miniapp.config.WxMaConfig;
|
||||
import com.google.common.base.Joiner;
|
||||
@@ -65,6 +56,7 @@ public class WxMaServiceImpl implements WxMaService, RequestHttp<CloseableHttpCl
|
||||
private WxMaCodeService codeService = new WxMaCodeServiceImpl(this);
|
||||
private WxMaSettingService settingService = new WxMaSettingServiceImpl(this);
|
||||
private WxMaJsapiService jsapiService = new WxMaJsapiServiceImpl(this);
|
||||
private WxMaShareService shareService = new WxMaShareServiceImpl(this);
|
||||
|
||||
private int retrySleepMillis = 1000;
|
||||
private int maxRetryTimes = 5;
|
||||
@@ -335,4 +327,9 @@ public class WxMaServiceImpl implements WxMaService, RequestHttp<CloseableHttpCl
|
||||
public WxMaSettingService getSettingService() {
|
||||
return this.settingService;
|
||||
}
|
||||
|
||||
@Override
|
||||
public WxMaShareService getShareService() {
|
||||
return this.shareService;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
package cn.binarywang.wx.miniapp.api.impl;
|
||||
|
||||
import cn.binarywang.wx.miniapp.api.WxMaService;
|
||||
import cn.binarywang.wx.miniapp.api.WxMaShareService;
|
||||
import cn.binarywang.wx.miniapp.bean.WxMaShareInfo;
|
||||
import cn.binarywang.wx.miniapp.util.crypt.WxMaCryptUtils;
|
||||
|
||||
/**
|
||||
* @author zhfish
|
||||
*/
|
||||
public class WxMaShareServiceImpl implements WxMaShareService {
|
||||
private WxMaService service;
|
||||
|
||||
public WxMaShareServiceImpl(WxMaService service) {
|
||||
this.service = service;
|
||||
}
|
||||
|
||||
@Override
|
||||
public WxMaShareInfo getShareInfo(String sessionKey, String encryptedData, String ivStr) {
|
||||
return WxMaShareInfo.fromJson(WxMaCryptUtils.decrypt(sessionKey, encryptedData, ivStr));
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package cn.binarywang.wx.miniapp.bean;
|
||||
|
||||
import cn.binarywang.wx.miniapp.util.json.WxMaGsonBuilder;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @author zhfish
|
||||
*/
|
||||
@Data
|
||||
public class WxMaShareInfo implements Serializable {
|
||||
private static final long serialVersionUID = -8053613683499632226L;
|
||||
|
||||
private String openGId;
|
||||
|
||||
public static WxMaShareInfo fromJson(String json) {
|
||||
return WxMaGsonBuilder.create().fromJson(json, WxMaShareInfo.class);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user