Skip to content

Commit e69ef87

Browse files
authored
Merge pull request binarywang#16 from wechat-group/develop
merge Develop
2 parents 38ab775 + 41ca492 commit e69ef87

File tree

55 files changed

+1298
-1067
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+1298
-1067
lines changed

README.md

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,30 @@
1-
# Weixin Java Tools <a target="_blank" href="http://shang.qq.com/wpa/qunwpa?idkey=078f7a153d243853e24cf2b542e7a6ccbf2a592bc138080f84d11297f736ec46"><img border="0" src="http://pub.idqqimg.com/wpa/images/group.png" alt="weixin-java-tools" title="weixin-java-tools"></a>
2-
## 微信公众号/企业号开发Java SDK
3-
## [![Open Source Love](https://badges.frapsoft.com/os/v1/open-source.svg?v=103)](https://github.com/ellerbrock/open-source-badge/) ![Maven Central](https://img.shields.io/maven-central/v/com.github.binarywang/weixin-java-parent.svg) [![Build Status](https://travis-ci.org/binarywang/weixin-java-tools.svg?branch=develop)](https://travis-ci.org/binarywang/weixin-java-tools) [![Code Climate](https://codeclimate.com/github/binarywang/weixin-java-tools.png)](https://codeclimate.com/github/binarywang/weixin-java-tools)
1+
# Weixin Java Tools 微信公众号/企业号开发Java SDK
2+
## <a target="_blank" href="http://shang.qq.com/wpa/qunwpa?idkey=078f7a153d243853e24cf2b542e7a6ccbf2a592bc138080f84d11297f736ec46"><img border="0" src="http://pub.idqqimg.com/wpa/images/group.png" alt="weixin-java-tools" title="weixin-java-tools"></a> [![Open Source Love](https://badges.frapsoft.com/os/v1/open-source.svg?v=103)](https://github.com/ellerbrock/open-source-badge/) ![Maven Central](https://img.shields.io/maven-central/v/com.github.binarywang/weixin-java-parent.svg) [![Build Status](https://travis-ci.org/binarywang/weixin-java-tools.svg?branch=develop)](https://travis-ci.org/binarywang/weixin-java-tools)
43

54

65
### 声明:本项目基于chanjarster/weixin-java-tools,由于原作者长期没有维护,故单独维护和发布,且发布到maven上的groupId也会不同。
76
#### 最新更新:1.3.5版发布!!! on 2016-06-30
87

8+
---
9+
10+
#### 本项目主要存放在github上,地址为 :
11+
* https://github.com/wechat-group/weixin-java-tools
12+
* ===========但同时会在其他几个网站同步更新,地址分别是:
13+
* https://bitbucket.org/binarywang/weixin-java-tools
14+
* http://git.oschina.net/binary/weixin-java-tools
15+
* https://git.coding.net/binarywang/weixin-java-tools.git
16+
917
### 详细开发文档请看 [wiki](https://github.com/chanjarster/weixin-java-tools/wiki)
1018

19+
## 目前可参考的Demo项目:
20+
* https://github.com/wechat-group/weixin-java-tools-springmvc
21+
* https://github.com/wechat-group/weixin-mp-demo
22+
* =========以下为备份仓库,会保持跟主仓库同步
23+
* http://git.oschina.net/binary/weixin-mp-demo
24+
* https://bitbucket.org/binarywang/weixin-mp-demo
25+
1126
===========
12-
## 使用开发交流工具
27+
## 开发交流工具
1328
* QQ群:343954419 <a target="_blank" href="http://shang.qq.com/wpa/qunwpa?idkey=078f7a153d243853e24cf2b542e7a6ccbf2a592bc138080f84d11297f736ec46"><img border="0" src="http://pub.idqqimg.com/wpa/images/group.png" alt="weixin-java-tools" title="weixin-java-tools"></a>
1429
* 注意:为保证入群成员质量,请申请入群时认真输入Github帐号ID,即你的github主页地址https://github.com/XXXX 中最后的部分XXXX的内容,谢谢~
1530
* 微信群: 因二维码有时间限制,如有想加入微信群的,请入QQ群后咨询获取最新入群二维码。

weixin-java-common/src/main/java/me/chanjar/weixin/common/api/WxErrorExceptionHandler.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,6 @@
77
*/
88
public interface WxErrorExceptionHandler {
99

10-
public void handle(WxErrorException e);
10+
void handle(WxErrorException e);
1111

1212
}

