mirror of
https://gitee.com/binary/weixin-java-tools.git
synced 2025-09-20 02:29:44 +08:00
fix javadoc
This commit is contained in:
@@ -12,7 +12,7 @@ import me.chanjar.weixin.common.util.http.RequestHttp;
|
||||
*/
|
||||
public interface WxMaService {
|
||||
/**
|
||||
* 获取access_token
|
||||
* 获取access_token.
|
||||
*/
|
||||
String GET_ACCESS_TOKEN_URL = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=%s&secret=%s";
|
||||
|
||||
@@ -25,14 +25,14 @@ public interface WxMaService {
|
||||
WxMaJscode2SessionResult jsCode2SessionInfo(String jsCode) throws WxErrorException;
|
||||
/**
|
||||
* <pre>
|
||||
* 验证消息的确来自微信服务器
|
||||
* 验证消息的确来自微信服务器.
|
||||
* 详情请见: http://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1421135319&token=&lang=zh_CN
|
||||
* </pre>
|
||||
*/
|
||||
boolean checkSignature(String timestamp, String nonce, String signature);
|
||||
|
||||
/**
|
||||
* 获取access_token, 不强制刷新access_token
|
||||
* 获取access_token, 不强制刷新access_token.
|
||||
*
|
||||
* @see #getAccessToken(boolean)
|
||||
*/
|
||||
@@ -40,7 +40,7 @@ public interface WxMaService {
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 获取access_token,本方法线程安全
|
||||
* 获取access_token,本方法线程安全.
|
||||
* 且在多线程同时刷新时只刷新一次,避免超出2000次/日的调用次数上限
|
||||
*
|
||||
* 另:本service的所有方法都会在access_token过期是调用此方法
|
||||
@@ -55,12 +55,12 @@ public interface WxMaService {
|
||||
String getAccessToken(boolean forceRefresh) throws WxErrorException;
|
||||
|
||||
/**
|
||||
* 当本Service没有实现某个API的时候,可以用这个,针对所有微信API中的GET请求
|
||||
* 当本Service没有实现某个API的时候,可以用这个,针对所有微信API中的GET请求.
|
||||
*/
|
||||
String get(String url, String queryParam) throws WxErrorException;
|
||||
|
||||
/**
|
||||
* 当本Service没有实现某个API的时候,可以用这个,针对所有微信API中的POST请求
|
||||
* 当本Service没有实现某个API的时候,可以用这个,针对所有微信API中的POST请求.
|
||||
*/
|
||||
String post(String url, String postData) throws WxErrorException;
|
||||
|
||||
@@ -75,7 +75,7 @@ public interface WxMaService {
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 设置当微信系统响应系统繁忙时,要等待多少 retrySleepMillis(ms) * 2^(重试次数 - 1) 再发起重试
|
||||
* 设置当微信系统响应系统繁忙时,要等待多少 retrySleepMillis(ms) * 2^(重试次数 - 1) 再发起重试.
|
||||
* 默认:1000ms
|
||||
* </pre>
|
||||
*/
|
||||
@@ -83,65 +83,65 @@ public interface WxMaService {
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 设置当微信系统响应系统繁忙时,最大重试次数
|
||||
* 设置当微信系统响应系统繁忙时,最大重试次数.
|
||||
* 默认:5次
|
||||
* </pre>
|
||||
*/
|
||||
void setMaxRetryTimes(int maxRetryTimes);
|
||||
|
||||
/**
|
||||
* 获取WxMaConfig 对象
|
||||
* 获取WxMaConfig 对象.
|
||||
*
|
||||
* @return WxMaConfig
|
||||
*/
|
||||
WxMaConfig getWxMaConfig();
|
||||
|
||||
/**
|
||||
* 注入 {@link WxMaConfig} 的实现
|
||||
* 注入 {@link WxMaConfig} 的实现.
|
||||
*/
|
||||
void setWxMaConfig(WxMaConfig wxConfigProvider);
|
||||
|
||||
/**
|
||||
* 返回消息(客服消息和模版消息)发送接口方法实现类,以方便调用其各个接口
|
||||
* 返回消息(客服消息和模版消息)发送接口方法实现类,以方便调用其各个接口.
|
||||
*
|
||||
* @return WxMaMsgService
|
||||
*/
|
||||
WxMaMsgService getMsgService();
|
||||
|
||||
/**
|
||||
* 返回素材相关接口方法的实现类对象,以方便调用其各个接口
|
||||
* 返回素材相关接口方法的实现类对象,以方便调用其各个接口.
|
||||
*
|
||||
* @return WxMaMediaService
|
||||
*/
|
||||
WxMaMediaService getMediaService();
|
||||
|
||||
/**
|
||||
* 返回用户相关接口方法的实现类对象,以方便调用其各个接口
|
||||
* 返回用户相关接口方法的实现类对象,以方便调用其各个接口.
|
||||
*
|
||||
* @return WxMaUserService
|
||||
*/
|
||||
WxMaUserService getUserService();
|
||||
|
||||
/**
|
||||
* 返回二维码相关接口方法的实现类对象,以方便调用其各个接口
|
||||
* 返回二维码相关接口方法的实现类对象,以方便调用其各个接口.
|
||||
*
|
||||
* @return WxMaQrcodeService
|
||||
*/
|
||||
WxMaQrcodeService getQrcodeService();
|
||||
|
||||
/**
|
||||
* 返回模板配置相关接口方法的实现类对象, 以方便调用其各个接口
|
||||
* 返回模板配置相关接口方法的实现类对象, 以方便调用其各个接口.
|
||||
* @return WxMaTemplateService
|
||||
*/
|
||||
WxMaTemplateService getTemplateService();
|
||||
|
||||
/**
|
||||
* 初始化http请求对象
|
||||
* 初始化http请求对象.
|
||||
*/
|
||||
void initHttp();
|
||||
|
||||
/**
|
||||
* 请求http请求相关信息
|
||||
* 请求http请求相关信息.
|
||||
*/
|
||||
RequestHttp getRequestHttp();
|
||||
|
||||
|
@@ -5,21 +5,21 @@ import cn.binarywang.wx.miniapp.bean.WxMaUserInfo;
|
||||
import me.chanjar.weixin.common.exception.WxErrorException;
|
||||
|
||||
/**
|
||||
* 用户信息相关操作接口
|
||||
* 用户信息相关操作接口.
|
||||
*
|
||||
* @author <a href="https://github.com/binarywang">Binary Wang</a>
|
||||
*/
|
||||
public interface WxMaUserService {
|
||||
|
||||
/**
|
||||
* 获取登录后的session信息
|
||||
* 获取登录后的session信息.
|
||||
*
|
||||
* @param jsCode 登录时获取的 code
|
||||
*/
|
||||
WxMaJscode2SessionResult getSessionInfo(String jsCode) throws WxErrorException;
|
||||
|
||||
/**
|
||||
* 解密用户敏感数据
|
||||
* 解密用户敏感数据.
|
||||
*
|
||||
* @param sessionKey 会话密钥
|
||||
* @param encryptedData 消息密文
|
||||
@@ -28,7 +28,7 @@ public interface WxMaUserService {
|
||||
WxMaUserInfo getUserInfo(String sessionKey, String encryptedData, String ivStr);
|
||||
|
||||
/**
|
||||
* 验证用户信息完整性
|
||||
* 验证用户信息完整性.
|
||||
*
|
||||
* @param sessionKey 会话密钥
|
||||
* @param rawData 微信用户基本信息
|
||||
|
@@ -1,18 +1,10 @@
|
||||
package cn.binarywang.wx.miniapp.api.impl;
|
||||
|
||||
import cn.binarywang.wx.miniapp.api.*;
|
||||
import cn.binarywang.wx.miniapp.bean.WxMaJscode2SessionResult;
|
||||
import cn.binarywang.wx.miniapp.config.WxMaConfig;
|
||||
import cn.binarywang.wx.miniapp.constant.WxMaConstants;
|
||||
import com.google.common.base.Joiner;
|
||||
import com.google.gson.JsonParser;
|
||||
import me.chanjar.weixin.common.bean.WxAccessToken;
|
||||
import me.chanjar.weixin.common.bean.result.WxError;
|
||||
import me.chanjar.weixin.common.exception.WxErrorException;
|
||||
import me.chanjar.weixin.common.util.crypto.SHA1;
|
||||
import me.chanjar.weixin.common.util.http.*;
|
||||
import me.chanjar.weixin.common.util.http.apache.ApacheHttpClientBuilder;
|
||||
import me.chanjar.weixin.common.util.http.apache.DefaultApacheHttpClientBuilder;
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.locks.Lock;
|
||||
|
||||
import org.apache.http.HttpHost;
|
||||
import org.apache.http.client.config.RequestConfig;
|
||||
import org.apache.http.client.methods.CloseableHttpResponse;
|
||||
@@ -22,16 +14,32 @@ import org.apache.http.impl.client.CloseableHttpClient;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.locks.Lock;
|
||||
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.WxMaTemplateService;
|
||||
import cn.binarywang.wx.miniapp.api.WxMaUserService;
|
||||
import cn.binarywang.wx.miniapp.bean.WxMaJscode2SessionResult;
|
||||
import cn.binarywang.wx.miniapp.config.WxMaConfig;
|
||||
import cn.binarywang.wx.miniapp.constant.WxMaConstants;
|
||||
import com.google.common.base.Joiner;
|
||||
import me.chanjar.weixin.common.bean.WxAccessToken;
|
||||
import me.chanjar.weixin.common.bean.result.WxError;
|
||||
import me.chanjar.weixin.common.exception.WxErrorException;
|
||||
import me.chanjar.weixin.common.util.crypto.SHA1;
|
||||
import me.chanjar.weixin.common.util.http.HttpType;
|
||||
import me.chanjar.weixin.common.util.http.RequestExecutor;
|
||||
import me.chanjar.weixin.common.util.http.RequestHttp;
|
||||
import me.chanjar.weixin.common.util.http.SimpleGetRequestExecutor;
|
||||
import me.chanjar.weixin.common.util.http.SimplePostRequestExecutor;
|
||||
import me.chanjar.weixin.common.util.http.apache.ApacheHttpClientBuilder;
|
||||
import me.chanjar.weixin.common.util.http.apache.DefaultApacheHttpClientBuilder;
|
||||
|
||||
/**
|
||||
* @author <a href="https://github.com/binarywang">Binary Wang</a>
|
||||
*/
|
||||
public class WxMaServiceImpl implements WxMaService, RequestHttp<CloseableHttpClient, HttpHost> {
|
||||
private static final JsonParser JSON_PARSER = new JsonParser();
|
||||
private final Logger log = LoggerFactory.getLogger(this.getClass());
|
||||
|
||||
private CloseableHttpClient httpClient;
|
||||
@@ -137,6 +145,7 @@ public class WxMaServiceImpl implements WxMaService, RequestHttp<CloseableHttpCl
|
||||
String result = get(JSCODE_TO_SESSION_URL, Joiner.on("&").withKeyValueSeparator("=").join(params));
|
||||
return WxMaJscode2SessionResult.fromJson(result);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkSignature(String timestamp, String nonce, String signature) {
|
||||
try {
|
||||
|
@@ -1,5 +1,10 @@
|
||||
package cn.binarywang.wx.miniapp.api.impl;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.commons.codec.digest.DigestUtils;
|
||||
|
||||
import cn.binarywang.wx.miniapp.api.WxMaService;
|
||||
import cn.binarywang.wx.miniapp.api.WxMaUserService;
|
||||
import cn.binarywang.wx.miniapp.bean.WxMaJscode2SessionResult;
|
||||
@@ -8,10 +13,6 @@ import cn.binarywang.wx.miniapp.config.WxMaConfig;
|
||||
import cn.binarywang.wx.miniapp.util.crypt.WxMaCryptUtils;
|
||||
import com.google.common.base.Joiner;
|
||||
import me.chanjar.weixin.common.exception.WxErrorException;
|
||||
import org.apache.commons.codec.digest.DigestUtils;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author <a href="https://github.com/binarywang">Binary Wang</a>
|
||||
|
Reference in New Issue
Block a user