Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
# Conflicts:
#	README.md
  • Loading branch information
binarywang committed Sep 30, 2016
2 parents af92403 + 5c53319 commit 9a26c75
Show file tree
Hide file tree
Showing 194 changed files with 5,769 additions and 2,720 deletions.
14 changes: 14 additions & 0 deletions .editorconfig
@@ -0,0 +1,14 @@
# EditorConfig: http://editorconfig.org/

root = true

[*]
indent_style = space
indent_size = 2
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

[*.md]
trim_trailing_whitespace = false
12 changes: 6 additions & 6 deletions README.md
Expand Up @@ -5,7 +5,7 @@
### 注意:
1. ***本项目Fork自chanjarster/weixin-java-tools,但由于原项目已停止维护,故单独维护和发布,且发布到maven上的groupId也会不同,详细信息见下文。***
1. ***自2.0.0版本以来,主要是公众号的接口调整比较大,主要是为了解决主接口类过于庞大不方便管理的问题,将接口实现代码按模块进行拆分。***
1. 最新更新:2016-08-31 发布2.1.0正式版!
1. 最新更新:2016-09-30 发布2.2.0正式版!

===========

Expand Down Expand Up @@ -33,12 +33,12 @@ maven:
<dependency>
<groupId>com.github.binarywang</groupId>
<artifactId>weixin-java-mp</artifactId>
<version>2.1.0</version>
<version>2.2.0</version>
</dependency>
```
gradle:
```groovy
compile 'com.github.binarywang:weixin-java-mp:2.1.0'
compile 'com.github.binarywang:weixin-java-mp:2.2.0'
```

* 企业号:
Expand All @@ -48,12 +48,12 @@ maven:
<dependency>
<groupId>com.github.binarywang</groupId>
<artifactId>weixin-java-cp</artifactId>
<version>2.1.0</version>
<version>2.2.0</version>
</dependency>
```
gradle:
```groovy
compile 'com.github.binarywang:weixin-java-cp:2.1.0'
compile 'com.github.binarywang:weixin-java-cp:2.2.0'
```

#### 本项目主要存放在github上,地址为 :
Expand All @@ -74,4 +74,4 @@ compile 'com.github.binarywang:weixin-java-cp:2.1.0'
* 本项目可以采用两种方式接受代码贡献:

