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