weixin-java-common/src/main/java/me/chanjar/weixin/common/api/WxMessageDuplicateChecker.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,6 @@ public interface WxMessageDuplicateChecker {
2222
* @param messageId messageId需要根据上面讲的方式构造
2323
* @return 如果是重复消息,返回true,否则返回false
2424
*/
25-
public boolean isDuplicate(String messageId);
25+
boolean isDuplicate(String messageId);
2626

2727
}

weixin-java-common/src/main/java/me/chanjar/weixin/common/api/WxMessageInMemoryDuplicateChecker.java

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -87,11 +87,7 @@ public boolean isDuplicate(String messageId) {
8787
}
8888
checkBackgroundProcessStarted();
8989
Long timestamp = msgId2Timestamp.putIfAbsent(messageId, System.currentTimeMillis());
90-
if (timestamp == null) {
91-
// 第一次接收到这个消息
92-
return false;
93-
}
94-
return true;
90+
return timestamp != null;
9591
}
9692

9793

Lines changed: 68 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
package me.chanjar.weixin.common.bean;
22

3+
import org.apache.commons.lang3.builder.ToStringBuilder;
4+
import org.apache.commons.lang3.builder.ToStringStyle;
5+
36
import java.io.Serializable;
47

58
/**
@@ -10,95 +13,100 @@
1013
*/
1114
public class WxCardApiSignature implements Serializable {
1215

13-
private static final long serialVersionUID = 158176707226975979L;
16+
private static final long serialVersionUID = 158176707226975979L;
1417

15-
private String appId;
18+
private String appId;
1619

17-
private String cardId;
20+
private String cardId;
1821

19-
private String cardType;
22+
private String cardType;
2023

21-
private String locationId;
24+
private String locationId;
2225

23-
private String code;
26+
private String code;
2427

25-
private String openId;
28+
private String openId;
2629

27-
private Long timestamp;
30+
private Long timestamp;
2831

29-
private String nonceStr;
32+
private String nonceStr;
3033

31-
private String signature;
34+
private String signature;
3235

33-
public String getAppId() {
34-
return appId;
35-
}
36+
@Override
37+
public String toString() {
38+
return ToStringBuilder.reflectionToString(this, ToStringStyle.JSON_STYLE);
39+
}
3640

37-
public void setAppId(String appId) {
38-
this.appId = appId;
39-
}
41+
public String getAppId() {
42+
return appId;
43+
}
44+
45+
public void setAppId(String appId) {
46+
this.appId = appId;
47+
}
4048

41-
public String getCardId() {
42-
return cardId;
43-
}
49+
public String getCardId() {
50+
return cardId;
51+
}
4452

45-
public void setCardId(String cardId) {
46-
this.cardId = cardId;
47-
}
53+
public void setCardId(String cardId) {
54+
this.cardId = cardId;
55+
}
4856

49-
public String getCardType() {
50-
return cardType;
51-
}
57+
public String getCardType() {
58+
return cardType;
59+
}
5260

53-
public void setCardType(String cardType) {
54-
this.cardType = cardType;
55-
}
61+
public void setCardType(String cardType) {
62+
this.cardType = cardType;
63+
}
5664

57-
public String getLocationId() {
58-
return locationId;
59-
}
65+
public String getLocationId() {
66+
return locationId;
67+
}
6068

6169
public void setLocationId(String locationId) {
6270
this.locationId = locationId;
6371
}
6472

6573
public String getCode() {
66-
return code;
67-
}
74+
return code;
75+
}
6876

69-
public void setCode(String code) {
70-
this.code = code;
71-
}
77+
public void setCode(String code) {
78+
this.code = code;
79+
}
7280

73-
public String getOpenId() {
74-
return openId;
75-
}
81+
public String getOpenId() {
82+
return openId;
83+
}
7684

77-
public void setOpenId(String openId) {
78-
this.openId = openId;
79-
}
85+
public void setOpenId(String openId) {
86+
this.openId = openId;
87+
}
8088

81-
public Long getTimestamp() {
82-
return timestamp;
83-
}
89+
public Long getTimestamp() {
90+
return timestamp;
91+
}
8492

85-
public void setTimestamp(Long timestamp) {
86-
this.timestamp = timestamp;
87-
}
93+
public void setTimestamp(Long timestamp) {
94+
this.timestamp = timestamp;
95+
}
8896

