From 11020ea0f4c8ca3bb68cf51e0916cd67bd6fe41a Mon Sep 17 00:00:00 2001 From: Binary Wang Date: Thu, 1 Dec 2016 15:35:25 +0800 Subject: [PATCH 01/21] Update README.md --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 4c61f08d..21991c11 100644 --- a/README.md +++ b/README.md @@ -12,6 +12,7 @@ Weixin Java Tools 微信公众号/企业号开发Java SDK =========== ## 开发交流方式及注意事项: +1. ***QQ群入群须知:为保证入群成员质量,请申请入群前,先Star本项目,然后在申请入群时,输入您的Github帐号ID,以便管理员核对,ID即你的github主页地址https://github.com/XXXX 中最后的部分XXXX的内容,或者在github网页右上角点击头像后查看Signed in as后方内容。*** 1. QQ群:343954419(推荐点击按钮入群: [![Join QQ Group](http://pub.idqqimg.com/wpa/images/group.png)](http://shang.qq.com/wpa/qunwpa?idkey=731dc3e7ea31ebe25376cc1a791445468612c63fd0e9e05399b088ec81fd9e15) 或 [![Join QQ Group](http://pub.idqqimg.com/wpa/images/group.png)](http://jq.qq.com/?_wv=1027&k=40lRskK),如果无反应,可以自行搜索群号进行添加 ) 1. 由于群容量有限即将爆满,现开启付费入群模式,并不定期清理长时间不活跃人士; 1. 微信群: 因微信群已达到100人限制,故如有想加入微信群的,请入QQ群后联系管理员,提供微信号以便邀请加入; From f69b15c59547209ff47bea511ae866cb4eb7ae3f Mon Sep 17 00:00:00 2001 From: Binary Wang Date: Thu, 1 Dec 2016 15:36:45 +0800 Subject: [PATCH 02/21] Update README.md --- README.md | 1 - 1 file changed, 1 deletion(-) diff --git a/README.md b/README.md index 21991c11..0ac5b4ef 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,6 @@ Weixin Java Tools 微信公众号/企业号开发Java SDK ## 开发交流方式及注意事项: 1. ***QQ群入群须知:为保证入群成员质量,请申请入群前,先Star本项目,然后在申请入群时,输入您的Github帐号ID,以便管理员核对,ID即你的github主页地址https://github.com/XXXX 中最后的部分XXXX的内容,或者在github网页右上角点击头像后查看Signed in as后方内容。*** 1. QQ群:343954419(推荐点击按钮入群: [![Join QQ Group](http://pub.idqqimg.com/wpa/images/group.png)](http://shang.qq.com/wpa/qunwpa?idkey=731dc3e7ea31ebe25376cc1a791445468612c63fd0e9e05399b088ec81fd9e15) 或 [![Join QQ Group](http://pub.idqqimg.com/wpa/images/group.png)](http://jq.qq.com/?_wv=1027&k=40lRskK),如果无反应,可以自行搜索群号进行添加 ) -1. 由于群容量有限即将爆满,现开启付费入群模式,并不定期清理长时间不活跃人士; 1. 微信群: 因微信群已达到100人限制,故如有想加入微信群的,请入QQ群后联系管理员,提供微信号以便邀请加入; 1. 新手提问前,请先阅读此文章:http://t.cn/RV93MRB 1. 寻求帮助时需贴代码或大长串异常信息的,请利用http://paste.ubuntu.com From 0059226d708c7c8c991a6875073bac641fd9b756 Mon Sep 17 00:00:00 2001 From: Binary Wang Date: Fri, 2 Dec 2016 09:38:41 +0800 Subject: [PATCH 03/21] Update README.md --- README.md | 1 - 1 file changed, 1 deletion(-) diff --git a/README.md b/README.md index 0ac5b4ef..fb085eb1 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,6 @@ Weixin Java Tools 微信公众号/企业号开发Java SDK =========== ## 开发交流方式及注意事项: -1. ***QQ群入群须知:为保证入群成员质量,请申请入群前,先Star本项目,然后在申请入群时,输入您的Github帐号ID,以便管理员核对,ID即你的github主页地址https://github.com/XXXX 中最后的部分XXXX的内容,或者在github网页右上角点击头像后查看Signed in as后方内容。*** 1. QQ群:343954419(推荐点击按钮入群: [![Join QQ Group](http://pub.idqqimg.com/wpa/images/group.png)](http://shang.qq.com/wpa/qunwpa?idkey=731dc3e7ea31ebe25376cc1a791445468612c63fd0e9e05399b088ec81fd9e15) 或 [![Join QQ Group](http://pub.idqqimg.com/wpa/images/group.png)](http://jq.qq.com/?_wv=1027&k=40lRskK),如果无反应,可以自行搜索群号进行添加 ) 1. 微信群: 因微信群已达到100人限制,故如有想加入微信群的,请入QQ群后联系管理员,提供微信号以便邀请加入; 1. 新手提问前,请先阅读此文章:http://t.cn/RV93MRB From 4f0b905305b6028b12ce89976e1297c542cfe166 Mon Sep 17 00:00:00 2001 From: Binary Wang Date: Fri, 2 Dec 2016 13:47:17 +0800 Subject: [PATCH 04/21] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index fb085eb1..320ae2b5 100644 --- a/README.md +++ b/README.md @@ -24,7 +24,7 @@ Weixin Java Tools 微信公众号/企业号开发Java SDK =========== ## 版本说明 -1. 本项目定为每月发布一次正式版,版本号格式为X.X.0(如2.1.0,2.2.0等),月初或月底发布新版本,遇到重大问题需修复会及时提交新版本,欢迎大家随时提交Pull Request; +1. 本项目定为每两个月发布一次正式版,版本号格式为X.X.0(如2.1.0,2.2.0等),月底发布新版本,遇到重大问题需修复会及时提交新版本,欢迎大家随时提交Pull Request; 1. BUG修复和新特性一般会先发布成小版本作为临时版本(如2.0.1,2.0.2等,即尾号不为0,以区别于正式版); 1. 目前最新版本号为 [![Maven Central](https://maven-badges.herokuapp.com/maven-central/com.github.binarywang/weixin-java-parent/badge.svg)](https://maven-badges.herokuapp.com/maven-central/com.github.binarywang/weixin-java-parent) ,也可以通过访问链接 [【公众号】](http://search.maven.org/#search%7Cgav%7C1%7Cg%3A%22com.github.binarywang%22%20AND%20a%3A%22weixin-java-mp%22) 、[【企业号】](http://search.maven.org/#search%7Cgav%7C1%7Cg%3A%22com.github.binarywang%22%20AND%20a%3A%22weixin-java-cp%22) 分别查看所有最新的版本。 From fcf11c65e13fef296e9753b28c56e877cc9583d6 Mon Sep 17 00:00:00 2001 From: Binary Wang Date: Fri, 2 Dec 2016 14:10:49 +0800 Subject: [PATCH 05/21] Update README.md --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 320ae2b5..7fff2744 100644 --- a/README.md +++ b/README.md @@ -13,6 +13,7 @@ Weixin Java Tools 微信公众号/企业号开发Java SDK ## 开发交流方式及注意事项: 1. QQ群:343954419(推荐点击按钮入群: [![Join QQ Group](http://pub.idqqimg.com/wpa/images/group.png)](http://shang.qq.com/wpa/qunwpa?idkey=731dc3e7ea31ebe25376cc1a791445468612c63fd0e9e05399b088ec81fd9e15) 或 [![Join QQ Group](http://pub.idqqimg.com/wpa/images/group.png)](http://jq.qq.com/?_wv=1027&k=40lRskK),如果无反应,可以自行搜索群号进行添加 ) +1. 由于群容量有限,即将爆满,故开启付费入群模式以保证只有真实交流需求的人进入,并为保证群的活跃度,将不定期清理长时间不活跃的同学; 1. 微信群: 因微信群已达到100人限制,故如有想加入微信群的,请入QQ群后联系管理员,提供微信号以便邀请加入; 1. 新手提问前,请先阅读此文章:http://t.cn/RV93MRB 1. 寻求帮助时需贴代码或大长串异常信息的,请利用http://paste.ubuntu.com From 6b78c94ff33bfb6749e891d03f458a9c4a2cd1ee Mon Sep 17 00:00:00 2001 From: Binary Wang Date: Fri, 9 Dec 2016 10:11:33 +0800 Subject: [PATCH 06/21] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 7fff2744..444eda6f 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ Weixin Java Tools 微信公众号/企业号开发Java SDK ===================================== [![Maven Central](https://maven-badges.herokuapp.com/maven-central/com.github.binarywang/weixin-java-parent/badge.svg)](https://maven-badges.herokuapp.com/maven-central/com.github.binarywang/weixin-java-parent) -[![Build Status](https://travis-ci.org/wechat-group/weixin-java-tools.svg?branch=develop)](https://travis-ci.org/wechat-group/weixin-java-tools) +[![Build Status](https://travis-ci.org/Wechat-Group/weixin-java-tools.svg?branch=develop)](https://travis-ci.org/Wechat-Group/weixin-java-tools) ### 注意: 1. ***本项目Fork自chanjarster/weixin-java-tools,但由于原项目已停止维护,故单独维护和发布,且发布到maven上的groupId也会不同,详细信息见下文。*** From a7c72f613abdaf0af4242132722cfd6249698e83 Mon Sep 17 00:00:00 2001 From: dongfuqiang Date: Wed, 14 Dec 2016 16:29:50 +0800 Subject: [PATCH 07/21] update --- .../weixin/mp/api/WxMpDeviceService.java | 80 +++++++++++++ .../me/chanjar/weixin/mp/api/WxMpService.java | 7 ++ .../mp/api/impl/WxMpDeviceServiceImpl.java | 72 ++++++++++++ .../weixin/mp/api/impl/WxMpServiceImpl.java | 6 + .../mp/bean/device/AbstractDeviceBean.java | 12 ++ .../weixin/mp/bean/device/BaseResp.java | 55 +++++++++ .../weixin/mp/bean/device/RespMsg.java | 26 +++++ .../weixin/mp/bean/device/TransMsgResp.java | 49 ++++++++ .../weixin/mp/bean/device/WxDevice.java | 106 ++++++++++++++++++ .../mp/bean/device/WxDeviceAuthorize.java | 36 ++++++ .../bean/device/WxDeviceAuthorizeResult.java | 24 ++++ .../weixin/mp/bean/device/WxDeviceBind.java | 34 ++++++ .../mp/bean/device/WxDeviceBindResult.java | 22 ++++ .../weixin/mp/bean/device/WxDeviceMsg.java | 50 +++++++++ .../mp/bean/device/WxDeviceQrCodeResult.java | 49 ++++++++ .../api/impl/WxMpDeviceServiceImplTest.java | 40 +++++++ 16 files changed, 668 insertions(+) create mode 100644 weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpDeviceService.java create mode 100644 weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpDeviceServiceImpl.java create mode 100644 weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/device/AbstractDeviceBean.java create mode 100644 weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/device/BaseResp.java create mode 100644 weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/device/RespMsg.java create mode 100644 weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/device/TransMsgResp.java create mode 100644 weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/device/WxDevice.java create mode 100644 weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/device/WxDeviceAuthorize.java create mode 100644 weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/device/WxDeviceAuthorizeResult.java create mode 100644 weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/device/WxDeviceBind.java create mode 100644 weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/device/WxDeviceBindResult.java create mode 100644 weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/device/WxDeviceMsg.java create mode 100644 weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/device/WxDeviceQrCodeResult.java create mode 100644 weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/impl/WxMpDeviceServiceImplTest.java diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpDeviceService.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpDeviceService.java new file mode 100644 index 00000000..a565011c --- /dev/null +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpDeviceService.java @@ -0,0 +1,80 @@ +package me.chanjar.weixin.mp.api; + +import me.chanjar.weixin.common.exception.WxErrorException; +import me.chanjar.weixin.mp.bean.device.*; + +/** + * Created by keungtung on 10/12/2016. + */ +public interface WxMpDeviceService { + /** + *
+   * 主动发送消息给设备
+   * 详情请见:http://iot.weixin.qq.com/wiki/new/index.html?page=3-4-3
+   * 
+ */ + TransMsgResp transMsg(WxDeviceMsg msg) throws WxErrorException; + + /** + *
+   *   获取一组新的deviceid和设备二维码
+   *   详情请见:http://iot.weixin.qq.com/wiki/new/index.html?page=3-4-6
+   * 
+ * @param productId 产品id + * @return 返回WxDeviceQrCodeResult + */ + WxDeviceQrCodeResult getQrCode(String productId) throws WxErrorException; + + /** + *
+   *   将device id及其属性信息提交公众平台进行授权
+   *   详情请见:http://iot.weixin.qq.com/wiki/new/index.html?page=3-4-6
+   * 
+ * @param wxDeviceAuthorize 授权请求对象 + * @return WxDeviceAuthorizeResult + */ + WxDeviceAuthorizeResult authorize(WxDeviceAuthorize wxDeviceAuthorize) throws WxErrorException; + + + /** + *
+   *   第三方后台绑定成功后,通知公众平台
+   *   详情请见:http://iot.weixin.qq.com/wiki/new/index.html/page=3-4-7
+   * 
+ * @param wxDeviceBind 绑定请求对象 + * @return WxDeviceBindResult + */ + WxDeviceBindResult bind(WxDeviceBind wxDeviceBind) throws WxErrorException; + + /** + *
+   *   强制绑定用户和设备
+   *   详情请见:http://iot.weixin.qq.com/wiki/new/index.html?page=3-4-7
+   * 
+ * @param wxDeviceBind 强制绑定请求对象 + * @return WxDeviceBindResult + */ + WxDeviceBindResult compelBind(WxDeviceBind wxDeviceBind) throws WxErrorException; + + /** + *
+   *   第三方确认用户和设备的解绑操作
+   *   详情请见:http://iot.weixin.qq.com/wiki/new/index.html/page=3-4-7
+   * 
+ * @param wxDeviceBind 绑定请求对象 + * @return WxDeviceBidResult + */ + WxDeviceBindResult unbind(WxDeviceBind wxDeviceBind) throws WxErrorException; + + /** + *
+   *   强制解绑用户和设备
+   *   详情请见:http://iot.weixin.qq.com/wiki/new/index.html?page=3-4-7
+   * 
+ * @param wxDeviceBind 强制解绑请求对象 + * @return WxDeviceBindResult + */ + WxDeviceBindResult compelUnbind(WxDeviceBind wxDeviceBind) throws WxErrorException; + + +} diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpService.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpService.java index 4fa91bad..dc05a2ee 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpService.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpService.java @@ -345,4 +345,11 @@ public interface WxMpService { * @return WxMpTemplateMsgService */ WxMpTemplateMsgService getTemplateMsgService(); + + /** + * 返回硬件平台相关接口方法的实现类对象,以方便调用其各个接口 + * + * @return WxMpDeviceService + */ + WxMpDeviceService getDeviceService(); } diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpDeviceServiceImpl.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpDeviceServiceImpl.java new file mode 100644 index 00000000..e7dbea1b --- /dev/null +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpDeviceServiceImpl.java @@ -0,0 +1,72 @@ +package me.chanjar.weixin.mp.api.impl; + +import me.chanjar.weixin.common.exception.WxErrorException; +import me.chanjar.weixin.mp.api.WxMpDeviceService; +import me.chanjar.weixin.mp.api.WxMpService; +import me.chanjar.weixin.mp.bean.device.*; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * Created by keungtung on 10/12/2016. + */ +public class WxMpDeviceServiceImpl implements WxMpDeviceService { + private static final String API_URL_PREFIX = "https://api.weixin.qq.com/device"; + private static Logger log = LoggerFactory.getLogger(WxMpMenuServiceImpl.class); + + private WxMpService wxMpService; + + WxMpDeviceServiceImpl(WxMpService wxMpService) { + this.wxMpService = wxMpService; + } + + @Override + public TransMsgResp transMsg(WxDeviceMsg msg) throws WxErrorException { + String url = API_URL_PREFIX + "/transmsg"; + String response = this.wxMpService.post(url,msg.toJson()); + return TransMsgResp.fromJson(response); + } + + @Override + public WxDeviceQrCodeResult getQrCode(String productId) throws WxErrorException { + String url = API_URL_PREFIX + "/getqrcode"; + String response = this.wxMpService.get(url, "product_id=" + productId); + return WxDeviceQrCodeResult.fromJson(response); + } + + @Override + public WxDeviceAuthorizeResult authorize(WxDeviceAuthorize wxDeviceAuthorize) throws WxErrorException { + String url = API_URL_PREFIX + "/authorize_device"; + String response = this.wxMpService.post(url,wxDeviceAuthorize.toJson()); + return WxDeviceAuthorizeResult.fromJson(response); + } + + @Override + public WxDeviceBindResult bind(WxDeviceBind wxDeviceBind) throws WxErrorException { + String url = API_URL_PREFIX + "/bind"; + String response = this.wxMpService.post(url,wxDeviceBind.toJson()); + return WxDeviceBindResult.fromJson(response); + } + + @Override + public WxDeviceBindResult compelBind(WxDeviceBind wxDeviceBind) throws WxErrorException { + String url = API_URL_PREFIX + "/compel_bind"; + String response = this.wxMpService.post(url,wxDeviceBind.toJson()); + return WxDeviceBindResult.fromJson(response); + } + + @Override + public WxDeviceBindResult unbind(WxDeviceBind wxDeviceBind) throws WxErrorException { + String url = API_URL_PREFIX + "/unbind?"; + String response = this.wxMpService.post(url, wxDeviceBind.toJson()); + return WxDeviceBindResult.fromJson(response); + } + + @Override + public WxDeviceBindResult compelUnbind(WxDeviceBind wxDeviceBind) throws WxErrorException { + String url = API_URL_PREFIX + "/compel_unbind?"; + String response = this.wxMpService.post(url, wxDeviceBind.toJson()); + return WxDeviceBindResult.fromJson(response); + } +} + diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpServiceImpl.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpServiceImpl.java index 46fa3157..3c602325 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpServiceImpl.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpServiceImpl.java @@ -62,6 +62,8 @@ public class WxMpServiceImpl implements WxMpService { private WxMpTemplateMsgService templateMsgService = new WxMpTemplateMsgServiceImpl(this); + private WxMpDeviceService deviceService = new WxMpDeviceServiceImpl(this); + private CloseableHttpClient httpClient; private HttpHost httpProxy; @@ -540,4 +542,8 @@ public class WxMpServiceImpl implements WxMpService { return this.templateMsgService; } + @Override + public WxMpDeviceService getDeviceService() { + return this.deviceService; + } } diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/device/AbstractDeviceBean.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/device/AbstractDeviceBean.java new file mode 100644 index 00000000..3a327069 --- /dev/null +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/device/AbstractDeviceBean.java @@ -0,0 +1,12 @@ +package me.chanjar.weixin.mp.bean.device; + +import me.chanjar.weixin.common.util.json.WxGsonBuilder; + +/** + * Created by keungtung on 14/12/2016. + */ +public abstract class AbstractDeviceBean { + public String toJson() { + return WxGsonBuilder.create().toJson(this); + } +} diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/device/BaseResp.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/device/BaseResp.java new file mode 100644 index 00000000..5a3082f6 --- /dev/null +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/device/BaseResp.java @@ -0,0 +1,55 @@ +package me.chanjar.weixin.mp.bean.device; + +/** + * Created by keungtung on 10/12/2016. + */ +public class BaseResp extends AbstractDeviceBean{ + private BaseInfo base_info; + private Integer errcode; + private String errmsg; + + public Integer getErrcode() { + return errcode; + } + + public void setErrcode(Integer errcode) { + this.errcode = errcode; + } + + public BaseInfo getBase_info() { + return base_info; + } + + public void setBase_info(BaseInfo base_info) { + this.base_info = base_info; + } + + public String getErrmsg() { + return errmsg; + } + + public void setErrmsg(String errmsg) { + this.errmsg = errmsg; + } + + private class BaseInfo { + private String device_type; + private String device_id; + + public String getDevice_type() { + return device_type; + } + + public void setDevice_type(String device_type) { + this.device_type = device_type; + } + + public String getDevice_id() { + return device_id; + } + + public void setDevice_id(String device_id) { + this.device_id = device_id; + } + } +} diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/device/RespMsg.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/device/RespMsg.java new file mode 100644 index 00000000..e0291fbb --- /dev/null +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/device/RespMsg.java @@ -0,0 +1,26 @@ +package me.chanjar.weixin.mp.bean.device; + +/** + * Created by keungtung on 10/12/2016. + */ + +public class RespMsg extends AbstractDeviceBean{ + private Integer retCode; + private String errorInfo; + + public Integer getRetCode() { + return retCode; + } + + public void setRetCode(Integer retCode) { + this.retCode = retCode; + } + + public String getErrorInfo() { + return errorInfo; + } + + public void setErrorInfo(String errorInfo) { + this.errorInfo = errorInfo; + } +} diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/device/TransMsgResp.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/device/TransMsgResp.java new file mode 100644 index 00000000..6d5fbe06 --- /dev/null +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/device/TransMsgResp.java @@ -0,0 +1,49 @@ +package me.chanjar.weixin.mp.bean.device; + +import me.chanjar.weixin.common.util.json.WxGsonBuilder; + +/** + * Created by keungtung on 14/12/2016. + */ +public class TransMsgResp extends AbstractDeviceBean{ + private Integer ret; + private String ret_info; + private Integer errcode; + private String errmsg; + + public static TransMsgResp fromJson(String json) { + return WxGsonBuilder.create().fromJson(json, TransMsgResp.class); + } + + public Integer getRet() { + return ret; + } + + public void setRet(Integer ret) { + this.ret = ret; + } + + public String getRet_info() { + return ret_info; + } + + public void setRet_info(String ret_info) { + this.ret_info = ret_info; + } + + public Integer getErrcode() { + return errcode; + } + + public void setErrcode(Integer errcode) { + this.errcode = errcode; + } + + public String getErrmsg() { + return errmsg; + } + + public void setErrmsg(String errmsg) { + this.errmsg = errmsg; + } +} diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/device/WxDevice.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/device/WxDevice.java new file mode 100644 index 00000000..f36c4b10 --- /dev/null +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/device/WxDevice.java @@ -0,0 +1,106 @@ +package me.chanjar.weixin.mp.bean.device; + +/** + * Created by keungtung on 10/12/2016. + */ +public class WxDevice { + private String id; + private String mac; + private String connect_protocol; + private String auth_key; + private String close_strategy; + private String conn_strategy; + private String crypt_method; + private String auth_ver; + private String manu_mac_pos; + private String ser_mac_pos; + private String ble_simple_protocol; + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getMac() { + return mac; + } + + public void setMac(String mac) { + this.mac = mac; + } + + public String getConnect_protocol() { + return connect_protocol; + } + + public void setConnect_protocol(String connect_protocol) { + this.connect_protocol = connect_protocol; + } + + public String getAuth_key() { + return auth_key; + } + + public void setAuth_key(String auth_key) { + this.auth_key = auth_key; + } + + public String getClose_strategy() { + return close_strategy; + } + + public void setClose_strategy(String close_strategy) { + this.close_strategy = close_strategy; + } + + public String getConn_strategy() { + return conn_strategy; + } + + public void setConn_strategy(String conn_strategy) { + this.conn_strategy = conn_strategy; + } + + public String getCrypt_method() { + return crypt_method; + } + + public void setCrypt_method(String crypt_method) { + this.crypt_method = crypt_method; + } + + public String getAuth_ver() { + return auth_ver; + } + + public void setAuth_ver(String auth_ver) { + this.auth_ver = auth_ver; + } + + public String getManu_mac_pos() { + return manu_mac_pos; + } + + public void setManu_mac_pos(String manu_mac_pos) { + this.manu_mac_pos = manu_mac_pos; + } + + public String getSer_mac_pos() { + return ser_mac_pos; + } + + public void setSer_mac_pos(String ser_mac_pos) { + this.ser_mac_pos = ser_mac_pos; + } + + public String getBle_simple_protocol() { + return ble_simple_protocol; + } + + public void setBle_simple_protocol(String ble_simple_protocol) { + this.ble_simple_protocol = ble_simple_protocol; + } +} diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/device/WxDeviceAuthorize.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/device/WxDeviceAuthorize.java new file mode 100644 index 00000000..920a369e --- /dev/null +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/device/WxDeviceAuthorize.java @@ -0,0 +1,36 @@ +package me.chanjar.weixin.mp.bean.device; + +import java.util.List; + +/** + * Created by keungtung on 10/12/2016. + */ +public class WxDeviceAuthorize extends AbstractDeviceBean{ + private String deivce_num; + private String op_type; + private List device_list; + + public String getDeivce_num() { + return deivce_num; + } + + public void setDeivce_num(String deivce_num) { + this.deivce_num = deivce_num; + } + + public String getOp_type() { + return op_type; + } + + public void setOp_type(String op_type) { + this.op_type = op_type; + } + + public List getDevice_list() { + return device_list; + } + + public void setDevice_list(List device_list) { + this.device_list = device_list; + } +} diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/device/WxDeviceAuthorizeResult.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/device/WxDeviceAuthorizeResult.java new file mode 100644 index 00000000..dfe8d3b7 --- /dev/null +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/device/WxDeviceAuthorizeResult.java @@ -0,0 +1,24 @@ +package me.chanjar.weixin.mp.bean.device; + +import me.chanjar.weixin.common.util.json.WxGsonBuilder; + +import java.util.List; + +/** + * Created by keungtung on 10/12/2016. + */ +public class WxDeviceAuthorizeResult extends AbstractDeviceBean{ + private List resp; + + public static WxDeviceAuthorizeResult fromJson(String response) { + return WxGsonBuilder.create().fromJson(response, WxDeviceAuthorizeResult.class); + } + + public List getResp() { + return resp; + } + + public void setResp(List resp) { + this.resp = resp; + } +} diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/device/WxDeviceBind.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/device/WxDeviceBind.java new file mode 100644 index 00000000..e4588478 --- /dev/null +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/device/WxDeviceBind.java @@ -0,0 +1,34 @@ +package me.chanjar.weixin.mp.bean.device; + +/** + * Created by keungtung on 10/12/2016. + */ +public class WxDeviceBind extends AbstractDeviceBean{ + private String ticket; + private String device_id; + private String openid; + + public String getTicket() { + return ticket; + } + + public void setTicket(String ticket) { + this.ticket = ticket; + } + + public String getDevice_id() { + return device_id; + } + + public void setDevice_id(String device_id) { + this.device_id = device_id; + } + + public String getOpenid() { + return openid; + } + + public void setOpenid(String openid) { + this.openid = openid; + } +} diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/device/WxDeviceBindResult.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/device/WxDeviceBindResult.java new file mode 100644 index 00000000..8f41a320 --- /dev/null +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/device/WxDeviceBindResult.java @@ -0,0 +1,22 @@ +package me.chanjar.weixin.mp.bean.device; + +import me.chanjar.weixin.mp.util.json.WxMpGsonBuilder; + +/** + * Created by keungtung on 10/12/2016. + */ +public class WxDeviceBindResult extends AbstractDeviceBean{ + private BaseResp base_resp; + + public static WxDeviceBindResult fromJson(String json) { + return WxMpGsonBuilder.create().fromJson(json, WxDeviceBindResult.class); + } + + public BaseResp getBase_resp() { + return base_resp; + } + + public void setBase_resp(BaseResp base_resp) { + this.base_resp = base_resp; + } +} diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/device/WxDeviceMsg.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/device/WxDeviceMsg.java new file mode 100644 index 00000000..e01f09ab --- /dev/null +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/device/WxDeviceMsg.java @@ -0,0 +1,50 @@ +package me.chanjar.weixin.mp.bean.device; + +import me.chanjar.weixin.common.util.ToStringUtils; + +/** + * Created by keungtung on 10/12/2016. + */ +public class WxDeviceMsg extends AbstractDeviceBean{ + private String deviceType; + private String deviceId; + private String openId; + private String content; + + @Override + public String toString() { + return ToStringUtils.toSimpleString(this); + } + + public String getDeviceType() { + return deviceType; + } + + public void setDeviceType(String deviceType) { + this.deviceType = deviceType; + } + + public String getDeviceId() { + return deviceId; + } + + public void setDeviceId(String deviceId) { + this.deviceId = deviceId; + } + + public String getOpenId() { + return openId; + } + + public void setOpenId(String openId) { + this.openId = openId; + } + + public String getContent() { + return content; + } + + public void setContent(String content) { + this.content = content; + } +} diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/device/WxDeviceQrCodeResult.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/device/WxDeviceQrCodeResult.java new file mode 100644 index 00000000..c2f67c5f --- /dev/null +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/device/WxDeviceQrCodeResult.java @@ -0,0 +1,49 @@ +package me.chanjar.weixin.mp.bean.device; + +import me.chanjar.weixin.mp.util.json.WxMpGsonBuilder; + +/** + * Created by keungtung on 10/12/2016. + */ +public class WxDeviceQrCodeResult extends AbstractDeviceBean{ + private String deviceid; + private String qrticket; + private String devcielicence; + private RespMsg resp_msg; + + public static WxDeviceQrCodeResult fromJson(String json) { + return WxMpGsonBuilder.INSTANCE.create().fromJson(json, WxDeviceQrCodeResult.class); + } + + public String getDevcielicence() { + return devcielicence; + } + + public void setDevcielicence(String devcielicence) { + this.devcielicence = devcielicence; + } + + public RespMsg getResp_msg() { + return resp_msg; + } + + public void setResp_msg(RespMsg resp_msg) { + this.resp_msg = resp_msg; + } + + public String getDeviceid() { + return deviceid; + } + + public void setDeviceid(String deviceid) { + this.deviceid = deviceid; + } + + public String getQrticket() { + return qrticket; + } + + public void setQrticket(String qrticket) { + this.qrticket = qrticket; + } +} diff --git a/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/impl/WxMpDeviceServiceImplTest.java b/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/impl/WxMpDeviceServiceImplTest.java new file mode 100644 index 00000000..e79dd250 --- /dev/null +++ b/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/impl/WxMpDeviceServiceImplTest.java @@ -0,0 +1,40 @@ +package me.chanjar.weixin.mp.api.impl; + + +import com.google.inject.Inject; +import me.chanjar.weixin.common.exception.WxErrorException; +import me.chanjar.weixin.mp.api.ApiTestModule; +import me.chanjar.weixin.mp.api.WxMpService; +import me.chanjar.weixin.mp.bean.device.WxDeviceQrCodeResult; +import org.testng.annotations.DataProvider; +import org.testng.annotations.Guice; +import org.testng.annotations.Test; + +/** + * Created by keungtung on 14/12/2016. + */ +@Test(groups = "deviceApi") +@Guice(modules = ApiTestModule.class) +public class WxMpDeviceServiceImplTest { + @Inject + protected WxMpService wxService; + + @Test(dataProvider = "productId") + public void testGetQrcode(String productId) { + try { + WxDeviceQrCodeResult result = wxService.getDeviceService().getQrCode(productId); + println(result.toJson()); + } catch (WxErrorException e) { + println(e.getMessage()); + } + } + + private void println(String content) { + System.out.println(content); + } + + @DataProvider(name = "productId") + public Object[][] getProductId() { + return new Object[][]{new Object[]{"25639"}}; + } +} From 3e8b1a5dca8b9659b6292f93c149356af39ff0f5 Mon Sep 17 00:00:00 2001 From: dongfuqiang Date: Thu, 15 Dec 2016 12:09:13 +0800 Subject: [PATCH 08/21] update --- .../chanjar/weixin/mp/bean/device/WxDeviceAuthorize.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/device/WxDeviceAuthorize.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/device/WxDeviceAuthorize.java index 920a369e..ce7317d6 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/device/WxDeviceAuthorize.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/device/WxDeviceAuthorize.java @@ -1,11 +1,12 @@ package me.chanjar.weixin.mp.bean.device; +import java.util.Arrays; import java.util.List; /** * Created by keungtung on 10/12/2016. */ -public class WxDeviceAuthorize extends AbstractDeviceBean{ +public class WxDeviceAuthorize extends AbstractDeviceBean { private String deivce_num; private String op_type; private List device_list; @@ -33,4 +34,8 @@ public class WxDeviceAuthorize extends AbstractDeviceBean{ public void setDevice_list(List device_list) { this.device_list = device_list; } + + public void addDevice(WxDevice... devices) { + this.device_list.addAll(Arrays.asList(devices)); + } } From 575458d12b8b99c2f310fb12f225f64e96865acd Mon Sep 17 00:00:00 2001 From: dongfuqiang Date: Thu, 15 Dec 2016 14:11:39 +0800 Subject: [PATCH 09/21] update --- .../me/chanjar/weixin/mp/bean/device/WxDeviceAuthorize.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/device/WxDeviceAuthorize.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/device/WxDeviceAuthorize.java index ce7317d6..e1dcd9be 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/device/WxDeviceAuthorize.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/device/WxDeviceAuthorize.java @@ -1,6 +1,7 @@ package me.chanjar.weixin.mp.bean.device; import java.util.Arrays; +import java.util.LinkedList; import java.util.List; /** @@ -9,7 +10,7 @@ import java.util.List; public class WxDeviceAuthorize extends AbstractDeviceBean { private String deivce_num; private String op_type; - private List device_list; + private List device_list = new LinkedList<>(); public String getDeivce_num() { return deivce_num; From f6608075e90caa8630ca9b6563cb76f63522a6ff Mon Sep 17 00:00:00 2001 From: Binary Wang Date: Thu, 15 Dec 2016 14:25:07 +0800 Subject: [PATCH 10/21] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 444eda6f..e3c099c6 100644 --- a/README.md +++ b/README.md @@ -30,7 +30,7 @@ Weixin Java Tools 微信公众号/企业号开发Java SDK 1. 目前最新版本号为 [![Maven Central](https://maven-badges.herokuapp.com/maven-central/com.github.binarywang/weixin-java-parent/badge.svg)](https://maven-badges.herokuapp.com/maven-central/com.github.binarywang/weixin-java-parent) ,也可以通过访问链接 [【公众号】](http://search.maven.org/#search%7Cgav%7C1%7Cg%3A%22com.github.binarywang%22%20AND%20a%3A%22weixin-java-mp%22) 、[【企业号】](http://search.maven.org/#search%7Cgav%7C1%7Cg%3A%22com.github.binarywang%22%20AND%20a%3A%22weixin-java-cp%22) 分别查看所有最新的版本。 -## Maven & Gradle +## Maven & Gradle 最新正式版本 * 公众号(订阅号、服务号): From b8a9795cf5a67711ec77c56798e296a9b3a1fa4f Mon Sep 17 00:00:00 2001 From: Binary Wang Date: Thu, 15 Dec 2016 15:23:29 +0800 Subject: [PATCH 11/21] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=8E=A5=E5=8F=A3?= =?UTF-8?q?=E8=AF=B7=E6=B1=82=E9=87=8D=E8=AF=95=E4=BB=A3=E7=A0=81=EF=BC=8C?= =?UTF-8?q?=E9=81=BF=E5=85=8D=E6=97=A0=E6=95=88=E7=AD=89=E5=BE=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../weixin/cp/api/WxCpServiceImpl.java | 12 ++++++++--- .../weixin/cp/api/WxCpBusyRetryTest.java | 14 ++++++------- .../weixin/mp/api/impl/WxMpServiceImpl.java | 11 ++++++++-- .../weixin/mp/api/WxMpBusyRetryTest.java | 20 +++++++++---------- 4 files changed, 34 insertions(+), 23 deletions(-) diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpServiceImpl.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpServiceImpl.java index d44bbf5f..734593d4 100644 --- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpServiceImpl.java +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpServiceImpl.java @@ -540,6 +540,12 @@ public class WxCpServiceImpl implements WxCpService { try { return executeInternal(executor, uri, data); } catch (WxErrorException e) { + if (retryTimes + 1 > this.maxRetryTimes) { + this.log.warn("重试达到最大次数【{}】", this.maxRetryTimes); + //最后一次重试失败后,直接抛出异常,不再等待 + throw new RuntimeException("微信服务端异常,超出重试次数"); + } + WxError error = e.getError(); /* * -1 系统繁忙, 1000ms后重试 @@ -547,8 +553,7 @@ public class WxCpServiceImpl implements WxCpService { if (error.getErrorCode() == -1) { int sleepMillis = this.retrySleepMillis * (1 << retryTimes); try { - this.log.debug("微信系统繁忙,{}ms 后重试(第{}次)", sleepMillis, - retryTimes + 1); + this.log.debug("微信系统繁忙,{} ms 后重试(第{}次)", sleepMillis, retryTimes + 1); Thread.sleep(sleepMillis); } catch (InterruptedException e1) { throw new RuntimeException(e1); @@ -557,8 +562,9 @@ public class WxCpServiceImpl implements WxCpService { throw e; } } - } while (++retryTimes < this.maxRetryTimes); + } while (retryTimes++ < this.maxRetryTimes); + this.log.warn("重试达到最大次数【{}】", this.maxRetryTimes); throw new RuntimeException("微信服务端异常,超出重试次数"); } diff --git a/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/api/WxCpBusyRetryTest.java b/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/api/WxCpBusyRetryTest.java index b3f96b1b..e1b005bd 100644 --- a/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/api/WxCpBusyRetryTest.java +++ b/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/api/WxCpBusyRetryTest.java @@ -1,17 +1,16 @@ package me.chanjar.weixin.cp.api; +import me.chanjar.weixin.common.bean.result.WxError; +import me.chanjar.weixin.common.exception.WxErrorException; +import me.chanjar.weixin.common.util.http.RequestExecutor; +import org.testng.annotations.DataProvider; +import org.testng.annotations.Test; + import java.util.concurrent.ExecutionException; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import java.util.concurrent.Future; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; - -import me.chanjar.weixin.common.bean.result.WxError; -import me.chanjar.weixin.common.exception.WxErrorException; -import me.chanjar.weixin.common.util.http.RequestExecutor; - @Test public class WxCpBusyRetryTest { @@ -23,6 +22,7 @@ public class WxCpBusyRetryTest { protected synchronized T executeInternal( RequestExecutor executor, String uri, E data) throws WxErrorException { + this.log.info("Executed"); WxError error = new WxError(); error.setErrorCode(-1); throw new WxErrorException(error); diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpServiceImpl.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpServiceImpl.java index 3c602325..62b363a2 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpServiceImpl.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpServiceImpl.java @@ -369,12 +369,18 @@ public class WxMpServiceImpl implements WxMpService { this.log.debug("\n[URL]: {}\n[PARAMS]: {}\n[RESPONSE]: {}",uri, data, result); return result; } catch (WxErrorException e) { + if (retryTimes + 1 > this.maxRetryTimes) { + this.log.warn("重试达到最大次数【{}】", maxRetryTimes); + //最后一次重试失败后,直接抛出异常,不再等待 + throw new RuntimeException("微信服务端异常,超出重试次数"); + } + WxError error = e.getError(); // -1 系统繁忙, 1000ms后重试 if (error.getErrorCode() == -1) { int sleepMillis = this.retrySleepMillis * (1 << retryTimes); try { - this.log.debug("微信系统繁忙,{}ms 后重试(第{}次)", sleepMillis, retryTimes + 1); + this.log.warn("微信系统繁忙,{} ms 后重试(第{}次)", sleepMillis, retryTimes + 1); Thread.sleep(sleepMillis); } catch (InterruptedException e1) { throw new RuntimeException(e1); @@ -383,8 +389,9 @@ public class WxMpServiceImpl implements WxMpService { throw e; } } - } while (++retryTimes < this.maxRetryTimes); + } while (retryTimes++ < this.maxRetryTimes); + this.log.warn("重试达到最大次数【{}】", this.maxRetryTimes); throw new RuntimeException("微信服务端异常,超出重试次数"); } diff --git a/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/WxMpBusyRetryTest.java b/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/WxMpBusyRetryTest.java index a302cc2f..8d46eba7 100644 --- a/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/WxMpBusyRetryTest.java +++ b/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/api/WxMpBusyRetryTest.java @@ -1,17 +1,16 @@ package me.chanjar.weixin.mp.api; -import java.util.concurrent.ExecutionException; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; -import java.util.concurrent.Future; - -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; - import me.chanjar.weixin.common.bean.result.WxError; import me.chanjar.weixin.common.exception.WxErrorException; import me.chanjar.weixin.common.util.http.RequestExecutor; import me.chanjar.weixin.mp.api.impl.WxMpServiceImpl; +import org.testng.annotations.DataProvider; +import org.testng.annotations.Test; + +import java.util.concurrent.ExecutionException; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; +import java.util.concurrent.Future; @Test public class WxMpBusyRetryTest { @@ -24,6 +23,7 @@ public class WxMpBusyRetryTest { protected synchronized T executeInternal( RequestExecutor executor, String uri, E data) throws WxErrorException { + this.log.info("Executed"); WxError error = new WxError(); error.setErrorCode(-1); throw new WxErrorException(error); @@ -32,9 +32,7 @@ public class WxMpBusyRetryTest { service.setMaxRetryTimes(3); service.setRetrySleepMillis(500); - return new Object[][] { - new Object[] { service } - }; + return new Object[][] { { service } }; } @Test(dataProvider = "getService", expectedExceptions = RuntimeException.class) From 00421c4e6fc1c431a9895f04beede02795bf1093 Mon Sep 17 00:00:00 2001 From: Binary Wang Date: Thu, 15 Dec 2016 15:26:12 +0800 Subject: [PATCH 12/21] =?UTF-8?q?=E4=B8=BA=E6=8E=A5=E5=8F=A3=E8=AF=B7?= =?UTF-8?q?=E6=B1=82=E5=A2=9E=E5=8A=A0=E6=97=A5=E5=BF=97=E8=BE=93=E5=87=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/me/chanjar/weixin/cp/api/WxCpServiceImpl.java | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpServiceImpl.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpServiceImpl.java index 734593d4..a2bd3659 100644 --- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpServiceImpl.java +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpServiceImpl.java @@ -538,7 +538,9 @@ public class WxCpServiceImpl implements WxCpService { int retryTimes = 0; do { try { - return executeInternal(executor, uri, data); + T result = this.executeInternal(executor, uri, data); + this.log.debug("\n[URL]: {}\n[PARAMS]: {}\n[RESPONSE]: {}",uri, data, result); + return result; } catch (WxErrorException e) { if (retryTimes + 1 > this.maxRetryTimes) { this.log.warn("重试达到最大次数【{}】", this.maxRetryTimes); @@ -578,8 +580,7 @@ public class WxCpServiceImpl implements WxCpService { uriWithAccessToken += uri.indexOf('?') == -1 ? "?access_token=" + accessToken : "&access_token=" + accessToken; try { - return executor.execute(getHttpclient(), this.httpProxy, - uriWithAccessToken, data); + return executor.execute(getHttpclient(), this.httpProxy, uriWithAccessToken, data); } catch (WxErrorException e) { WxError error = e.getError(); /* @@ -592,11 +593,14 @@ public class WxCpServiceImpl implements WxCpService { this.configStorage.expireAccessToken(); return execute(executor, uri, data); } + if (error.getErrorCode() != 0) { + this.log.error("\n[URL]: {}\n[PARAMS]: {}\n[RESPONSE]: {}", uri, data, error); throw new WxErrorException(error); } return null; } catch (IOException e) { + this.log.error("\n[URL]: {}\n[PARAMS]: {}\n[EXCEPTION]: {}", uri, data, e.getMessage()); throw new RuntimeException(e); } } From 84a79a9760e58db0daf776301834005ad7d2c8c2 Mon Sep 17 00:00:00 2001 From: Binary Wang Date: Thu, 15 Dec 2016 16:00:02 +0800 Subject: [PATCH 13/21] ".equals()" should not be used to test the values of "Atomic" classes --- .../weixin/common/session/StandardSession.java | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/weixin-java-common/src/main/java/me/chanjar/weixin/common/session/StandardSession.java b/weixin-java-common/src/main/java/me/chanjar/weixin/common/session/StandardSession.java index 89d847d7..dc2a0105 100644 --- a/weixin-java-common/src/main/java/me/chanjar/weixin/common/session/StandardSession.java +++ b/weixin-java-common/src/main/java/me/chanjar/weixin/common/session/StandardSession.java @@ -12,7 +12,7 @@ public class StandardSession implements WxSession, InternalSession { * The string manager for this package. */ protected static final StringManager sm = - StringManager.getManager(Constants.Package); + StringManager.getManager(Constants.Package); /** * Type array. */ @@ -73,7 +73,7 @@ public class StandardSession implements WxSession, InternalSession { if (!isValidInternal()) throw new IllegalStateException - (sm.getString("sessionImpl.getAttribute.ise")); + (sm.getString("sessionImpl.getAttribute.ise")); if (name == null) return null; @@ -84,7 +84,7 @@ public class StandardSession implements WxSession, InternalSession { public Enumeration getAttributeNames() { if (!isValidInternal()) throw new IllegalStateException - (sm.getString("sessionImpl.getAttributeNames.ise")); + (sm.getString("sessionImpl.getAttributeNames.ise")); Set names = new HashSet<>(); names.addAll(this.attributes.keySet()); @@ -96,7 +96,7 @@ public class StandardSession implements WxSession, InternalSession { // Name cannot be null if (name == null) throw new IllegalArgumentException - (sm.getString("sessionImpl.setAttribute.namenull")); + (sm.getString("sessionImpl.setAttribute.namenull")); // Null value is the same as removeAttribute() if (value == null) { @@ -107,7 +107,7 @@ public class StandardSession implements WxSession, InternalSession { // Validate our current state if (!isValidInternal()) throw new IllegalStateException(sm.getString( - "sessionImpl.setAttribute.ise", getIdInternal())); + "sessionImpl.setAttribute.ise", getIdInternal())); this.attributes.put(name, value); @@ -122,7 +122,7 @@ public class StandardSession implements WxSession, InternalSession { public void invalidate() { if (!isValidInternal()) throw new IllegalStateException - (sm.getString("sessionImpl.invalidate.ise")); + (sm.getString("sessionImpl.invalidate.ise")); // Cause this session to expire expire(); @@ -305,7 +305,7 @@ public class StandardSession implements WxSession, InternalSession { if (this.isValid != session.isValid) return false; if (this.maxInactiveInterval != session.maxInactiveInterval) return false; if (this.thisAccessedTime != session.thisAccessedTime) return false; - if (!this.accessCount.equals(session.accessCount)) return false; + if (this.accessCount.get() != session.accessCount.get()) return false; if (!this.attributes.equals(session.attributes)) return false; if (!this.facade.equals(session.facade)) return false; if (!this.id.equals(session.id)) return false; From 761c570cad87432d0be557c749c30d289fd528b7 Mon Sep 17 00:00:00 2001 From: Binary Wang Date: Thu, 15 Dec 2016 16:13:49 +0800 Subject: [PATCH 14/21] =?UTF-8?q?=E6=B6=88=E7=81=AD=E4=B8=8D=E8=A7=84?= =?UTF-8?q?=E8=8C=83=E4=BB=A3=E7=A0=81=EF=BC=88=E7=94=B1sonatype=E6=A3=80?= =?UTF-8?q?=E6=B5=8B=E5=87=BA=E6=9D=A5=E7=9A=84=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/session/StandardSession.java | 110 +++++++++++------- 1 file changed, 69 insertions(+), 41 deletions(-) diff --git a/weixin-java-common/src/main/java/me/chanjar/weixin/common/session/StandardSession.java b/weixin-java-common/src/main/java/me/chanjar/weixin/common/session/StandardSession.java index dc2a0105..f9d61707 100644 --- a/weixin-java-common/src/main/java/me/chanjar/weixin/common/session/StandardSession.java +++ b/weixin-java-common/src/main/java/me/chanjar/weixin/common/session/StandardSession.java @@ -11,12 +11,12 @@ public class StandardSession implements WxSession, InternalSession { /** * The string manager for this package. */ - protected static final StringManager sm = - StringManager.getManager(Constants.Package); + protected static final StringManager sm = StringManager.getManager(Constants.Package); /** * Type array. */ - protected static final String EMPTY_ARRAY[] = new String[0]; + private static final String[] EMPTY_ARRAY = new String[0]; + // ------------------------------ WxSession protected Map attributes = new ConcurrentHashMap<>(); /** @@ -71,20 +71,23 @@ public class StandardSession implements WxSession, InternalSession { @Override public Object getAttribute(String name) { - if (!isValidInternal()) + if (!isValidInternal()) { throw new IllegalStateException (sm.getString("sessionImpl.getAttribute.ise")); + } - if (name == null) return null; + if (name == null) { + return null; + } - return (this.attributes.get(name)); + return this.attributes.get(name); } @Override public Enumeration getAttributeNames() { - if (!isValidInternal()) - throw new IllegalStateException - (sm.getString("sessionImpl.getAttributeNames.ise")); + if (!isValidInternal()) { + throw new IllegalStateException(sm.getString("sessionImpl.getAttributeNames.ise")); + } Set names = new HashSet<>(); names.addAll(this.attributes.keySet()); @@ -94,9 +97,9 @@ public class StandardSession implements WxSession, InternalSession { @Override public void setAttribute(String name, Object value) { // Name cannot be null - if (name == null) - throw new IllegalArgumentException - (sm.getString("sessionImpl.setAttribute.namenull")); + if (name == null) { + throw new IllegalArgumentException(sm.getString("sessionImpl.setAttribute.namenull")); + } // Null value is the same as removeAttribute() if (value == null) { @@ -105,9 +108,9 @@ public class StandardSession implements WxSession, InternalSession { } // Validate our current state - if (!isValidInternal()) - throw new IllegalStateException(sm.getString( - "sessionImpl.setAttribute.ise", getIdInternal())); + if (!isValidInternal()) { + throw new IllegalStateException(sm.getString("sessionImpl.setAttribute.ise", getIdInternal())); + } this.attributes.put(name, value); @@ -121,8 +124,7 @@ public class StandardSession implements WxSession, InternalSession { @Override public void invalidate() { if (!isValidInternal()) - throw new IllegalStateException - (sm.getString("sessionImpl.invalidate.ise")); + throw new IllegalStateException(sm.getString("sessionImpl.invalidate.ise")); // Cause this session to expire expire(); @@ -131,12 +133,11 @@ public class StandardSession implements WxSession, InternalSession { @Override public WxSession getSession() { - if (this.facade == null) { this.facade = new StandardSessionFacade(this); } - return (this.facade); + return this.facade; } /** @@ -185,12 +186,14 @@ public class StandardSession implements WxSession, InternalSession { @Override public String getIdInternal() { - return (this.id); + return this.id; } protected void removeAttributeInternal(String name) { // Avoid NPE - if (name == null) return; + if (name == null) { + return; + } // Remove this attribute from our collection this.attributes.remove(name); @@ -202,19 +205,22 @@ public class StandardSession implements WxSession, InternalSession { // Check to see if session has already been invalidated. // Do not check expiring at this point as expire should not return until // isValid is false - if (!this.isValid) + if (!this.isValid) { return; + } synchronized (this) { // Check again, now we are inside the sync so this code only runs once // Double check locking - isValid needs to be volatile // The check of expiring is to ensure that an infinite loop is not // entered as per bug 56339 - if (this.expiring || !this.isValid) + if (this.expiring || !this.isValid) { return; + } - if (this.manager == null) + if (this.manager == null) { return; + } // Mark this session as "being expired" this.expiring = true; @@ -230,9 +236,9 @@ public class StandardSession implements WxSession, InternalSession { this.expiring = false; // Unbind any objects associated with this session - String keys[] = keys(); - for (int i = 0; i < keys.length; i++) { - removeAttributeInternal(keys[i]); + String[] keys = keys(); + for (String key : keys) { + removeAttributeInternal(key); } } @@ -273,13 +279,15 @@ public class StandardSession implements WxSession, InternalSession { @Override public void setId(String id) { - if ((this.id != null) && (this.manager != null)) + if ((this.id != null) && (this.manager != null)) { this.manager.remove(this); + } this.id = id; - if (this.manager != null) + if (this.manager != null) { this.manager.add(this); + } } /** @@ -295,21 +303,41 @@ public class StandardSession implements WxSession, InternalSession { @Override public boolean equals(Object o) { - if (this == o) return true; - if (!(o instanceof StandardSession)) return false; + if (this == o) { + return true; + } + if (!(o instanceof StandardSession)) { + return false; + } StandardSession session = (StandardSession) o; - if (this.creationTime != session.creationTime) return false; - if (this.expiring != session.expiring) return false; - if (this.isValid != session.isValid) return false; - if (this.maxInactiveInterval != session.maxInactiveInterval) return false; - if (this.thisAccessedTime != session.thisAccessedTime) return false; - if (this.accessCount.get() != session.accessCount.get()) return false; - if (!this.attributes.equals(session.attributes)) return false; - if (!this.facade.equals(session.facade)) return false; - if (!this.id.equals(session.id)) return false; - return this.manager.equals(session.manager); + if (this.creationTime != session.creationTime) { + return false; + } + if (this.expiring != session.expiring) { + return false; + } + if (this.isValid != session.isValid) { + return false; + } + if (this.maxInactiveInterval != session.maxInactiveInterval) { + return false; + } + if (this.thisAccessedTime != session.thisAccessedTime) { + return false; + } + if (this.accessCount.get() != session.accessCount.get()) { + return false; + } + if (!this.attributes.equals(session.attributes)) { + return false; + } + if (!this.facade.equals(session.facade)) { + return false; + } + + return this.id.equals(session.id) && this.manager.equals(session.manager); } From 1524de26e62815ba37e2ecdbf0d037ebd8beb7df Mon Sep 17 00:00:00 2001 From: Binary Wang Date: Thu, 15 Dec 2016 16:41:14 +0800 Subject: [PATCH 15/21] =?UTF-8?q?=E6=B6=88=E7=81=AD=E4=B8=8D=E8=A7=84?= =?UTF-8?q?=E8=8C=83=E4=BB=A3=E7=A0=81=EF=BC=88=E7=94=B1sonatype=E6=A3=80?= =?UTF-8?q?=E6=B5=8B=E5=87=BA=E6=9D=A5=E7=9A=84=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/me/chanjar/weixin/common/bean/result/WxError.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/weixin-java-common/src/main/java/me/chanjar/weixin/common/bean/result/WxError.java b/weixin-java-common/src/main/java/me/chanjar/weixin/common/bean/result/WxError.java index 54b8b1fd..46c0ae89 100644 --- a/weixin-java-common/src/main/java/me/chanjar/weixin/common/bean/result/WxError.java +++ b/weixin-java-common/src/main/java/me/chanjar/weixin/common/bean/result/WxError.java @@ -20,8 +20,7 @@ public class WxError implements Serializable { private String json; public static WxError fromJson(String json) { - WxError error = WxGsonBuilder.create().fromJson(json, WxError.class); - return error; + return WxGsonBuilder.create().fromJson(json, WxError.class); } public static Builder newBuilder() { From 4812697b36f19c223637c5be335c2184e08e073b Mon Sep 17 00:00:00 2001 From: Binary Wang Date: Thu, 15 Dec 2016 16:41:26 +0800 Subject: [PATCH 16/21] =?UTF-8?q?=E6=B6=88=E7=81=AD=E4=B8=8D=E8=A7=84?= =?UTF-8?q?=E8=8C=83=E4=BB=A3=E7=A0=81=EF=BC=88=E7=94=B1sonatype=E6=A3=80?= =?UTF-8?q?=E6=B5=8B=E5=87=BA=E6=9D=A5=E7=9A=84=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mp/bean/message/WxMpXmlMessageTest.java | 208 +++++++++--------- 1 file changed, 104 insertions(+), 104 deletions(-) diff --git a/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/bean/message/WxMpXmlMessageTest.java b/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/bean/message/WxMpXmlMessageTest.java index 8f49ce99..23de3fe6 100644 --- a/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/bean/message/WxMpXmlMessageTest.java +++ b/weixin-java-mp/src/test/java/me/chanjar/weixin/mp/bean/message/WxMpXmlMessageTest.java @@ -10,63 +10,63 @@ public class WxMpXmlMessageTest { public void testFromXml() { String xml = "" - + "" - + " " - + "1348831860" - + "" - + "" - + "1234567890123456" - + "" - + "" - + "" - + "" - + "23.134521" - + "113.358803" - + "20" - + "" - + "" - + "" - + "<![CDATA[公众平台官网链接]]>" - + "" - + "" - + "" - + "23.137466" - + "113.352425" - + "119.385040" - + "" - + " " - + " " - + "" - + "" - + " 1\n" - + " " - + " " - + " " - + " " - + " " - + "" - + "" - + " \n" - + " \n" - + " \n" - + " \n" - + " \n" - + "" - + ""; + + "" + + " " + + "1348831860" + + "" + + "" + + "1234567890123456" + + "" + + "" + + "" + + "" + + "23.134521" + + "113.358803" + + "20" + + "" + + "" + + "" + + "<![CDATA[公众平台官网链接]]>" + + "" + + "" + + "" + + "23.137466" + + "113.352425" + + "119.385040" + + "" + + " " + + " " + + "" + + "" + + " 1\n" + + " " + + " " + + " " + + " " + + " " + + "" + + "" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + "" + + ""; WxMpXmlMessage wxMessage = WxMpXmlMessage.fromXml(xml); Assert.assertEquals(wxMessage.getToUser(), "toUser"); Assert.assertEquals(wxMessage.getFromUser(), "fromUser"); - Assert.assertEquals(wxMessage.getCreateTime(), new Long(1348831860l)); + Assert.assertEquals(wxMessage.getCreateTime(), new Long(1348831860L)); Assert.assertEquals(wxMessage.getMsgType(), WxConsts.XML_MSG_TEXT); Assert.assertEquals(wxMessage.getContent(), "this is a test"); - Assert.assertEquals(wxMessage.getMsgId(), new Long(1234567890123456l)); + Assert.assertEquals(wxMessage.getMsgId(), new Long(1234567890123456L)); Assert.assertEquals(wxMessage.getPicUrl(), "this is a url"); Assert.assertEquals(wxMessage.getMediaId(), "media_id"); Assert.assertEquals(wxMessage.getFormat(), "Format"); Assert.assertEquals(wxMessage.getThumbMediaId(), "thumb_media_id"); - Assert.assertEquals(wxMessage.getLocationX(), new Double(23.134521d)); - Assert.assertEquals(wxMessage.getLocationY(), new Double(113.358803d)); - Assert.assertEquals(wxMessage.getScale(), new Double(20)); + Assert.assertEquals(wxMessage.getLocationX(), 23.134521d); + Assert.assertEquals(wxMessage.getLocationY(), 113.358803d); + Assert.assertEquals(wxMessage.getScale(), 20d); Assert.assertEquals(wxMessage.getLabel(), "位置信息"); Assert.assertEquals(wxMessage.getDescription(), "公众平台官网链接"); Assert.assertEquals(wxMessage.getUrl(), "url"); @@ -74,12 +74,12 @@ public class WxMpXmlMessageTest { Assert.assertEquals(wxMessage.getEvent(), "subscribe"); Assert.assertEquals(wxMessage.getEventKey(), "qrscene_123123"); Assert.assertEquals(wxMessage.getTicket(), "TICKET"); - Assert.assertEquals(wxMessage.getLatitude(), new Double(23.137466)); - Assert.assertEquals(wxMessage.getLongitude(), new Double(113.352425)); - Assert.assertEquals(wxMessage.getPrecision(), new Double(119.385040)); + Assert.assertEquals(wxMessage.getLatitude(), 23.137466); + Assert.assertEquals(wxMessage.getLongitude(), 113.352425); + Assert.assertEquals(wxMessage.getPrecision(), 119.385040); Assert.assertEquals(wxMessage.getScanCodeInfo().getScanType(), "qrcode"); Assert.assertEquals(wxMessage.getScanCodeInfo().getScanResult(), "1"); - Assert.assertEquals(wxMessage.getSendPicsInfo().getCount(), new Long(1l)); + Assert.assertEquals(wxMessage.getSendPicsInfo().getCount(), new Long(1L)); Assert.assertEquals(wxMessage.getSendPicsInfo().getPicList().get(0).getPicMd5Sum(), "1b5f7c23b5bf75682a53e7b6d163e185"); Assert.assertEquals(wxMessage.getSendLocationInfo().getLocationX(), "23"); Assert.assertEquals(wxMessage.getSendLocationInfo().getLocationY(), "113"); @@ -91,63 +91,63 @@ public class WxMpXmlMessageTest { public void testFromXml2() { String xml = "" - + "" - + " " - + "1348831860" - + "" - + "" - + "1234567890123456" - + "" - + "" - + "" - + "" - + "23.134521" - + "113.358803" - + "20" - + "" - + "" - + "" - + "<![CDATA[公众平台官网链接]]>" - + "" - + "" - + "" - + "23.137466" - + "113.352425" - + "119.385040" - + "" - + " " - + " " - + "" - + "" - + " 1\n" - + " " - + " " - + " " - + " " - + " " - + "" - + "" - + " \n" - + " \n" - + " \n" - + " \n" - + " \n" - + "" - + ""; + + "" + + " " + + "1348831860" + + "" + + "" + + "1234567890123456" + + "" + + "" + + "" + + "" + + "23.134521" + + "113.358803" + + "20" + + "" + + "" + + "" + + "<![CDATA[公众平台官网链接]]>" + + "" + + "" + + "" + + "23.137466" + + "113.352425" + + "119.385040" + + "" + + " " + + " " + + "" + + "" + + " 1\n" + + " " + + " " + + " " + + " " + + " " + + "" + + "" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + "" + + ""; WxMpXmlMessage wxMessage = WxMpXmlMessage.fromXml(xml); Assert.assertEquals(wxMessage.getToUser(), "toUser"); Assert.assertEquals(wxMessage.getFromUser(), "fromUser"); - Assert.assertEquals(wxMessage.getCreateTime(), new Long(1348831860l)); + Assert.assertEquals(wxMessage.getCreateTime(), new Long(1348831860L)); Assert.assertEquals(wxMessage.getMsgType(), WxConsts.XML_MSG_TEXT); Assert.assertEquals(wxMessage.getContent(), "this is a test"); - Assert.assertEquals(wxMessage.getMsgId(), new Long(1234567890123456l)); + Assert.assertEquals(wxMessage.getMsgId(), new Long(1234567890123456L)); Assert.assertEquals(wxMessage.getPicUrl(), "this is a url"); Assert.assertEquals(wxMessage.getMediaId(), "media_id"); Assert.assertEquals(wxMessage.getFormat(), "Format"); Assert.assertEquals(wxMessage.getThumbMediaId(), "thumb_media_id"); - Assert.assertEquals(wxMessage.getLocationX(), new Double(23.134521d)); - Assert.assertEquals(wxMessage.getLocationY(), new Double(113.358803d)); - Assert.assertEquals(wxMessage.getScale(), new Double(20)); + Assert.assertEquals(wxMessage.getLocationX(), 23.134521d); + Assert.assertEquals(wxMessage.getLocationY(), 113.358803d); + Assert.assertEquals(wxMessage.getScale(), 20d); Assert.assertEquals(wxMessage.getLabel(), "位置信息"); Assert.assertEquals(wxMessage.getDescription(), "公众平台官网链接"); Assert.assertEquals(wxMessage.getUrl(), "url"); @@ -155,12 +155,12 @@ public class WxMpXmlMessageTest { Assert.assertEquals(wxMessage.getEvent(), "subscribe"); Assert.assertEquals(wxMessage.getEventKey(), "qrscene_123123"); Assert.assertEquals(wxMessage.getTicket(), "TICKET"); - Assert.assertEquals(wxMessage.getLatitude(), new Double(23.137466)); - Assert.assertEquals(wxMessage.getLongitude(), new Double(113.352425)); - Assert.assertEquals(wxMessage.getPrecision(), new Double(119.385040)); + Assert.assertEquals(wxMessage.getLatitude(), 23.137466); + Assert.assertEquals(wxMessage.getLongitude(), 113.352425); + Assert.assertEquals(wxMessage.getPrecision(), 119.385040); Assert.assertEquals(wxMessage.getScanCodeInfo().getScanType(), "qrcode"); Assert.assertEquals(wxMessage.getScanCodeInfo().getScanResult(), "1"); - Assert.assertEquals(wxMessage.getSendPicsInfo().getCount(), new Long(1l)); + Assert.assertEquals(wxMessage.getSendPicsInfo().getCount(), new Long(1L)); Assert.assertEquals(wxMessage.getSendPicsInfo().getPicList().get(0).getPicMd5Sum(), "1b5f7c23b5bf75682a53e7b6d163e185"); Assert.assertEquals(wxMessage.getSendLocationInfo().getLocationX(), "23"); Assert.assertEquals(wxMessage.getSendLocationInfo().getLocationY(), "113"); From 52221e72fc1f234a15c30bd5c9cc71305d6c1444 Mon Sep 17 00:00:00 2001 From: dongfuqiang Date: Fri, 16 Dec 2016 11:15:24 +0800 Subject: [PATCH 17/21] =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=B1=9E=E6=80=A7?= =?UTF-8?q?=E5=91=BD=E5=90=8D=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../weixin/mp/bean/device/BaseResp.java | 13 ++- .../weixin/mp/bean/device/RespMsg.java | 4 + .../weixin/mp/bean/device/TransMsgResp.java | 12 ++- .../weixin/mp/bean/device/WxDevice.java | 101 ++++++++++-------- .../mp/bean/device/WxDeviceAuthorize.java | 39 ++++--- .../weixin/mp/bean/device/WxDeviceBind.java | 13 ++- .../mp/bean/device/WxDeviceBindResult.java | 12 ++- .../weixin/mp/bean/device/WxDeviceMsg.java | 4 + .../mp/bean/device/WxDeviceQrCodeResult.java | 45 ++++---- 9 files changed, 141 insertions(+), 102 deletions(-) diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/device/BaseResp.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/device/BaseResp.java index 5a3082f6..42c57f0b 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/device/BaseResp.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/device/BaseResp.java @@ -1,10 +1,13 @@ package me.chanjar.weixin.mp.bean.device; +import com.google.gson.annotations.SerializedName; + /** * Created by keungtung on 10/12/2016. */ public class BaseResp extends AbstractDeviceBean{ - private BaseInfo base_info; + @SerializedName("base_info") + private BaseInfo baseInfo; private Integer errcode; private String errmsg; @@ -16,12 +19,12 @@ public class BaseResp extends AbstractDeviceBean{ this.errcode = errcode; } - public BaseInfo getBase_info() { - return base_info; + public BaseInfo getBaseInfo() { + return baseInfo; } - public void setBase_info(BaseInfo base_info) { - this.base_info = base_info; + public void setBaseInfo(BaseInfo baseInfo) { + this.baseInfo = baseInfo; } public String getErrmsg() { diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/device/RespMsg.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/device/RespMsg.java index e0291fbb..f1fdedff 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/device/RespMsg.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/device/RespMsg.java @@ -1,11 +1,15 @@ package me.chanjar.weixin.mp.bean.device; +import com.google.gson.annotations.SerializedName; + /** * Created by keungtung on 10/12/2016. */ public class RespMsg extends AbstractDeviceBean{ + @SerializedName("ret_code") private Integer retCode; + @SerializedName("error_info") private String errorInfo; public Integer getRetCode() { diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/device/TransMsgResp.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/device/TransMsgResp.java index 6d5fbe06..d1f6484f 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/device/TransMsgResp.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/device/TransMsgResp.java @@ -1,5 +1,6 @@ package me.chanjar.weixin.mp.bean.device; +import com.google.gson.annotations.SerializedName; import me.chanjar.weixin.common.util.json.WxGsonBuilder; /** @@ -7,7 +8,8 @@ import me.chanjar.weixin.common.util.json.WxGsonBuilder; */ public class TransMsgResp extends AbstractDeviceBean{ private Integer ret; - private String ret_info; + @SerializedName("ret_info") + private String retInfo; private Integer errcode; private String errmsg; @@ -23,12 +25,12 @@ public class TransMsgResp extends AbstractDeviceBean{ this.ret = ret; } - public String getRet_info() { - return ret_info; + public String getRetInfo() { + return retInfo; } - public void setRet_info(String ret_info) { - this.ret_info = ret_info; + public void setRetInfo(String retInfo) { + this.retInfo = retInfo; } public Integer getErrcode() { diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/device/WxDevice.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/device/WxDevice.java index f36c4b10..c0f95dbf 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/device/WxDevice.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/device/WxDevice.java @@ -1,20 +1,31 @@ package me.chanjar.weixin.mp.bean.device; +import com.google.gson.annotations.SerializedName; + /** * Created by keungtung on 10/12/2016. */ public class WxDevice { private String id; private String mac; - private String connect_protocol; - private String auth_key; - private String close_strategy; - private String conn_strategy; - private String crypt_method; - private String auth_ver; - private String manu_mac_pos; - private String ser_mac_pos; - private String ble_simple_protocol; + @SerializedName("connect_protocol") + private String connectProtocol; + @SerializedName("auth_key") + private String authKey; + @SerializedName("close_strategy") + private String closeStrategy; + @SerializedName("conn_strategy") + private String connStrategy; + @SerializedName("crypt_method") + private String cryptMethod; + @SerializedName("auth_ver") + private String authVer; + @SerializedName("manu_mac_pos") + private String manuMacPos; + @SerializedName("ser_mac_pos") + private String serMacPos; + @SerializedName("ble_simple_protocol") + private String bleSimpleProtocol; public String getId() { return id; @@ -32,75 +43,75 @@ public class WxDevice { this.mac = mac; } - public String getConnect_protocol() { - return connect_protocol; + public String getConnectProtocol() { + return connectProtocol; } - public void setConnect_protocol(String connect_protocol) { - this.connect_protocol = connect_protocol; + public void setConnectProtocol(String connectProtocol) { + this.connectProtocol = connectProtocol; } - public String getAuth_key() { - return auth_key; + public String getAuthKey() { + return authKey; } - public void setAuth_key(String auth_key) { - this.auth_key = auth_key; + public void setAuthKey(String authKey) { + this.authKey = authKey; } - public String getClose_strategy() { - return close_strategy; + public String getCloseStrategy() { + return closeStrategy; } - public void setClose_strategy(String close_strategy) { - this.close_strategy = close_strategy; + public void setCloseStrategy(String closeStrategy) { + this.closeStrategy = closeStrategy; } - public String getConn_strategy() { - return conn_strategy; + public String getConnStrategy() { + return connStrategy; } - public void setConn_strategy(String conn_strategy) { - this.conn_strategy = conn_strategy; + public void setConnStrategy(String connStrategy) { + this.connStrategy = connStrategy; } - public String getCrypt_method() { - return crypt_method; + public String getCryptMethod() { + return cryptMethod; } - public void setCrypt_method(String crypt_method) { - this.crypt_method = crypt_method; + public void setCryptMethod(String cryptMethod) { + this.cryptMethod = cryptMethod; } - public String getAuth_ver() { - return auth_ver; + public String getAuthVer() { + return authVer; } - public void setAuth_ver(String auth_ver) { - this.auth_ver = auth_ver; + public void setAuthVer(String authVer) { + this.authVer = authVer; } - public String getManu_mac_pos() { - return manu_mac_pos; + public String getManuMacPos() { + return manuMacPos; } - public void setManu_mac_pos(String manu_mac_pos) { - this.manu_mac_pos = manu_mac_pos; + public void setManuMacPos(String manuMacPos) { + this.manuMacPos = manuMacPos; } - public String getSer_mac_pos() { - return ser_mac_pos; + public String getSerMacPos() { + return serMacPos; } - public void setSer_mac_pos(String ser_mac_pos) { - this.ser_mac_pos = ser_mac_pos; + public void setSerMacPos(String serMacPos) { + this.serMacPos = serMacPos; } - public String getBle_simple_protocol() { - return ble_simple_protocol; + public String getBleSimpleProtocol() { + return bleSimpleProtocol; } - public void setBle_simple_protocol(String ble_simple_protocol) { - this.ble_simple_protocol = ble_simple_protocol; + public void setBleSimpleProtocol(String bleSimpleProtocol) { + this.bleSimpleProtocol = bleSimpleProtocol; } } diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/device/WxDeviceAuthorize.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/device/WxDeviceAuthorize.java index e1dcd9be..a37a8a42 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/device/WxDeviceAuthorize.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/device/WxDeviceAuthorize.java @@ -1,5 +1,7 @@ package me.chanjar.weixin.mp.bean.device; +import com.google.gson.annotations.SerializedName; + import java.util.Arrays; import java.util.LinkedList; import java.util.List; @@ -8,35 +10,38 @@ import java.util.List; * Created by keungtung on 10/12/2016. */ public class WxDeviceAuthorize extends AbstractDeviceBean { - private String deivce_num; - private String op_type; - private List device_list = new LinkedList<>(); - - public String getDeivce_num() { - return deivce_num; + @SerializedName("device_num") + private String deviceNum; + @SerializedName("op_type") + private String opType; + @SerializedName("device_list") + private List deviceList = new LinkedList<>(); + + public String getDeviceNum() { + return deviceNum; } - public void setDeivce_num(String deivce_num) { - this.deivce_num = deivce_num; + public void setDeviceNum(String deviceNum) { + this.deviceNum = deviceNum; } - public String getOp_type() { - return op_type; + public String getOpType() { + return opType; } - public void setOp_type(String op_type) { - this.op_type = op_type; + public void setOpType(String opType) { + this.opType = opType; } - public List getDevice_list() { - return device_list; + public List getDeviceList() { + return deviceList; } - public void setDevice_list(List device_list) { - this.device_list = device_list; + public void setDeviceList(List deviceList) { + this.deviceList = deviceList; } public void addDevice(WxDevice... devices) { - this.device_list.addAll(Arrays.asList(devices)); + this.deviceList.addAll(Arrays.asList(devices)); } } diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/device/WxDeviceBind.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/device/WxDeviceBind.java index e4588478..1236048c 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/device/WxDeviceBind.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/device/WxDeviceBind.java @@ -1,11 +1,14 @@ package me.chanjar.weixin.mp.bean.device; +import com.google.gson.annotations.SerializedName; + /** * Created by keungtung on 10/12/2016. */ public class WxDeviceBind extends AbstractDeviceBean{ private String ticket; - private String device_id; + @SerializedName("device_id") + private String deviceId; private String openid; public String getTicket() { @@ -16,12 +19,12 @@ public class WxDeviceBind extends AbstractDeviceBean{ this.ticket = ticket; } - public String getDevice_id() { - return device_id; + public String getDeviceId() { + return deviceId; } - public void setDevice_id(String device_id) { - this.device_id = device_id; + public void setDeviceId(String deviceId) { + this.deviceId = deviceId; } public String getOpenid() { diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/device/WxDeviceBindResult.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/device/WxDeviceBindResult.java index 8f41a320..26bdb84c 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/device/WxDeviceBindResult.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/device/WxDeviceBindResult.java @@ -1,22 +1,24 @@ package me.chanjar.weixin.mp.bean.device; +import com.google.gson.annotations.SerializedName; import me.chanjar.weixin.mp.util.json.WxMpGsonBuilder; /** * Created by keungtung on 10/12/2016. */ public class WxDeviceBindResult extends AbstractDeviceBean{ - private BaseResp base_resp; + @SerializedName("base_resp") + private BaseResp baseResp; public static WxDeviceBindResult fromJson(String json) { return WxMpGsonBuilder.create().fromJson(json, WxDeviceBindResult.class); } - public BaseResp getBase_resp() { - return base_resp; + public BaseResp getBaseResp() { + return baseResp; } - public void setBase_resp(BaseResp base_resp) { - this.base_resp = base_resp; + public void setBaseResp(BaseResp baseResp) { + this.baseResp = baseResp; } } diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/device/WxDeviceMsg.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/device/WxDeviceMsg.java index e01f09ab..bed1a8a2 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/device/WxDeviceMsg.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/device/WxDeviceMsg.java @@ -1,13 +1,17 @@ package me.chanjar.weixin.mp.bean.device; +import com.google.gson.annotations.SerializedName; import me.chanjar.weixin.common.util.ToStringUtils; /** * Created by keungtung on 10/12/2016. */ public class WxDeviceMsg extends AbstractDeviceBean{ + @SerializedName("device_type") private String deviceType; + @SerializedName("device_id") private String deviceId; + @SerializedName("open_id") private String openId; private String content; diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/device/WxDeviceQrCodeResult.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/device/WxDeviceQrCodeResult.java index c2f67c5f..9c89ff67 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/device/WxDeviceQrCodeResult.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/device/WxDeviceQrCodeResult.java @@ -1,49 +1,54 @@ package me.chanjar.weixin.mp.bean.device; +import com.google.gson.annotations.SerializedName; import me.chanjar.weixin.mp.util.json.WxMpGsonBuilder; /** * Created by keungtung on 10/12/2016. */ public class WxDeviceQrCodeResult extends AbstractDeviceBean{ - private String deviceid; - private String qrticket; - private String devcielicence; - private RespMsg resp_msg; + @SerializedName("deviceid") + private String deviceId; + @SerializedName("qrticket") + private String qrTicket; + @SerializedName("devicelicence") + private String deviceLicence; + @SerializedName("resp_msg") + private RespMsg respMsg; public static WxDeviceQrCodeResult fromJson(String json) { return WxMpGsonBuilder.INSTANCE.create().fromJson(json, WxDeviceQrCodeResult.class); } - public String getDevcielicence() { - return devcielicence; + public String getDeviceLicence() { + return deviceLicence; } - public void setDevcielicence(String devcielicence) { - this.devcielicence = devcielicence; + public void setDeviceLicence(String deviceLicence) { + this.deviceLicence = deviceLicence; } - public RespMsg getResp_msg() { - return resp_msg; + public RespMsg getRespMsg() { + return respMsg; } - public void setResp_msg(RespMsg resp_msg) { - this.resp_msg = resp_msg; + public void setRespMsg(RespMsg respMsg) { + this.respMsg = respMsg; } - public String getDeviceid() { - return deviceid; + public String getDeviceId() { + return deviceId; } - public void setDeviceid(String deviceid) { - this.deviceid = deviceid; + public void setDeviceId(String deviceId) { + this.deviceId = deviceId; } - public String getQrticket() { - return qrticket; + public String getQrTicket() { + return qrTicket; } - public void setQrticket(String qrticket) { - this.qrticket = qrticket; + public void setQrTicket(String qrTicket) { + this.qrTicket = qrTicket; } } From a2106d30eca13f3ac584e3d715d2820722c1094c Mon Sep 17 00:00:00 2001 From: dongfuqiang Date: Fri, 16 Dec 2016 11:21:00 +0800 Subject: [PATCH 18/21] =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=B1=9E=E6=80=A7?= =?UTF-8?q?=E5=91=BD=E5=90=8D=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../weixin/mp/bean/device/BaseResp.java | 22 ++++++++++--------- .../weixin/mp/bean/device/TransMsgResp.java | 22 ++++++++++--------- .../weixin/mp/bean/device/WxDeviceBind.java | 11 +++++----- 3 files changed, 30 insertions(+), 25 deletions(-) diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/device/BaseResp.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/device/BaseResp.java index 42c57f0b..41629c55 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/device/BaseResp.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/device/BaseResp.java @@ -8,15 +8,17 @@ import com.google.gson.annotations.SerializedName; public class BaseResp extends AbstractDeviceBean{ @SerializedName("base_info") private BaseInfo baseInfo; - private Integer errcode; - private String errmsg; + @SerializedName("errcode") + private Integer errCode; + @SerializedName("errmsg") + private String errMsg; - public Integer getErrcode() { - return errcode; + public Integer getErrCode() { + return errCode; } - public void setErrcode(Integer errcode) { - this.errcode = errcode; + public void setErrCode(Integer errCode) { + this.errCode = errCode; } public BaseInfo getBaseInfo() { @@ -27,12 +29,12 @@ public class BaseResp extends AbstractDeviceBean{ this.baseInfo = baseInfo; } - public String getErrmsg() { - return errmsg; + public String getErrMsg() { + return errMsg; } - public void setErrmsg(String errmsg) { - this.errmsg = errmsg; + public void setErrMsg(String errMsg) { + this.errMsg = errMsg; } private class BaseInfo { diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/device/TransMsgResp.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/device/TransMsgResp.java index d1f6484f..8828b25c 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/device/TransMsgResp.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/device/TransMsgResp.java @@ -10,8 +10,10 @@ public class TransMsgResp extends AbstractDeviceBean{ private Integer ret; @SerializedName("ret_info") private String retInfo; - private Integer errcode; - private String errmsg; + @SerializedName("errcode") + private Integer errCode; + @SerializedName("errmsg") + private String errMsg; public static TransMsgResp fromJson(String json) { return WxGsonBuilder.create().fromJson(json, TransMsgResp.class); @@ -33,19 +35,19 @@ public class TransMsgResp extends AbstractDeviceBean{ this.retInfo = retInfo; } - public Integer getErrcode() { - return errcode; + public Integer getErrCode() { + return errCode; } - public void setErrcode(Integer errcode) { - this.errcode = errcode; + public void setErrCode(Integer errCode) { + this.errCode = errCode; } - public String getErrmsg() { - return errmsg; + public String getErrMsg() { + return errMsg; } - public void setErrmsg(String errmsg) { - this.errmsg = errmsg; + public void setErrMsg(String errMsg) { + this.errMsg = errMsg; } } diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/device/WxDeviceBind.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/device/WxDeviceBind.java index 1236048c..467f3c42 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/device/WxDeviceBind.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/device/WxDeviceBind.java @@ -9,7 +9,8 @@ public class WxDeviceBind extends AbstractDeviceBean{ private String ticket; @SerializedName("device_id") private String deviceId; - private String openid; + @SerializedName("openid") + private String openId; public String getTicket() { return ticket; @@ -27,11 +28,11 @@ public class WxDeviceBind extends AbstractDeviceBean{ this.deviceId = deviceId; } - public String getOpenid() { - return openid; + public String getOpenId() { + return openId; } - public void setOpenid(String openid) { - this.openid = openid; + public void setOpenId(String openId) { + this.openId = openId; } } From 12329d0a8ccb1dd35f2f3d3e0acb68b838bb2fdd Mon Sep 17 00:00:00 2001 From: Binary Wang Date: Fri, 16 Dec 2016 17:27:19 +0800 Subject: [PATCH 19/21] Update .travis.yml --- .travis.yml | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 65cf5e12..5fcb077e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,8 +1,14 @@ language: java +sudo: false +install: true +addons: + sonarqube: + token: + secure: "834110c7191f97ecb226970c46dcaff8e681da5a" + jdk: - oraclejdk7 - -script: "mvn clean package -Dmaven.test.skip=true" +#script: "mvn clean package -Dmaven.test.skip=true" branches: only: @@ -11,3 +17,10 @@ branches: notifications: email: - binaryw@qq.com + +script: + - mvn clean org.jacoco:jacoco-maven-plugin:prepare-agent package sonar:sonar +cache: + directories: + - '$HOME/.m2/repository' + - '$HOME/.sonar/cache' From e4b37f97627ca849352578cfeebe14a7f14af3f9 Mon Sep 17 00:00:00 2001 From: Binary Wang Date: Fri, 16 Dec 2016 17:32:30 +0800 Subject: [PATCH 20/21] Update .travis.yml --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 5fcb077e..ae9f5e64 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,7 +7,7 @@ addons: secure: "834110c7191f97ecb226970c46dcaff8e681da5a" jdk: - - oraclejdk7 + - oraclejdk8 #script: "mvn clean package -Dmaven.test.skip=true" branches: From 4758440792525a0ee4757b5236fe26420f635c35 Mon Sep 17 00:00:00 2001 From: Binary Wang Date: Fri, 16 Dec 2016 17:40:04 +0800 Subject: [PATCH 21/21] Update .travis.yml --- .travis.yml | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/.travis.yml b/.travis.yml index ae9f5e64..904ee9a4 100644 --- a/.travis.yml +++ b/.travis.yml @@ -9,18 +9,19 @@ addons: jdk: - oraclejdk8 #script: "mvn clean package -Dmaven.test.skip=true" - -branches: - only: - - develop - -notifications: - email: - - binaryw@qq.com script: - mvn clean org.jacoco:jacoco-maven-plugin:prepare-agent package sonar:sonar + +branches: + only: + - develop + cache: directories: - '$HOME/.m2/repository' - '$HOME/.sonar/cache' + +notifications: + email: + - binaryw@qq.com