@@ -1,14 +1,14 @@ | |||||
package me.chanjar.weixin.common.bean; | package me.chanjar.weixin.common.bean; | ||||
import me.chanjar.weixin.common.util.json.WxGsonBuilder; | |||||
import org.apache.commons.codec.Charsets; | |||||
import java.io.InputStream; | import java.io.InputStream; | ||||
import java.io.InputStreamReader; | import java.io.InputStreamReader; | ||||
import java.io.Serializable; | import java.io.Serializable; | ||||
import java.nio.charset.StandardCharsets; | |||||
import java.util.ArrayList; | import java.util.ArrayList; | ||||
import java.util.List; | import java.util.List; | ||||
import me.chanjar.weixin.common.util.json.WxGsonBuilder; | |||||
/** | /** | ||||
* 企业号菜单 | * 企业号菜单 | ||||
* @author Daniel Qian | * @author Daniel Qian | ||||
@@ -45,8 +45,6 @@ public class WxMenu implements Serializable { | |||||
/** | /** | ||||
* 要用 http://mp.weixin.qq.com/wiki/16/ff9b7b85220e1396ffa16794a9d95adc.html 格式来反序列化 | * 要用 http://mp.weixin.qq.com/wiki/16/ff9b7b85220e1396ffa16794a9d95adc.html 格式来反序列化 | ||||
* 相比 http://mp.weixin.qq.com/wiki/13/43de8269be54a0a6f64413e4dfa94f39.html 的格式,外层多套了一个menu | * 相比 http://mp.weixin.qq.com/wiki/13/43de8269be54a0a6f64413e4dfa94f39.html 的格式,外层多套了一个menu | ||||
* @param json | |||||
* @return | |||||
*/ | */ | ||||
public static WxMenu fromJson(String json) { | public static WxMenu fromJson(String json) { | ||||
return WxGsonBuilder.create().fromJson(json, WxMenu.class); | return WxGsonBuilder.create().fromJson(json, WxMenu.class); | ||||
@@ -55,11 +53,9 @@ public class WxMenu implements Serializable { | |||||
/** | /** | ||||
* 要用 http://mp.weixin.qq.com/wiki/16/ff9b7b85220e1396ffa16794a9d95adc.html 格式来反序列化 | * 要用 http://mp.weixin.qq.com/wiki/16/ff9b7b85220e1396ffa16794a9d95adc.html 格式来反序列化 | ||||
* 相比 http://mp.weixin.qq.com/wiki/13/43de8269be54a0a6f64413e4dfa94f39.html 的格式,外层多套了一个menu | * 相比 http://mp.weixin.qq.com/wiki/13/43de8269be54a0a6f64413e4dfa94f39.html 的格式,外层多套了一个menu | ||||
* @param is | |||||
* @return | |||||
*/ | */ | ||||
public static WxMenu fromJson(InputStream is) { | public static WxMenu fromJson(InputStream is) { | ||||
return WxGsonBuilder.create().fromJson(new InputStreamReader(is, Charsets.UTF_8), WxMenu.class); | |||||
return WxGsonBuilder.create().fromJson(new InputStreamReader(is, StandardCharsets.UTF_8), WxMenu.class); | |||||
} | } | ||||
@Override | @Override | ||||
@@ -195,7 +191,7 @@ public class WxMenu implements Serializable { | |||||
this.language = language; | this.language = language; | ||||
} | } | ||||
@Override | |||||
@Override | |||||
public String toString() { | public String toString() { | ||||
return "matchrule:{" + | return "matchrule:{" + | ||||
"tag_id='" + tagId + '\'' + | "tag_id='" + tagId + '\'' + | ||||
@@ -4,16 +4,11 @@ public interface WxSessionManager { | |||||
/** | /** | ||||
* 获取某个sessionId对应的session,如果sessionId没有对应的session,则新建一个并返回。 | * 获取某个sessionId对应的session,如果sessionId没有对应的session,则新建一个并返回。 | ||||
* @param sessionId | |||||
* @return | |||||
*/ | */ | ||||
public WxSession getSession(String sessionId); | public WxSession getSession(String sessionId); | ||||
/** | /** | ||||
* 获取某个sessionId对应的session,如果sessionId没有对应的session,若create为true则新建一个,否则返回null。 | * 获取某个sessionId对应的session,如果sessionId没有对应的session,若create为true则新建一个,否则返回null。 | ||||
* @param sessionId | |||||
* @param create | |||||
* @return | |||||
*/ | */ | ||||
public WxSession getSession(String sessionId, boolean create); | public WxSession getSession(String sessionId, boolean create); | ||||
@@ -12,9 +12,6 @@ public class SHA1 { | |||||
/** | /** | ||||
* 串接arr参数,生成sha1 digest | * 串接arr参数,生成sha1 digest | ||||
* | |||||
* @param arr | |||||
* @return | |||||
*/ | */ | ||||
public static String gen(String... arr) throws NoSuchAlgorithmException { | public static String gen(String... arr) throws NoSuchAlgorithmException { | ||||
Arrays.sort(arr); | Arrays.sort(arr); | ||||
@@ -27,9 +24,6 @@ public class SHA1 { | |||||
/** | /** | ||||
* 用&串接arr参数,生成sha1 digest | * 用&串接arr参数,生成sha1 digest | ||||
* | |||||
* @param arr | |||||
* @return | |||||
*/ | */ | ||||
public static String genWithAmple(String... arr) throws NoSuchAlgorithmException { | public static String genWithAmple(String... arr) throws NoSuchAlgorithmException { | ||||
Arrays.sort(arr); | Arrays.sort(arr); | ||||
@@ -35,16 +35,16 @@ public class WxCryptUtil { | |||||
private static final Base64 base64 = new Base64(); | private static final Base64 base64 = new Base64(); | ||||
private static final Charset CHARSET = Charset.forName("utf-8"); | private static final Charset CHARSET = Charset.forName("utf-8"); | ||||
private static final ThreadLocal<DocumentBuilder> builderLocal = | |||||
new ThreadLocal<DocumentBuilder>() { | |||||
@Override protected DocumentBuilder initialValue() { | |||||
try { | |||||
return DocumentBuilderFactory.newInstance().newDocumentBuilder(); | |||||
} catch (ParserConfigurationException exc) { | |||||
throw new IllegalArgumentException(exc); | |||||
} | |||||
} | |||||
}; | |||||
private static final ThreadLocal<DocumentBuilder> builderLocal = new ThreadLocal<DocumentBuilder>() { | |||||
@Override | |||||
protected DocumentBuilder initialValue() { | |||||
try { | |||||
return DocumentBuilderFactory.newInstance().newDocumentBuilder(); | |||||
} catch (ParserConfigurationException exc) { | |||||
throw new IllegalArgumentException(exc); | |||||
} | |||||
} | |||||
}; | |||||
protected byte[] aesKey; | protected byte[] aesKey; | ||||
protected String token; | protected String token; | ||||
@@ -61,7 +61,8 @@ public class WxCryptUtil { | |||||
* @param encodingAesKey 公众平台上,开发者设置的EncodingAESKey | * @param encodingAesKey 公众平台上,开发者设置的EncodingAESKey | ||||
* @param appidOrCorpid 公众平台appid/corpid | * @param appidOrCorpid 公众平台appid/corpid | ||||
*/ | */ | ||||
public WxCryptUtil(String token, String encodingAesKey, String appidOrCorpid) { | |||||
public WxCryptUtil(String token, String encodingAesKey, | |||||
String appidOrCorpid) { | |||||
this.token = token; | this.token = token; | ||||
this.appidOrCorpid = appidOrCorpid; | this.appidOrCorpid = appidOrCorpid; | ||||
this.aesKey = Base64.decodeBase64(encodingAesKey + "="); | this.aesKey = Base64.decodeBase64(encodingAesKey + "="); | ||||
@@ -105,7 +106,8 @@ public class WxCryptUtil { | |||||
ByteGroup byteCollector = new ByteGroup(); | ByteGroup byteCollector = new ByteGroup(); | ||||
byte[] randomStringBytes = randomStr.getBytes(CHARSET); | byte[] randomStringBytes = randomStr.getBytes(CHARSET); | ||||
byte[] plainTextBytes = plainText.getBytes(CHARSET); | byte[] plainTextBytes = plainText.getBytes(CHARSET); | ||||
byte[] bytesOfSizeInNetworkOrder = number2BytesInNetworkOrder(plainTextBytes.length); | |||||
byte[] bytesOfSizeInNetworkOrder = number2BytesInNetworkOrder( | |||||
plainTextBytes.length); | |||||
byte[] appIdBytes = appidOrCorpid.getBytes(CHARSET); | byte[] appIdBytes = appidOrCorpid.getBytes(CHARSET); | ||||
// randomStr + networkBytesOrder + text + appid | // randomStr + networkBytesOrder + text + appid | ||||
@@ -154,7 +156,8 @@ public class WxCryptUtil { | |||||
* @param encryptedXml 密文,对应POST请求的数据 | * @param encryptedXml 密文,对应POST请求的数据 | ||||
* @return 解密后的原文 | * @return 解密后的原文 | ||||
*/ | */ | ||||
public String decrypt(String msgSignature, String timeStamp, String nonce, String encryptedXml) { | |||||
public String decrypt(String msgSignature, String timeStamp, String nonce, | |||||
String encryptedXml) { | |||||
// 密钥,公众账号的app corpSecret | // 密钥,公众账号的app corpSecret | ||||
// 提取密文 | // 提取密文 | ||||
String cipherText = extractEncryptPart(encryptedXml); | String cipherText = extractEncryptPart(encryptedXml); | ||||
@@ -186,7 +189,8 @@ public class WxCryptUtil { | |||||
// 设置解密模式为AES的CBC模式 | // 设置解密模式为AES的CBC模式 | ||||
Cipher cipher = Cipher.getInstance("AES/CBC/NoPadding"); | Cipher cipher = Cipher.getInstance("AES/CBC/NoPadding"); | ||||
SecretKeySpec key_spec = new SecretKeySpec(aesKey, "AES"); | SecretKeySpec key_spec = new SecretKeySpec(aesKey, "AES"); | ||||
IvParameterSpec iv = new IvParameterSpec(Arrays.copyOfRange(aesKey, 0, 16)); | |||||
IvParameterSpec iv = new IvParameterSpec( | |||||
Arrays.copyOfRange(aesKey, 0, 16)); | |||||
cipher.init(Cipher.DECRYPT_MODE, key_spec, iv); | cipher.init(Cipher.DECRYPT_MODE, key_spec, iv); | ||||
// 使用BASE64对密文进行解码 | // 使用BASE64对密文进行解码 | ||||
@@ -208,9 +212,10 @@ public class WxCryptUtil { | |||||
int xmlLength = bytesNetworkOrder2Number(networkOrder); | int xmlLength = bytesNetworkOrder2Number(networkOrder); | ||||
xmlContent = new String(Arrays.copyOfRange(bytes, 20, 20 + xmlLength), CHARSET); | |||||
from_appid = new String(Arrays.copyOfRange(bytes, 20 + xmlLength, bytes.length), | |||||
xmlContent = new String(Arrays.copyOfRange(bytes, 20, 20 + xmlLength), | |||||
CHARSET); | CHARSET); | ||||
from_appid = new String( | |||||
Arrays.copyOfRange(bytes, 20 + xmlLength, bytes.length), CHARSET); | |||||
} catch (Exception e) { | } catch (Exception e) { | ||||
throw new RuntimeException(e); | throw new RuntimeException(e); | ||||
} | } | ||||
@@ -224,34 +229,32 @@ public class WxCryptUtil { | |||||
} | } | ||||
/** | |||||
* 微信公众号支付签名算法(详见:http://pay.weixin.qq.com/wiki/doc/api/index.php?chapter=4_3) | |||||
* @param packageParams 原始参数 | |||||
* @param signKey 加密Key(即 商户Key) | |||||
* @param charset 编码 | |||||
* @return 签名字符串 | |||||
*/ | |||||
public static String createSign(Map<String, String> packageParams, String signKey) { | |||||
SortedMap<String, String> sortedMap = new TreeMap<String, String>(); | |||||
sortedMap.putAll(packageParams); | |||||
List<String> keys = new ArrayList<String>(packageParams.keySet()); | |||||
Collections.sort(keys); | |||||
StringBuffer toSign = new StringBuffer(); | |||||
for (String key : keys) { | |||||
String value = packageParams.get(key); | |||||
if (null != value && !"".equals(value) && !"sign".equals(key) | |||||
&& !"key".equals(key)) { | |||||
toSign.append(key + "=" + value + "&"); | |||||
} | |||||
} | |||||
toSign.append("key=" + signKey); | |||||
String sign = DigestUtils.md5Hex(toSign.toString()) | |||||
.toUpperCase(); | |||||
return sign; | |||||
/** | |||||
* 微信公众号支付签名算法(详见:http://pay.weixin.qq.com/wiki/doc/api/index.php?chapter=4_3) | |||||
* @param packageParams 原始参数 | |||||
* @param signKey 加密Key(即 商户Key) | |||||
* @return 签名字符串 | |||||
*/ | |||||
public static String createSign(Map<String, String> packageParams, | |||||
String signKey) { | |||||
SortedMap<String, String> sortedMap = new TreeMap<String, String>(); | |||||
sortedMap.putAll(packageParams); | |||||
List<String> keys = new ArrayList<String>(packageParams.keySet()); | |||||
Collections.sort(keys); | |||||
StringBuffer toSign = new StringBuffer(); | |||||
for (String key : keys) { | |||||
String value = packageParams.get(key); | |||||
if (null != value && !"".equals(value) && !"sign".equals(key) | |||||
&& !"key".equals(key)) { | |||||
toSign.append(key + "=" + value + "&"); | |||||
} | |||||
} | } | ||||
toSign.append("key=" + signKey); | |||||
String sign = DigestUtils.md5Hex(toSign.toString()).toUpperCase(); | |||||
return sign; | |||||
} | |||||
/** | /** | ||||
* 将一个数字转换成生成4个字节的网络字节序bytes数组 | * 将一个数字转换成生成4个字节的网络字节序bytes数组 | ||||
@@ -283,8 +286,6 @@ public class WxCryptUtil { | |||||
/** | /** | ||||
* 随机生成16位字符串 | * 随机生成16位字符串 | ||||
* | |||||
* @return | |||||
*/ | */ | ||||
private String genRandomStr() { | private String genRandomStr() { | ||||
String base = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"; | String base = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"; | ||||
@@ -306,14 +307,12 @@ public class WxCryptUtil { | |||||
* @param nonce 随机字符串 | * @param nonce 随机字符串 | ||||
* @return 生成的xml字符串 | * @return 生成的xml字符串 | ||||
*/ | */ | ||||
private String generateXml(String encrypt, String signature, String timestamp, String nonce) { | |||||
String format = | |||||
"<xml>\n" | |||||
+ "<Encrypt><![CDATA[%1$s]]></Encrypt>\n" | |||||
+ "<MsgSignature><![CDATA[%2$s]]></MsgSignature>\n" | |||||
+ "<TimeStamp>%3$s</TimeStamp>\n" | |||||
+ "<Nonce><![CDATA[%4$s]]></Nonce>\n" | |||||
+ "</xml>"; | |||||
private String generateXml(String encrypt, String signature, String timestamp, | |||||
String nonce) { | |||||
String format = "<xml>\n" + "<Encrypt><![CDATA[%1$s]]></Encrypt>\n" | |||||
+ "<MsgSignature><![CDATA[%2$s]]></MsgSignature>\n" | |||||
+ "<TimeStamp>%3$s</TimeStamp>\n" + "<Nonce><![CDATA[%4$s]]></Nonce>\n" | |||||
+ "</xml>"; | |||||
return String.format(format, encrypt, signature, timestamp, nonce); | return String.format(format, encrypt, signature, timestamp, nonce); | ||||
} | } | ||||
@@ -14,8 +14,6 @@ public class FileUtils { | |||||
* @param name 文件名 | * @param name 文件名 | ||||
* @param ext 扩展名 | * @param ext 扩展名 | ||||
* @param tmpDirFile 临时文件夹目录 | * @param tmpDirFile 临时文件夹目录 | ||||
* @return | |||||
* @throws IOException | |||||
*/ | */ | ||||
public static File createTmpFile(InputStream inputStream, String name, String ext, File tmpDirFile) throws IOException { | public static File createTmpFile(InputStream inputStream, String name, String ext, File tmpDirFile) throws IOException { | ||||
FileOutputStream fos = null; | FileOutputStream fos = null; | ||||
@@ -56,8 +54,6 @@ public class FileUtils { | |||||
* @param inputStream | * @param inputStream | ||||
* @param name 文件名 | * @param name 文件名 | ||||
* @param ext 扩展名 | * @param ext 扩展名 | ||||
* @return | |||||
* @throws IOException | |||||
*/ | */ | ||||
public static File createTmpFile(InputStream inputStream, String name, String ext) throws IOException { | public static File createTmpFile(InputStream inputStream, String name, String ext) throws IOException { | ||||
return createTmpFile(inputStream, name, ext, null); | return createTmpFile(inputStream, name, ext, null); | ||||
@@ -17,35 +17,30 @@ public interface ApacheHttpClientBuilder { | |||||
/** | /** | ||||
* 代理服务器地址 | * 代理服务器地址 | ||||
* @param httpProxyHost | * @param httpProxyHost | ||||
* @return | |||||
*/ | */ | ||||
ApacheHttpClientBuilder httpProxyHost(String httpProxyHost); | ApacheHttpClientBuilder httpProxyHost(String httpProxyHost); | ||||
/** | /** | ||||
* 代理服务器端口 | * 代理服务器端口 | ||||
* @param httpProxyPort | * @param httpProxyPort | ||||
* @return | |||||
*/ | */ | ||||
ApacheHttpClientBuilder httpProxyPort(int httpProxyPort); | ApacheHttpClientBuilder httpProxyPort(int httpProxyPort); | ||||
/** | /** | ||||
* 代理服务器用户名 | * 代理服务器用户名 | ||||
* @param httpProxyUsername | * @param httpProxyUsername | ||||
* @return | |||||
*/ | */ | ||||
ApacheHttpClientBuilder httpProxyUsername(String httpProxyUsername); | ApacheHttpClientBuilder httpProxyUsername(String httpProxyUsername); | ||||
/** | /** | ||||
* 代理服务器密码 | * 代理服务器密码 | ||||
* @param httpProxyPassword | * @param httpProxyPassword | ||||
* @return | |||||
*/ | */ | ||||
ApacheHttpClientBuilder httpProxyPassword(String httpProxyPassword); | ApacheHttpClientBuilder httpProxyPassword(String httpProxyPassword); | ||||
/** | /** | ||||
* ssl连接socket工厂 | * ssl连接socket工厂 | ||||
* @param sslConnectionSocketFactory | * @param sslConnectionSocketFactory | ||||
* @return | |||||
*/ | */ | ||||
ApacheHttpClientBuilder sslConnectionSocketFactory(SSLConnectionSocketFactory sslConnectionSocketFactory); | ApacheHttpClientBuilder sslConnectionSocketFactory(SSLConnectionSocketFactory sslConnectionSocketFactory); | ||||
} | } |
@@ -22,7 +22,6 @@ public interface RequestExecutor<T, E> { | |||||
* @param httpProxy http代理对象,如果没有配置代理则为空 | * @param httpProxy http代理对象,如果没有配置代理则为空 | ||||
* @param uri uri | * @param uri uri | ||||
* @param data 数据 | * @param data 数据 | ||||
* @return | |||||
* @throws WxErrorException | * @throws WxErrorException | ||||
* @throws ClientProtocolException | * @throws ClientProtocolException | ||||
* @throws IOException | * @throws IOException | ||||
@@ -9,8 +9,6 @@ public interface WxCpMessageMatcher { | |||||
/** | /** | ||||
* 消息是否匹配某种模式 | * 消息是否匹配某种模式 | ||||
* @param message | |||||
* @return | |||||
*/ | */ | ||||
public boolean match(WxCpXmlMessage message); | public boolean match(WxCpXmlMessage message); | ||||
@@ -124,7 +124,6 @@ public class WxCpMessageRouter { | |||||
/** | /** | ||||
* 开始一个新的Route规则 | * 开始一个新的Route规则 | ||||
* @return | |||||
*/ | */ | ||||
public WxCpMessageRouterRule rule() { | public WxCpMessageRouterRule rule() { | ||||
return new WxCpMessageRouterRule(this); | return new WxCpMessageRouterRule(this); | ||||
@@ -48,7 +48,6 @@ public class WxCpMessageRouterRule { | |||||
* 设置是否异步执行,默认是true | * 设置是否异步执行,默认是true | ||||
* | * | ||||
* @param async | * @param async | ||||
* @return | |||||
*/ | */ | ||||
public WxCpMessageRouterRule async(boolean async) { | public WxCpMessageRouterRule async(boolean async) { | ||||
this.async = async; | this.async = async; | ||||
@@ -59,7 +58,6 @@ public class WxCpMessageRouterRule { | |||||
* 如果agentId匹配 | * 如果agentId匹配 | ||||
* | * | ||||
* @param agentId | * @param agentId | ||||
* @return | |||||
*/ | */ | ||||
public WxCpMessageRouterRule agentId(Integer agentId) { | public WxCpMessageRouterRule agentId(Integer agentId) { | ||||
this.agentId = agentId; | this.agentId = agentId; | ||||
@@ -70,7 +68,6 @@ public class WxCpMessageRouterRule { | |||||
* 如果msgType等于某值 | * 如果msgType等于某值 | ||||
* | * | ||||
* @param msgType | * @param msgType | ||||
* @return | |||||
*/ | */ | ||||
public WxCpMessageRouterRule msgType(String msgType) { | public WxCpMessageRouterRule msgType(String msgType) { | ||||
this.msgType = msgType; | this.msgType = msgType; | ||||
@@ -81,7 +78,6 @@ public class WxCpMessageRouterRule { | |||||
* 如果event等于某值 | * 如果event等于某值 | ||||
* | * | ||||
* @param event | * @param event | ||||
* @return | |||||
*/ | */ | ||||
public WxCpMessageRouterRule event(String event) { | public WxCpMessageRouterRule event(String event) { | ||||
this.event = event; | this.event = event; | ||||
@@ -92,7 +88,6 @@ public class WxCpMessageRouterRule { | |||||
* 如果eventKey等于某值 | * 如果eventKey等于某值 | ||||
* | * | ||||
* @param eventKey | * @param eventKey | ||||
* @return | |||||
*/ | */ | ||||
public WxCpMessageRouterRule eventKey(String eventKey) { | public WxCpMessageRouterRule eventKey(String eventKey) { | ||||
this.eventKey = eventKey; | this.eventKey = eventKey; | ||||
@@ -103,7 +98,6 @@ public class WxCpMessageRouterRule { | |||||
* 如果content等于某值 | * 如果content等于某值 | ||||
* | * | ||||
* @param content | * @param content | ||||
* @return | |||||
*/ | */ | ||||
public WxCpMessageRouterRule content(String content) { | public WxCpMessageRouterRule content(String content) { | ||||
this.content = content; | this.content = content; | ||||
@@ -114,7 +108,6 @@ public class WxCpMessageRouterRule { | |||||
* 如果content匹配该正则表达式 | * 如果content匹配该正则表达式 | ||||
* | * | ||||
* @param regex | * @param regex | ||||
* @return | |||||
*/ | */ | ||||
public WxCpMessageRouterRule rContent(String regex) { | public WxCpMessageRouterRule rContent(String regex) { | ||||
this.rContent = regex; | this.rContent = regex; | ||||
@@ -125,7 +118,6 @@ public class WxCpMessageRouterRule { | |||||
* 如果fromUser等于某值 | * 如果fromUser等于某值 | ||||
* | * | ||||
* @param fromUser | * @param fromUser | ||||
* @return | |||||
*/ | */ | ||||
public WxCpMessageRouterRule fromUser(String fromUser) { | public WxCpMessageRouterRule fromUser(String fromUser) { | ||||
this.fromUser = fromUser; | this.fromUser = fromUser; | ||||
@@ -136,7 +128,6 @@ public class WxCpMessageRouterRule { | |||||
* 如果消息匹配某个matcher,用在用户需要自定义更复杂的匹配规则的时候 | * 如果消息匹配某个matcher,用在用户需要自定义更复杂的匹配规则的时候 | ||||
* | * | ||||
* @param matcher | * @param matcher | ||||
* @return | |||||
*/ | */ | ||||
public WxCpMessageRouterRule matcher(WxCpMessageMatcher matcher) { | public WxCpMessageRouterRule matcher(WxCpMessageMatcher matcher) { | ||||
this.matcher = matcher; | this.matcher = matcher; | ||||
@@ -147,7 +138,6 @@ public class WxCpMessageRouterRule { | |||||
* 设置微信消息拦截器 | * 设置微信消息拦截器 | ||||
* | * | ||||
* @param interceptor | * @param interceptor | ||||
* @return | |||||
*/ | */ | ||||
public WxCpMessageRouterRule interceptor(WxCpMessageInterceptor interceptor) { | public WxCpMessageRouterRule interceptor(WxCpMessageInterceptor interceptor) { | ||||
return interceptor(interceptor, (WxCpMessageInterceptor[]) null); | return interceptor(interceptor, (WxCpMessageInterceptor[]) null); | ||||
@@ -158,7 +148,6 @@ public class WxCpMessageRouterRule { | |||||
* | * | ||||
* @param interceptor | * @param interceptor | ||||
* @param otherInterceptors | * @param otherInterceptors | ||||
* @return | |||||
*/ | */ | ||||
public WxCpMessageRouterRule interceptor(WxCpMessageInterceptor interceptor, WxCpMessageInterceptor... otherInterceptors) { | public WxCpMessageRouterRule interceptor(WxCpMessageInterceptor interceptor, WxCpMessageInterceptor... otherInterceptors) { | ||||
this.interceptors.add(interceptor); | this.interceptors.add(interceptor); | ||||
@@ -174,7 +163,6 @@ public class WxCpMessageRouterRule { | |||||
* 设置微信消息处理器 | * 设置微信消息处理器 | ||||
* | * | ||||
* @param handler | * @param handler | ||||
* @return | |||||
*/ | */ | ||||
public WxCpMessageRouterRule handler(WxCpMessageHandler handler) { | public WxCpMessageRouterRule handler(WxCpMessageHandler handler) { | ||||
return handler(handler, (WxCpMessageHandler[]) null); | return handler(handler, (WxCpMessageHandler[]) null); | ||||
@@ -185,7 +173,6 @@ public class WxCpMessageRouterRule { | |||||
* | * | ||||
* @param handler | * @param handler | ||||
* @param otherHandlers | * @param otherHandlers | ||||
* @return | |||||
*/ | */ | ||||
public WxCpMessageRouterRule handler(WxCpMessageHandler handler, WxCpMessageHandler... otherHandlers) { | public WxCpMessageRouterRule handler(WxCpMessageHandler handler, WxCpMessageHandler... otherHandlers) { | ||||
this.handlers.add(handler); | this.handlers.add(handler); | ||||
@@ -200,7 +187,6 @@ public class WxCpMessageRouterRule { | |||||
/** | /** | ||||
* 规则结束,代表如果一个消息匹配该规则,那么它将不再会进入其他规则 | * 规则结束,代表如果一个消息匹配该规则,那么它将不再会进入其他规则 | ||||
* | * | ||||
* @return | |||||
*/ | */ | ||||
public WxCpMessageRouter end() { | public WxCpMessageRouter end() { | ||||
this.routerBuilder.getRules().add(this); | this.routerBuilder.getRules().add(this); | ||||
@@ -210,7 +196,6 @@ public class WxCpMessageRouterRule { | |||||
/** | /** | ||||
* 规则结束,但是消息还会进入其他规则 | * 规则结束,但是消息还会进入其他规则 | ||||
* | * | ||||
* @return | |||||
*/ | */ | ||||
public WxCpMessageRouter next() { | public WxCpMessageRouter next() { | ||||
this.reEnter = true; | this.reEnter = true; | ||||
@@ -32,7 +32,6 @@ public interface WxCpService { | |||||
* @param timestamp | * @param timestamp | ||||
* @param nonce | * @param nonce | ||||
* @param data 微信传输过来的数据,有可能是echoStr,有可能是xml消息 | * @param data 微信传输过来的数据,有可能是echoStr,有可能是xml消息 | ||||
* @return | |||||
*/ | */ | ||||
boolean checkSignature(String msgSignature, String timestamp, String nonce, String data); | boolean checkSignature(String msgSignature, String timestamp, String nonce, String data); | ||||
@@ -49,7 +48,6 @@ public interface WxCpService { | |||||
/** | /** | ||||
* 获取access_token, 不强制刷新access_token | * 获取access_token, 不强制刷新access_token | ||||
* @see #getAccessToken(boolean) | * @see #getAccessToken(boolean) | ||||
* @return | |||||
* @throws WxErrorException | * @throws WxErrorException | ||||
*/ | */ | ||||
String getAccessToken() throws WxErrorException; | String getAccessToken() throws WxErrorException; | ||||
@@ -63,7 +61,6 @@ public interface WxCpService { | |||||
* 详情请见: http://mp.weixin.qq.com/wiki/index.php?title=获取access_token | * 详情请见: http://mp.weixin.qq.com/wiki/index.php?title=获取access_token | ||||
* </pre> | * </pre> | ||||
* @param forceRefresh 强制刷新 | * @param forceRefresh 强制刷新 | ||||
* @return | |||||
* @throws me.chanjar.weixin.common.exception.WxErrorException | * @throws me.chanjar.weixin.common.exception.WxErrorException | ||||
*/ | */ | ||||
String getAccessToken(boolean forceRefresh) throws WxErrorException; | String getAccessToken(boolean forceRefresh) throws WxErrorException; | ||||
@@ -71,7 +68,6 @@ public interface WxCpService { | |||||
/** | /** | ||||
* 获得jsapi_ticket,不强制刷新jsapi_ticket | * 获得jsapi_ticket,不强制刷新jsapi_ticket | ||||
* @see #getJsapiTicket(boolean) | * @see #getJsapiTicket(boolean) | ||||
* @return | |||||
* @throws WxErrorException | * @throws WxErrorException | ||||
*/ | */ | ||||
public String getJsapiTicket() throws WxErrorException; | public String getJsapiTicket() throws WxErrorException; | ||||
@@ -84,7 +80,6 @@ public interface WxCpService { | |||||
* 详情请见:http://qydev.weixin.qq.com/wiki/index.php?title=微信JS接口#.E9.99.84.E5.BD.951-JS-SDK.E4.BD.BF.E7.94.A8.E6.9D.83.E9.99.90.E7.AD.BE.E5.90.8D.E7.AE.97.E6.B3.95 | * 详情请见:http://qydev.weixin.qq.com/wiki/index.php?title=微信JS接口#.E9.99.84.E5.BD.951-JS-SDK.E4.BD.BF.E7.94.A8.E6.9D.83.E9.99.90.E7.AD.BE.E5.90.8D.E7.AE.97.E6.B3.95 | ||||
* </pre> | * </pre> | ||||
* @param forceRefresh 强制刷新 | * @param forceRefresh 强制刷新 | ||||
* @return | |||||
* @throws WxErrorException | * @throws WxErrorException | ||||
*/ | */ | ||||
public String getJsapiTicket(boolean forceRefresh) throws WxErrorException; | public String getJsapiTicket(boolean forceRefresh) throws WxErrorException; | ||||
@@ -96,7 +91,6 @@ public interface WxCpService { | |||||
* 详情请见:http://qydev.weixin.qq.com/wiki/index.php?title=微信JS接口#.E9.99.84.E5.BD.951-JS-SDK.E4.BD.BF.E7.94.A8.E6.9D.83.E9.99.90.E7.AD.BE.E5.90.8D.E7.AE.97.E6.B3.95 | * 详情请见:http://qydev.weixin.qq.com/wiki/index.php?title=微信JS接口#.E9.99.84.E5.BD.951-JS-SDK.E4.BD.BF.E7.94.A8.E6.9D.83.E9.99.90.E7.AD.BE.E5.90.8D.E7.AE.97.E6.B3.95 | ||||
* </pre> | * </pre> | ||||
* @param url url | * @param url url | ||||
* @return | |||||
*/ | */ | ||||
public WxJsapiSignature createJsapiSignature(String url) throws WxErrorException; | public WxJsapiSignature createJsapiSignature(String url) throws WxErrorException; | ||||
@@ -136,7 +130,7 @@ public interface WxCpService { | |||||
* | * | ||||
* @return 保存到本地的临时文件 | * @return 保存到本地的临时文件 | ||||
* @throws WxErrorException | * @throws WxErrorException | ||||
* @params media_id | |||||
* @param media_id | |||||
*/ | */ | ||||
File mediaDownload(String media_id) throws WxErrorException; | File mediaDownload(String media_id) throws WxErrorException; | ||||
@@ -216,7 +210,6 @@ public interface WxCpService { | |||||
* </pre> | * </pre> | ||||
* @see #menuGet(String) | * @see #menuGet(String) | ||||
* | * | ||||
* @return | |||||
* @throws WxErrorException | * @throws WxErrorException | ||||
*/ | */ | ||||
WxMenu menuGet() throws WxErrorException; | WxMenu menuGet() throws WxErrorException; | ||||
@@ -231,7 +224,6 @@ public interface WxCpService { | |||||
* @see #menuGet() | * @see #menuGet() | ||||
* | * | ||||
* @param agentId 企业号应用的id | * @param agentId 企业号应用的id | ||||
* @return | |||||
* @throws WxErrorException | * @throws WxErrorException | ||||
*/ | */ | ||||
WxMenu menuGet(String agentId) throws WxErrorException; | WxMenu menuGet(String agentId) throws WxErrorException; | ||||
@@ -255,7 +247,6 @@ public interface WxCpService { | |||||
* 详情请见: http://mp.weixin.qq.com/wiki/index.php?title=部门管理接口 | * 详情请见: http://mp.weixin.qq.com/wiki/index.php?title=部门管理接口 | ||||
* </pre> | * </pre> | ||||
* | * | ||||
* @return | |||||
* @throws WxErrorException | * @throws WxErrorException | ||||
*/ | */ | ||||
List<WxCpDepart> departGet() throws WxErrorException; | List<WxCpDepart> departGet() throws WxErrorException; | ||||
@@ -291,7 +282,6 @@ public interface WxCpService { | |||||
* @param departId 必填。部门id | * @param departId 必填。部门id | ||||
* @param fetchChild 非必填。1/0:是否递归获取子部门下面的成员 | * @param fetchChild 非必填。1/0:是否递归获取子部门下面的成员 | ||||
* @param status 非必填。0获取全部员工,1获取已关注成员列表,2获取禁用成员列表,4获取未关注成员列表。status可叠加 | * @param status 非必填。0获取全部员工,1获取已关注成员列表,2获取禁用成员列表,4获取未关注成员列表。status可叠加 | ||||
* @return | |||||
* @throws WxErrorException | * @throws WxErrorException | ||||
*/ | */ | ||||
List<WxCpUser> userList(Integer departId, Boolean fetchChild, Integer status) throws WxErrorException; | List<WxCpUser> userList(Integer departId, Boolean fetchChild, Integer status) throws WxErrorException; | ||||
@@ -306,7 +296,6 @@ public interface WxCpService { | |||||
* @param departId 必填。部门id | * @param departId 必填。部门id | ||||
* @param fetchChild 非必填。1/0:是否递归获取子部门下面的成员 | * @param fetchChild 非必填。1/0:是否递归获取子部门下面的成员 | ||||
* @param status 非必填。0获取全部员工,1获取已关注成员列表,2获取禁用成员列表,4获取未关注成员列表。status可叠加 | * @param status 非必填。0获取全部员工,1获取已关注成员列表,2获取禁用成员列表,4获取未关注成员列表。status可叠加 | ||||
* @return | |||||
* @throws WxErrorException | * @throws WxErrorException | ||||
*/ | */ | ||||
List<WxCpUser> departGetUsers(Integer departId, Boolean fetchChild, Integer status) throws WxErrorException; | List<WxCpUser> departGetUsers(Integer departId, Boolean fetchChild, Integer status) throws WxErrorException; | ||||
@@ -350,7 +339,6 @@ public interface WxCpService { | |||||
* 获取用户 | * 获取用户 | ||||
* | * | ||||
* @param userid | * @param userid | ||||
* @return | |||||
* @throws WxErrorException | * @throws WxErrorException | ||||
*/ | */ | ||||
WxCpUser userGet(String userid) throws WxErrorException; | WxCpUser userGet(String userid) throws WxErrorException; | ||||
@@ -359,7 +347,6 @@ public interface WxCpService { | |||||
* 创建标签 | * 创建标签 | ||||
* | * | ||||
* @param tagName | * @param tagName | ||||
* @return | |||||
*/ | */ | ||||
String tagCreate(String tagName) throws WxErrorException; | String tagCreate(String tagName) throws WxErrorException; | ||||
@@ -381,7 +368,6 @@ public interface WxCpService { | |||||
/** | /** | ||||
* 获得标签列表 | * 获得标签列表 | ||||
* | * | ||||
* @return | |||||
*/ | */ | ||||
List<WxCpTag> tagGet() throws WxErrorException; | List<WxCpTag> tagGet() throws WxErrorException; | ||||
@@ -389,7 +375,6 @@ public interface WxCpService { | |||||
* 获取标签成员 | * 获取标签成员 | ||||
* | * | ||||
* @param tagId | * @param tagId | ||||
* @return | |||||
*/ | */ | ||||
List<WxCpUser> tagGetUsers(String tagId) throws WxErrorException; | List<WxCpUser> tagGetUsers(String tagId) throws WxErrorException; | ||||
@@ -478,7 +463,6 @@ public interface WxCpService { | |||||
* 当本Service没有实现某个API的时候,可以用这个,针对所有微信API中的GET请求 | * 当本Service没有实现某个API的时候,可以用这个,针对所有微信API中的GET请求 | ||||
* @param url | * @param url | ||||
* @param queryParam | * @param queryParam | ||||
* @return | |||||
* @throws WxErrorException | * @throws WxErrorException | ||||
*/ | */ | ||||
String get(String url, String queryParam) throws WxErrorException; | String get(String url, String queryParam) throws WxErrorException; | ||||
@@ -487,7 +471,6 @@ public interface WxCpService { | |||||
* 当本Service没有实现某个API的时候,可以用这个,针对所有微信API中的POST请求 | * 当本Service没有实现某个API的时候,可以用这个,针对所有微信API中的POST请求 | ||||
* @param url | * @param url | ||||
* @param postData | * @param postData | ||||
* @return | |||||
* @throws WxErrorException | * @throws WxErrorException | ||||
*/ | */ | ||||
String post(String url, String postData) throws WxErrorException; | String post(String url, String postData) throws WxErrorException; | ||||
@@ -503,7 +486,6 @@ public interface WxCpService { | |||||
* @param data | * @param data | ||||
* @param <T> | * @param <T> | ||||
* @param <E> | * @param <E> | ||||
* @return | |||||
* @throws WxErrorException | * @throws WxErrorException | ||||
*/ | */ | ||||
<T, E> T execute(RequestExecutor<T, E> executor, String uri, E data) throws WxErrorException; | <T, E> T execute(RequestExecutor<T, E> executor, String uri, E data) throws WxErrorException; | ||||
@@ -536,7 +518,6 @@ public interface WxCpService { | |||||
/** | /** | ||||
* 获取某个sessionId对应的session,如果sessionId没有对应的session,则新建一个并返回。 | * 获取某个sessionId对应的session,如果sessionId没有对应的session,则新建一个并返回。 | ||||
* @param id id可以为任意字符串,建议使用FromUserName作为id | * @param id id可以为任意字符串,建议使用FromUserName作为id | ||||
* @return | |||||
*/ | */ | ||||
WxSession getSession(String id); | WxSession getSession(String id); | ||||
@@ -544,7 +525,6 @@ public interface WxCpService { | |||||
* 获取某个sessionId对应的session,如果sessionId没有对应的session,若create为true则新建一个,否则返回null。 | * 获取某个sessionId对应的session,如果sessionId没有对应的session,若create为true则新建一个,否则返回null。 | ||||
* @param id id可以为任意字符串,建议使用FromUserName作为id | * @param id id可以为任意字符串,建议使用FromUserName作为id | ||||
* @param create | * @param create | ||||
* @return | |||||
*/ | */ | ||||
WxSession getSession(String id, boolean create); | WxSession getSession(String id, boolean create); | ||||
@@ -556,25 +536,24 @@ public interface WxCpService { | |||||
* @param sessionManager | * @param sessionManager | ||||
*/ | */ | ||||
void setSessionManager(WxSessionManager sessionManager); | void setSessionManager(WxSessionManager sessionManager); | ||||
/** | /** | ||||
* 上传部门列表覆盖企业号上的部门信息 | * 上传部门列表覆盖企业号上的部门信息 | ||||
* @param mediaId | * @param mediaId | ||||
* @throws WxErrorException | * @throws WxErrorException | ||||
*/ | */ | ||||
String replaceParty(String mediaId) throws WxErrorException; | String replaceParty(String mediaId) throws WxErrorException; | ||||
/** | /** | ||||
* 上传用户列表覆盖企业号上的用户信息 | * 上传用户列表覆盖企业号上的用户信息 | ||||
* @param mediaId | * @param mediaId | ||||
* @throws WxErrorException | * @throws WxErrorException | ||||
*/ | */ | ||||
String replaceUser(String mediaId) throws WxErrorException; | String replaceUser(String mediaId) throws WxErrorException; | ||||
/** | /** | ||||
* 获取异步任务结果 | * 获取异步任务结果 | ||||
* @param joinId | * @param joinId | ||||
* @return | |||||
* @throws WxErrorException | * @throws WxErrorException | ||||
*/ | */ | ||||
String getTaskResult(String joinId) throws WxErrorException; | String getTaskResult(String joinId) throws WxErrorException; | ||||
@@ -510,12 +510,6 @@ public class WxCpServiceImpl implements WxCpService { | |||||
/** | /** | ||||
* 向微信端发送请求,在这里执行的策略是当发生access_token过期时才去刷新,然后重新执行请求,而不是全局定时请求 | * 向微信端发送请求,在这里执行的策略是当发生access_token过期时才去刷新,然后重新执行请求,而不是全局定时请求 | ||||
* | |||||
* @param executor | |||||
* @param uri | |||||
* @param data | |||||
* @return | |||||
* @throws WxErrorException | |||||
*/ | */ | ||||
public <T, E> T execute(RequestExecutor<T, E> executor, String uri, E data) throws WxErrorException { | public <T, E> T execute(RequestExecutor<T, E> executor, String uri, E data) throws WxErrorException { | ||||
int retryTimes = 0; | int retryTimes = 0; | ||||
@@ -28,7 +28,7 @@ public class WxCpMessage implements Serializable { | |||||
private String hqMusicUrl; | private String hqMusicUrl; | ||||
private String safe; | private String safe; | ||||
private List<WxArticle> articles = new ArrayList<WxArticle>(); | private List<WxArticle> articles = new ArrayList<WxArticle>(); | ||||
public String getToUser() { | public String getToUser() { | ||||
return toUser; | return toUser; | ||||
} | } | ||||
@@ -63,7 +63,7 @@ public class WxCpMessage implements Serializable { | |||||
public String getMsgType() { | public String getMsgType() { | ||||
return msgType; | return msgType; | ||||
} | } | ||||
public String getSafe() { | public String getSafe() { | ||||
return safe; | return safe; | ||||
} | } | ||||
@@ -135,18 +135,18 @@ public class WxCpMessage implements Serializable { | |||||
public void setArticles(List<WxArticle> articles) { | public void setArticles(List<WxArticle> articles) { | ||||
this.articles = articles; | this.articles = articles; | ||||
} | } | ||||
public String toJson() { | public String toJson() { | ||||
return WxCpGsonBuilder.INSTANCE.create().toJson(this); | return WxCpGsonBuilder.INSTANCE.create().toJson(this); | ||||
} | } | ||||
public static class WxArticle { | public static class WxArticle { | ||||
private String title; | private String title; | ||||
private String description; | private String description; | ||||
private String url; | private String url; | ||||
private String picUrl; | private String picUrl; | ||||
public String getTitle() { | public String getTitle() { | ||||
return title; | return title; | ||||
} | } | ||||
@@ -171,12 +171,11 @@ public class WxCpMessage implements Serializable { | |||||
public void setPicUrl(String picUrl) { | public void setPicUrl(String picUrl) { | ||||
this.picUrl = picUrl; | this.picUrl = picUrl; | ||||
} | } | ||||
} | } | ||||
/** | /** | ||||
* 获得文本消息builder | * 获得文本消息builder | ||||
* @return | |||||
*/ | */ | ||||
public static TextBuilder TEXT() { | public static TextBuilder TEXT() { | ||||
return new TextBuilder(); | return new TextBuilder(); | ||||
@@ -184,7 +183,6 @@ public class WxCpMessage implements Serializable { | |||||
/** | /** | ||||
* 获得图片消息builder | * 获得图片消息builder | ||||
* @return | |||||
*/ | */ | ||||
public static ImageBuilder IMAGE() { | public static ImageBuilder IMAGE() { | ||||
return new ImageBuilder(); | return new ImageBuilder(); | ||||
@@ -192,23 +190,20 @@ public class WxCpMessage implements Serializable { | |||||
/** | /** | ||||
* 获得语音消息builder | * 获得语音消息builder | ||||
* @return | |||||
*/ | */ | ||||
public static VoiceBuilder VOICE() { | public static VoiceBuilder VOICE() { | ||||
return new VoiceBuilder(); | return new VoiceBuilder(); | ||||
} | } | ||||
/** | /** | ||||
* 获得视频消息builder | * 获得视频消息builder | ||||
* @return | |||||
*/ | */ | ||||
public static VideoBuilder VIDEO() { | public static VideoBuilder VIDEO() { | ||||
return new VideoBuilder(); | return new VideoBuilder(); | ||||
} | } | ||||
/** | /** | ||||
* 获得图文消息builder | * 获得图文消息builder | ||||
* @return | |||||
*/ | */ | ||||
public static NewsBuilder NEWS() { | public static NewsBuilder NEWS() { | ||||
return new NewsBuilder(); | return new NewsBuilder(); | ||||
@@ -216,10 +211,9 @@ public class WxCpMessage implements Serializable { | |||||
/** | /** | ||||
* 获得文件消息builder | * 获得文件消息builder | ||||
* @return | |||||
*/ | */ | ||||
public static FileBuilder FILE() { | public static FileBuilder FILE() { | ||||
return new FileBuilder(); | return new FileBuilder(); | ||||
} | } | ||||
} | } |
@@ -198,7 +198,6 @@ public class WxCpXmlMessage implements Serializable { | |||||
* {@link me.chanjar.weixin.common.api.WxConsts#XML_MSG_EVENT} | * {@link me.chanjar.weixin.common.api.WxConsts#XML_MSG_EVENT} | ||||
* </pre> | * </pre> | ||||
* | * | ||||
* @return | |||||
*/ | */ | ||||
public String getMsgType() { | public String getMsgType() { | ||||
return msgType; | return msgType; | ||||
@@ -404,7 +403,6 @@ public class WxCpXmlMessage implements Serializable { | |||||
* @param timestamp | * @param timestamp | ||||
* @param nonce | * @param nonce | ||||
* @param msgSignature | * @param msgSignature | ||||
* @return | |||||
*/ | */ | ||||
public static WxCpXmlMessage fromEncryptedXml( | public static WxCpXmlMessage fromEncryptedXml( | ||||
String encryptedXml, | String encryptedXml, | ||||
@@ -542,7 +540,6 @@ public class WxCpXmlMessage implements Serializable { | |||||
/** | /** | ||||
* 扫描类型,一般是qrcode | * 扫描类型,一般是qrcode | ||||
* @return | |||||
*/ | */ | ||||
public String getScanType() { | public String getScanType() { | ||||
@@ -555,7 +552,6 @@ public class WxCpXmlMessage implements Serializable { | |||||
/** | /** | ||||
* 扫描结果,即二维码对应的字符串信息 | * 扫描结果,即二维码对应的字符串信息 | ||||
* @return | |||||
*/ | */ | ||||
public String getScanResult() { | public String getScanResult() { | ||||
return scanResult; | return scanResult; | ||||
@@ -14,14 +14,14 @@ public abstract class WxCpXmlOutMessage { | |||||
@XStreamAlias("ToUserName") | @XStreamAlias("ToUserName") | ||||
@XStreamConverter(value=XStreamCDataConverter.class) | @XStreamConverter(value=XStreamCDataConverter.class) | ||||
protected String toUserName; | protected String toUserName; | ||||
@XStreamAlias("FromUserName") | @XStreamAlias("FromUserName") | ||||
@XStreamConverter(value=XStreamCDataConverter.class) | @XStreamConverter(value=XStreamCDataConverter.class) | ||||
protected String fromUserName; | protected String fromUserName; | ||||
@XStreamAlias("CreateTime") | @XStreamAlias("CreateTime") | ||||
protected Long createTime; | protected Long createTime; | ||||
@XStreamAlias("MsgType") | @XStreamAlias("MsgType") | ||||
@XStreamConverter(value=XStreamCDataConverter.class) | @XStreamConverter(value=XStreamCDataConverter.class) | ||||
protected String msgType; | protected String msgType; | ||||
@@ -57,14 +57,13 @@ public abstract class WxCpXmlOutMessage { | |||||
public void setMsgType(String msgType) { | public void setMsgType(String msgType) { | ||||
this.msgType = msgType; | this.msgType = msgType; | ||||
} | } | ||||
protected String toXml() { | protected String toXml() { | ||||
return XStreamTransformer.toXml((Class)this.getClass(), this); | return XStreamTransformer.toXml((Class)this.getClass(), this); | ||||
} | } | ||||
/** | /** | ||||
* 转换成加密的xml格式 | * 转换成加密的xml格式 | ||||
* @return | |||||
*/ | */ | ||||
public String toEncryptedXml(WxCpConfigStorage wxCpConfigStorage) { | public String toEncryptedXml(WxCpConfigStorage wxCpConfigStorage) { | ||||
String plainXml = toXml(); | String plainXml = toXml(); | ||||
@@ -74,7 +73,6 @@ public abstract class WxCpXmlOutMessage { | |||||
/** | /** | ||||
* 获得文本消息builder | * 获得文本消息builder | ||||
* @return | |||||
*/ | */ | ||||
public static TextBuilder TEXT() { | public static TextBuilder TEXT() { | ||||
return new TextBuilder(); | return new TextBuilder(); | ||||
@@ -82,7 +80,6 @@ public abstract class WxCpXmlOutMessage { | |||||
/** | /** | ||||
* 获得图片消息builder | * 获得图片消息builder | ||||
* @return | |||||
*/ | */ | ||||
public static ImageBuilder IMAGE() { | public static ImageBuilder IMAGE() { | ||||
return new ImageBuilder(); | return new ImageBuilder(); | ||||
@@ -90,23 +87,20 @@ public abstract class WxCpXmlOutMessage { | |||||
/** | /** | ||||
* 获得语音消息builder | * 获得语音消息builder | ||||
* @return | |||||
*/ | */ | ||||
public static VoiceBuilder VOICE() { | public static VoiceBuilder VOICE() { | ||||
return new VoiceBuilder(); | return new VoiceBuilder(); | ||||
} | } | ||||
/** | /** | ||||
* 获得视频消息builder | * 获得视频消息builder | ||||
* @return | |||||
*/ | */ | ||||
public static VideoBuilder VIDEO() { | public static VideoBuilder VIDEO() { | ||||
return new VideoBuilder(); | return new VideoBuilder(); | ||||
} | } | ||||
/** | /** | ||||
* 获得图文消息builder | * 获得图文消息builder | ||||
* @return | |||||
*/ | */ | ||||
public static NewsBuilder NEWS() { | public static NewsBuilder NEWS() { | ||||
return new NewsBuilder(); | return new NewsBuilder(); | ||||
@@ -255,7 +255,7 @@ public interface WxMpService { | |||||
* 根据微信文档,视频文件下载不了,会返回null | * 根据微信文档,视频文件下载不了,会返回null | ||||
* 详情请见: <a href="http://mp.weixin.qq.com/wiki/9/677a85e3f3849af35de54bb5516c2521.html">获取临时素材</a> | * 详情请见: <a href="http://mp.weixin.qq.com/wiki/9/677a85e3f3849af35de54bb5516c2521.html">获取临时素材</a> | ||||
* </pre> | * </pre> | ||||
* @params media_id | |||||
* @param media_id | |||||
* @return 保存到本地的临时文件 | * @return 保存到本地的临时文件 | ||||
* @throws WxErrorException | * @throws WxErrorException | ||||
*/ | */ | ||||
@@ -371,7 +371,6 @@ public interface WxMpService { | |||||
* 分组管理接口 - 查询所有分组 | * 分组管理接口 - 查询所有分组 | ||||
* 详情请见: http://mp.weixin.qq.com/wiki/index.php?title=分组管理接口 | * 详情请见: http://mp.weixin.qq.com/wiki/index.php?title=分组管理接口 | ||||
* </pre> | * </pre> | ||||
* @return | |||||
*/ | */ | ||||
public List<WxMpGroup> groupGet() throws WxErrorException; | public List<WxMpGroup> groupGet() throws WxErrorException; | ||||
@@ -573,7 +572,6 @@ public interface WxMpService { | |||||
* 验证oauth2的access token是否有效 | * 验证oauth2的access token是否有效 | ||||
* </pre> | * </pre> | ||||
* @param oAuth2AccessToken | * @param oAuth2AccessToken | ||||
* @return | |||||
*/ | */ | ||||
public boolean oauth2validateAccessToken(WxMpOAuth2AccessToken oAuth2AccessToken); | public boolean oauth2validateAccessToken(WxMpOAuth2AccessToken oAuth2AccessToken); | ||||
@@ -785,12 +785,6 @@ public class WxMpServiceImpl implements WxMpService { | |||||
/** | /** | ||||
* 向微信端发送请求,在这里执行的策略是当发生access_token过期时才去刷新,然后重新执行请求,而不是全局定时请求 | * 向微信端发送请求,在这里执行的策略是当发生access_token过期时才去刷新,然后重新执行请求,而不是全局定时请求 | ||||
* | |||||
* @param executor | |||||
* @param uri | |||||
* @param data | |||||
* @return | |||||
* @throws WxErrorException | |||||
*/ | */ | ||||
@Override | @Override | ||||
public <T, E> T execute(RequestExecutor<T, E> executor, String uri, E data) throws WxErrorException { | public <T, E> T execute(RequestExecutor<T, E> executor, String uri, E data) throws WxErrorException { | ||||
@@ -154,7 +154,6 @@ public class WxMpCustomMessage implements Serializable { | |||||
/** | /** | ||||
* 获得语音消息builder | * 获得语音消息builder | ||||
* @return | |||||
*/ | */ | ||||
public static VoiceBuilder VOICE() { | public static VoiceBuilder VOICE() { | ||||
return new VoiceBuilder(); | return new VoiceBuilder(); | ||||
@@ -14,10 +14,6 @@ public class XStreamTransformer { | |||||
/** | /** | ||||
* xml -> pojo | * xml -> pojo | ||||
* | |||||
* @param clazz | |||||
* @param xml | |||||
* @return | |||||
*/ | */ | ||||
@SuppressWarnings("unchecked") | @SuppressWarnings("unchecked") | ||||
public static <T> T fromXml(Class<T> clazz, String xml) { | public static <T> T fromXml(Class<T> clazz, String xml) { | ||||
@@ -43,10 +39,6 @@ public class XStreamTransformer { | |||||
/** | /** | ||||
* pojo -> xml | * pojo -> xml | ||||
* | |||||
* @param clazz | |||||
* @param object | |||||
* @return | |||||
*/ | */ | ||||
public static <T> String toXml(Class<T> clazz, T object) { | public static <T> String toXml(Class<T> clazz, T object) { | ||||
return CLASS_2_XSTREAM_INSTANCE.get(clazz).toXML(object); | return CLASS_2_XSTREAM_INSTANCE.get(clazz).toXML(object); | ||||