89-
public String getNonceStr() {
90-
return nonceStr;
91-
}
97+
public String getNonceStr() {
98+
return nonceStr;
99+
}
92100

93-
public void setNonceStr(String nonceStr) {
94-
this.nonceStr = nonceStr;
95-
}
101+
public void setNonceStr(String nonceStr) {
102+
this.nonceStr = nonceStr;
103+
}
96104

97-
public String getSignature() {
98-
return signature;
99-
}
105+
public String getSignature() {
106+
return signature;
107+
}
100108

101-
public void setSignature(String signature) {
102-
this.signature = signature;
103-
}
109+
public void setSignature(String signature) {
110+
this.signature = signature;
111+
}
104112
}

weixin-java-common/src/main/java/me/chanjar/weixin/common/session/InternalSession.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ public interface InternalSession {
1313
*
1414
* @param isValid The new value for the <code>isValid</code> flag
1515
*/
16-
public void setValid(boolean isValid);
16+
void setValid(boolean isValid);
1717

1818
/**
1919
* Return the <code>isValid</code> flag for this session.

weixin-java-common/src/main/java/me/chanjar/weixin/common/session/InternalSessionManager.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,22 +28,22 @@ public interface InternalSessionManager {
2828
* @exception IllegalStateException if a new session cannot be
2929
* instantiated for any reason
3030
*/
31-
public InternalSession createSession(String sessionId);
31+
InternalSession createSession(String sessionId);
3232

3333
/**
3434
* Remove this Session from the active Sessions for this Manager.
3535
*
3636
* @param session Session to be removed
3737
*/
38-
public void remove(InternalSession session);
38+
void remove(InternalSession session);
3939

4040
/**
4141
* Remove this Session from the active Sessions for this Manager.
4242
*
4343
* @param session Session to be removed
4444
* @param update Should the expiration statistics be updated
4545
*/
46-
public void remove(InternalSession session, boolean update);
46+
void remove(InternalSession session, boolean update);
4747

4848
/**
4949
* Add this Session to the set of active Sessions for this Manager.
@@ -71,7 +71,7 @@ public interface InternalSessionManager {
7171
/**
7272
* Implements the Manager interface, direct call to processExpires
7373
*/
74-
public void backgroundProcess();
74+
void backgroundProcess();
7575

7676
/**
7777
* Set the default maximum inactive interval (in seconds)

weixin-java-common/src/main/java/me/chanjar/weixin/common/session/StandardSession.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -323,9 +323,8 @@ public boolean equals(Object o) {
323323
if (!attributes.equals(session.attributes)) return false;
324324
if (!facade.equals(session.facade)) return false;
325325
if (!id.equals(session.id)) return false;
326-
if (!manager.equals(session.manager)) return false;
326+
return manager.equals(session.manager);
327327

328-
return true;
329328
}
330329

331330
@Override

weixin-java-common/src/main/java/me/chanjar/weixin/common/session/WxSession.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@
44

55
public interface WxSession {
66

7-
public Object getAttribute(String name);
7+
Object getAttribute(String name);
88

9-
public Enumeration<String> getAttributeNames();
9+
Enumeration<String> getAttributeNames();
1010

11-
public void setAttribute(String name, Object value);
11+
void setAttribute(String name, Object value);
1212

13-
public void removeAttribute(String name);
13+
void removeAttribute(String name);
1414

15-
public void invalidate();
15+
void invalidate();
1616

1717
}

weixin-java-common/src/main/java/me/chanjar/weixin/common/session/WxSessionManager.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@ public interface WxSessionManager {
55
/**
66
* 获取某个sessionId对应的session,如果sessionId没有对应的session,则新建一个并返回。
77
*/
8-
public WxSession getSession(String sessionId);
8+
WxSession getSession(String sessionId);
99

1010
/**
1111
* 获取某个sessionId对应的session,如果sessionId没有对应的session,若create为true则新建一个,否则返回null。
1212
*/
13-
public WxSession getSession(String sessionId, boolean create);
13+
WxSession getSession(String sessionId, boolean create);
1414

1515

1616
}

weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/InputStreamResponseHandler.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ public class InputStreamResponseHandler implements ResponseHandler<InputStream>
1414

1515
public static final ResponseHandler<InputStream> INSTANCE = new InputStreamResponseHandler();
1616