1. 第一种就是基于[Git Flow](https://www.atlassian.com/git/tutorials/comparing-workflows/gitflow-workflow)开发流程,因此在发起Pull Request的时候请选择develop分支。
1. 另外一种贡献代码的方式就是加入SDK Developers开发组,如果对自己的代码足够自信,可以随时提交代码,注意要随时进行单元测试,保证提交代码没有明显问题,具体加入方式,请咨询管理员。
1. 另外一种贡献代码的方式就是加入SDK Developers开发组,前提是对自己的代码足够自信就可以申请加入,加入之后可以随时直接提交代码,但要注意对所做的修改或新增的代码进行单元测试,保证提交代码没有明显问题,具体加入方式,请咨询管理员。
8 changes: 5 additions & 3 deletions build.gradle
Expand Up @@ -2,7 +2,7 @@ allprojects {
apply plugin: 'maven'

group = 'com.github.binarywang'
version = '2.1.0-SNAPSHOT'
version = '2.2.0'
}

subprojects {
Expand All @@ -13,8 +13,8 @@ subprojects {

repositories {
mavenLocal()

maven { url "http://maven.aliyun.com/nexus/content/groups/public" }
maven { url "http://central.maven.org/maven2" }
//maven { url "http://maven.aliyun.com/nexus/content/groups/public" }
}


Expand All @@ -24,6 +24,8 @@ subprojects {
compile group: 'org.apache.httpcomponents', name: 'httpmime', version:'4.5'
compile group: 'org.jodd', name: 'jodd-http', version:'3.6.7'
compile group: 'com.google.code.gson', name: 'gson', version:'2.7'
compile group: 'com.google.guava', name: 'guava', version:'19.0'
compile group: 'org.jooq', name: 'joor', version:'0.9.6'
compile group: 'commons-codec', name: 'commons-codec', version:'1.10'
compile group: 'commons-io', name: 'commons-io', version:'2.5'
compile group: 'org.apache.commons', name: 'commons-lang3', version:'3.4'
Expand Down
29 changes: 22 additions & 7 deletions pom.xml
Expand Up @@ -5,7 +5,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.github.binarywang</groupId>
<artifactId>weixin-java-parent</artifactId>
<version>2.1.0</version>
<version>2.2.0</version>
<packaging>pom</packaging>
<name>WeiXin Java Tools - Parent</name>
<description>微信公众号、企业号上级POM</description>
Expand Down Expand Up @@ -49,9 +49,10 @@
<slf4j.version>1.7.10</slf4j.version>
<logback.version>1.1.2</logback.version>
<jodd-http.version>3.6.7</jodd-http.version>
<jackson.version>2.8.0</jackson.version>
<jedis.version>2.9.0</jedis.version>
<gson.version>2.7</gson.version>
<guava.version>19.0</guava.version>
<joor.version>0.9.6</joor.version>
<commons-lang3.version>3.4</commons-lang3.version>
<commons-io.version>2.5</commons-io.version>
<commons-codec.version>1.10</commons-codec.version>
Expand Down Expand Up @@ -106,15 +107,19 @@
<artifactId>commons-lang3</artifactId>
<version>${commons-lang3.version}</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>${jackson.version}</version>
</dependency>
<dependency>
<groupId>redis.clients</groupId>
<artifactId>jedis</artifactId>
<version>${jedis.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
</dependency>
<dependency>
<groupId>org.jooq</groupId>
<artifactId>joor</artifactId>
</dependency>
</dependencies>

Expand Down Expand Up @@ -156,6 +161,16 @@
<version>${jetty.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>${guava.version}</version>
</dependency>
<dependency>
<groupId>org.jooq</groupId>
<artifactId>joor</artifactId>
<version>${joor.version}</version>
</dependency>
</dependencies>
</dependencyManagement>

Expand Down
2 changes: 1 addition & 1 deletion weixin-java-common/pom.xml
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>com.github.binarywang</groupId>
<artifactId>weixin-java-parent</artifactId>
<version>2.1.0</version>
<version>2.2.0</version>
</parent>

<artifactId>weixin-java-common</artifactId>
Expand Down
@@ -0,0 +1,19 @@
package me.chanjar.weixin.common.annotation;

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

/**
* 标识某个字段是否是必填的
*
* Created by Binary Wang on 2016/9/25.
* @author binarywang (https://github.com/binarywang)
*
*/
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.FIELD)
public @interface Required {

}
Expand Up @@ -30,6 +30,7 @@ public class WxConsts {
public static final String CUSTOM_MSG_MUSIC = "music";
public static final String CUSTOM_MSG_NEWS = "news";
public static final String CUSTOM_MSG_FILE = "file";
public static final String CUSTOM_MSG_WXCARD = "wxcard";
public static final String CUSTOM_MSG_TRANSFER_CUSTOMER_SERVICE = "transfer_customer_service";
public static final String CUSTOM_MSG_SAFE_NO = "0";
public static final String CUSTOM_MSG_SAFE_YES = "1";
Expand Down Expand Up @@ -61,7 +62,7 @@ public class WxConsts {
/**
* 群发反馈消息代码所对应的文字描述
*/
public static final Map<String, String> MASS_ST_2_DESC = new HashMap<String, String>();
public static final Map<String, String> MASS_ST_2_DESC = new HashMap<>();
///////////////////////
// 微信端推送过来的事件类型
///////////////////////
Expand Down Expand Up @@ -92,6 +93,8 @@ public class WxConsts {
public static final String EVT_KF_CREATE_SESSION = "kf_create_session"; // 客服接入会话
public static final String EVT_KF_CLOSE_SESSION = "kf_close_session"; // 客服关闭会话
public static final String EVT_KF_SWITCH_SESSION = "kf_switch_session"; // 客服转接会话
public static final String EVT_POI_CHECK_NOTIFY = "poi_check_notify"; //门店审核事件推送

///////////////////////
// 上传多媒体文件的类型
///////////////////////
Expand Down
Expand Up @@ -25,7 +25,7 @@ public class WxMessageInMemoryDuplicateChecker implements WxMessageDuplicateChec
/**
* 消息id->消息时间戳的map
*/
private final ConcurrentHashMap<String, Long> msgId2Timestamp = new ConcurrentHashMap<String, Long>();
private final ConcurrentHashMap<String, Long> msgId2Timestamp = new ConcurrentHashMap<>();

/**
* 后台清理线程是否已经开启
Expand Down Expand Up @@ -56,19 +56,19 @@ public WxMessageInMemoryDuplicateChecker(Long timeToLive, Long clearPeriod) {
}

protected void checkBackgroundProcessStarted() {
if (backgroundProcessStarted.getAndSet(true)) {
if (this.backgroundProcessStarted.getAndSet(true)) {
return;
}
Thread t = new Thread(new Runnable() {
@Override
public void run() {
try {
while (true) {
Thread.sleep(clearPeriod);
Thread.sleep(WxMessageInMemoryDuplicateChecker.this.clearPeriod);
Long now = System.currentTimeMillis();
for (Map.Entry<String, Long> entry : msgId2Timestamp.entrySet()) {
if (now - entry.getValue() > timeToLive) {
msgId2Timestamp.entrySet().remove(entry);
for (Map.Entry<String, Long> entry : WxMessageInMemoryDuplicateChecker.this.msgId2Timestamp.entrySet()) {
if (now - entry.getValue() > WxMessageInMemoryDuplicateChecker.this.timeToLive) {
WxMessageInMemoryDuplicateChecker.this.msgId2Timestamp.entrySet().remove(entry);
}
}
}
Expand All @@ -87,7 +87,7 @@ public boolean isDuplicate(String messageId) {
return false;
}
checkBackgroundProcessStarted();
Long timestamp = msgId2Timestamp.putIfAbsent(messageId, System.currentTimeMillis());
Long timestamp = this.msgId2Timestamp.putIfAbsent(messageId, System.currentTimeMillis());
return timestamp != null;
}

Expand Down
Expand Up @@ -16,15 +16,15 @@ public static WxAccessToken fromJson(String json) {
}

public String getAccessToken() {
return accessToken;
return this.accessToken;
}

public void setAccessToken(String accessToken) {
this.accessToken = accessToken;
}

public int getExpiresIn() {
return expiresIn;
return this.expiresIn;
}

public void setExpiresIn(int expiresIn) {
Expand Down
Expand Up @@ -39,71 +39,71 @@ public String toString() {
}

public String getAppId() {
return appId;
return this.appId;
}

public void setAppId(String appId) {
this.appId = appId;
}

public String getCardId() {
return cardId;
return this.cardId;
}

public void setCardId(String cardId) {
this.cardId = cardId;
}

public String getCardType() {
return cardType;
return this.cardType;
}

public void setCardType(String cardType) {
this.cardType = cardType;
}

public String getLocationId() {
return locationId;
return this.locationId;
}

public void setLocationId(String locationId) {
this.locationId = locationId;
}

public String getCode() {
return code;
return this.code;
}

public void setCode(String code) {
this.code = code;
}

public String getOpenId() {
return openId;
return this.openId;
}

public void setOpenId(String openId) {
this.openId = openId;
}

public Long getTimestamp() {
return timestamp;
return this.timestamp;
}

public void setTimestamp(Long timestamp) {
this.timestamp = timestamp;
}

public String getNonceStr() {
return nonceStr;
return this.nonceStr;
}

public void setNonceStr(String nonceStr) {
this.nonceStr = nonceStr;
}

public String getSignature() {
return signature;
return this.signature;
}

public void setSignature(String signature) {
Expand Down
Expand Up @@ -19,39 +19,39 @@ public class WxJsapiSignature implements Serializable {
private String signature;

public String getSignature() {
return signature;
return this.signature;
}

public void setSignature(String signature) {
this.signature = signature;
}

public String getNoncestr() {
return noncestr;
return this.noncestr;
}

public void setNoncestr(String noncestr) {
this.noncestr = noncestr;
}

public long getTimestamp() {
return timestamp;
return this.timestamp;
}

public void setTimestamp(long timestamp) {
this.timestamp = timestamp;
}

public String getUrl() {
return url;
return this.url;
}

public void setUrl(String url) {
this.url = url;
}

public String getAppid() {
return appid;
return this.appid;
}

public void setAppid(String appid) {
Expand Down

0 comments on commit 9a26c75

Please sign in to comment.