17-
public InputStream handleResponse(final HttpResponse response) throws HttpResponseException, IOException {
17+
public InputStream handleResponse(final HttpResponse response) throws IOException {
1818
final StatusLine statusLine = response.getStatusLine();
1919
final HttpEntity entity = response.getEntity();
2020
if (statusLine.getStatusCode() >= 300) {

weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/MediaDownloadRequestExecutor.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public MediaDownloadRequestExecutor(File tmpDirFile) {
3939

4040

4141
@Override
42-
public File execute(CloseableHttpClient httpclient, HttpHost httpProxy, String uri, String queryParam) throws WxErrorException, ClientProtocolException, IOException {
42+
public File execute(CloseableHttpClient httpclient, HttpHost httpProxy, String uri, String queryParam) throws WxErrorException, IOException {
4343
if (queryParam != null) {
4444
if (uri.indexOf('?') == -1) {
4545
uri += '?';

weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/MediaUploadRequestExecutor.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
public class MediaUploadRequestExecutor implements RequestExecutor<WxMediaUploadResult, File> {
2626

2727
@Override
28-
public WxMediaUploadResult execute(CloseableHttpClient httpclient, HttpHost httpProxy, String uri, File file) throws WxErrorException, ClientProtocolException, IOException {
28+
public WxMediaUploadResult execute(CloseableHttpClient httpclient, HttpHost httpProxy, String uri, File file) throws WxErrorException, IOException {
2929
HttpPost httpPost = new HttpPost(uri);
3030
if (httpProxy != null) {
3131
RequestConfig config = RequestConfig.custom().setProxy(httpProxy).build();

weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/RequestExecutor.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,6 @@ public interface RequestExecutor<T, E> {
2626
* @throws ClientProtocolException
2727
* @throws IOException
2828
*/
29-
public T execute(CloseableHttpClient httpclient, HttpHost httpProxy, String uri, E data) throws WxErrorException, ClientProtocolException, IOException;
29+
T execute(CloseableHttpClient httpclient, HttpHost httpProxy, String uri, E data) throws WxErrorException, IOException;
3030

3131
}

weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/SimpleGetRequestExecutor.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
public class SimpleGetRequestExecutor implements RequestExecutor<String, String> {
2020

2121
@Override
22-
public String execute(CloseableHttpClient httpclient, HttpHost httpProxy, String uri, String queryParam) throws WxErrorException, ClientProtocolException, IOException {
22+
public String execute(CloseableHttpClient httpclient, HttpHost httpProxy, String uri, String queryParam) throws WxErrorException, IOException {
2323
if (queryParam != null) {
2424
if (uri.indexOf('?') == -1) {
2525
uri += '?';

weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/SimplePostRequestExecutor.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
public class SimplePostRequestExecutor implements RequestExecutor<String, String> {
2222

2323
@Override
24-
public String execute(CloseableHttpClient httpclient, HttpHost httpProxy, String uri, String postEntity) throws WxErrorException, ClientProtocolException, IOException {
24+
public String execute(CloseableHttpClient httpclient, HttpHost httpProxy, String uri, String postEntity) throws WxErrorException, IOException {
2525
HttpPost httpPost = new HttpPost(uri);
2626
if (httpProxy != null) {
2727
RequestConfig config = RequestConfig.custom().setProxy(httpProxy).build();

weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/Utf8ResponseHandler.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ public class Utf8ResponseHandler implements ResponseHandler<String> {
1919

2020
public static final ResponseHandler<String> INSTANCE = new Utf8ResponseHandler();
2121

22-
public String handleResponse(final HttpResponse response) throws HttpResponseException, IOException {
22+
public String handleResponse(final HttpResponse response) throws IOException {
2323
final StatusLine statusLine = response.getStatusLine();
2424
final HttpEntity entity = response.getEntity();
2525
if (statusLine.getStatusCode() >= 300) {

weixin-java-common/src/main/java/me/chanjar/weixin/common/util/json/GsonHelper.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ public static Boolean getAsBoolean(JsonElement element) {
9191

9292
public static boolean getAsPrimitiveBool(JsonElement element) {
9393
Boolean r = getAsBoolean(element);
94-
return r == null ? false : r.booleanValue();
94+
return r != null && r.booleanValue();
9595
}
9696

9797
public static Double getAsDouble(JsonElement element) {

0 commit comments

Comments
 (0)