Skip to content

Commit a8f5d07

Browse files
committed
整理及重构
1 parent 67795a0 commit a8f5d07

File tree

212 files changed

+1698
-3456
lines changed

Some content is hidden

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

212 files changed

+1698
-3456
lines changed
Lines changed: 62 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,11 @@
44
xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
55
<modelVersion>4.0.0</modelVersion>
66
<groupId>me.chanjar</groupId>
7-
<artifactId>weixin-java-enterprise-tools</artifactId>
7+
<artifactId>weixin-java-parent</artifactId>
88
<version>1.0.3-SNAPSHOT</version>
9-
<name>WeiXin Java Enterprise Tools</name>
10-
<description>微信企业号Java SDK</description>
9+
<packaging>pom</packaging>
10+
<name>WeiXin Java Tools - Parent</name>
11+
<description>微信公众号、企业号上级POM</description>
1112
<url>https://github.com/chanjarster/weixin-java-tools</url>
1213

1314
<licenses>
@@ -30,19 +31,20 @@
3031
<url>https://github.com/chanjarster/weixin-java-tools</url>
3132
</scm>
3233

34+
<modules>
35+
<module>weixin-java-common</module>
36+
<module>weixin-java-cp</module>
37+
<module>weixin-java-mp</module>
38+
</modules>
39+
3340
<properties>
3441
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
3542
<downloadJavadocs>true</downloadJavadocs>
3643
<downloadSources>true</downloadSources>
3744
<httpclient.version>4.3.5</httpclient.version>
3845
</properties>
46+
3947
<dependencies>
40-
<dependency>
41-
<groupId>junit</groupId>
42-
<artifactId>junit</artifactId>
43-
<version>4.11</version>
44-
<scope>test</scope>
45-
</dependency>
4648
<dependency>
4749
<groupId>org.apache.httpcomponents</groupId>
4850
<artifactId>fluent-hc</artifactId>
@@ -63,34 +65,11 @@
6365
<artifactId>jaxb-impl</artifactId>
6466
<version>2.2.7</version>
6567
</dependency>
66-
<dependency>
67-
<groupId>org.apache.oltu.oauth2</groupId>
68-
<artifactId>org.apache.oltu.oauth2.client</artifactId>
69-
<version>1.0.0</version>
70-
</dependency>
7168
<dependency>
7269
<groupId>com.google.code.gson</groupId>
7370
<artifactId>gson</artifactId>
7471
<version>2.2.2</version>
7572
</dependency>
76-
<dependency>
77-
<groupId>org.testng</groupId>
78-
<artifactId>testng</artifactId>
79-
<version>6.8.7</version>
80-
<scope>test</scope>
81-
</dependency>
82-
<dependency>
83-
<groupId>org.mockito</groupId>
84-
<artifactId>mockito-all</artifactId>
85-
<version>1.9.5</version>
86-
<scope>test</scope>
87-
</dependency>
88-
<dependency>
89-
<groupId>com.google.inject</groupId>
90-
<artifactId>guice</artifactId>
91-
<version>3.0</version>
92-
<scope>test</scope>
93-
</dependency>
9473
<dependency>
9574
<groupId>org.apache.commons</groupId>
9675
<artifactId>commons-lang3</artifactId>
@@ -106,20 +85,49 @@
10685
<artifactId>commons-io</artifactId>
10786
<version>2.4</version>
10887
</dependency>
109-
<dependency>
110-
<groupId>org.eclipse.jetty</groupId>
111-
<artifactId>jetty-server</artifactId>
112-
<version>9.3.0.M0</version>
113-
<scope>test</scope>
114-
</dependency>
115-
<dependency>
116-
<groupId>org.eclipse.jetty</groupId>
117-
<artifactId>jetty-servlet</artifactId>
118-
<version>9.3.0.M0</version>
119-
<scope>test</scope>
120-
</dependency>
12188
</dependencies>
12289

90+
<dependencyManagement>
91+
<dependencies>
92+
<dependency>
93+
<groupId>junit</groupId>
94+
<artifactId>junit</artifactId>
95+
<version>4.11</version>
96+
<scope>test</scope>
97+
</dependency>
98+
<dependency>
99+
<groupId>com.google.inject</groupId>
100+
<artifactId>guice</artifactId>
101+
<version>3.0</version>
102+
<scope>test</scope>
103+
</dependency>
104+
<dependency>
105+
<groupId>org.testng</groupId>
106+
<artifactId>testng</artifactId>
107+
<version>6.8.7</version>
108+
<scope>test</scope>
109+
</dependency>
110+
<dependency>
111+
<groupId>org.mockito</groupId>
112+
<artifactId>mockito-all</artifactId>
113+
<version>1.9.5</version>
114+
<scope>test</scope>
115+
</dependency>
116+
<dependency>
117+
<groupId>org.eclipse.jetty</groupId>
118+
<artifactId>jetty-server</artifactId>
119+
<version>9.3.0.M0</version>
120+
<scope>test</scope>
121+
</dependency>
122+
<dependency>
123+
<groupId>org.eclipse.jetty</groupId>
124+
<artifactId>jetty-servlet</artifactId>
125+
<version>9.3.0.M0</version>
126+
<scope>test</scope>
127+
</dependency>
128+
</dependencies>
129+
</dependencyManagement>
130+
123131
<distributionManagement>
124132
<snapshotRepository>
125133
<id>ossrh</id>
@@ -186,17 +194,17 @@
186194
</profiles>
187195

188196
<build>
197+
<pluginManagement>
198+
<plugins>
199+
<plugin>
200+
<groupId>org.apache.maven.plugins</groupId>
201+
<artifactId>maven-surefire-plugin</artifactId>
202+
<version>2.17</version>
203+
</plugin>
204+
</plugins>
205+
</pluginManagement>
206+
189207
<plugins>
190-
<plugin>
191-
<groupId>org.apache.maven.plugins</groupId>
192-
<artifactId>maven-surefire-plugin</artifactId>
193-
<version>2.17</version>
194-
<configuration>
195-
<suiteXmlFiles>
196-
<suiteXmlFile>src/test/resources/testng.xml</suiteXmlFile>
197-
</suiteXmlFiles>
198-
</configuration>
199-
</plugin>
200208
<plugin>
201209
<groupId>org.sonatype.plugins</groupId>
202210
<artifactId>nexus-staging-maven-plugin</artifactId>

weixin-java-common/pom.xml

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
<?xml version="1.0"?>
2+
<project
3+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
4+
xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
5+
<modelVersion>4.0.0</modelVersion>
6+
<parent>
7+
<groupId>me.chanjar</groupId>
8+
<artifactId>weixin-java-parent</artifactId>
9+
<version>1.0.3-SNAPSHOT</version>
10+
</parent>
11+
12+
<artifactId>weixin-java-common</artifactId>
13+
<name>WeiXin Java Tools - Common</name>
14+
<description>微信公众号、企业号Java SDK Common</description>
15+
16+
<dependencies>
17+
<dependency>
18+
<groupId>junit</groupId>
19+
<artifactId>junit</artifactId>
20+
<scope>test</scope>
21+
</dependency>
22+
<dependency>
23+
<groupId>org.testng</groupId>
24+
<artifactId>testng</artifactId>
25+
<version>6.8.7</version>
26+
<scope>test</scope>
27+
</dependency>
28+
<dependency>
29+
<groupId>org.mockito</groupId>
30+
<artifactId>mockito-all</artifactId>
31+
<version>1.9.5</version>
32+
<scope>test</scope>
33+
</dependency>
34+
<dependency>
35+
<groupId>com.google.inject</groupId>
36+
<artifactId>guice</artifactId>
37+
<version>3.0</version>
38+
<scope>test</scope>
39+
</dependency>
40+
<dependency>
41+
<groupId>org.eclipse.jetty</groupId>
42+
<artifactId>jetty-server</artifactId>
43+
<version>9.3.0.M0</version>
44+
<scope>test</scope>
45+
</dependency>
46+
<dependency>
47+
<groupId>org.eclipse.jetty</groupId>
48+
<artifactId>jetty-servlet</artifactId>
49+
<version>9.3.0.M0</version>
50+
<scope>test</scope>
51+
</dependency>
52+
</dependencies>
53+
54+
<build>
55+
<plugins>
56+
<plugin>
57+
<groupId>org.apache.maven.plugins</groupId>
58+
<artifactId>maven-surefire-plugin</artifactId>
59+
<configuration>
60+
<suiteXmlFiles>
61+
<suiteXmlFile>src/test/resources/testng.xml</suiteXmlFile>
62+
</suiteXmlFiles>
63+
</configuration>
64+
</plugin>
65+
</plugins>
66+
</build>
67+
68+
</project>

weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/WxAccessToken.java renamed to weixin-java-common/src/main/java/me/chanjar/weixin/common/bean/WxAccessToken.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
package me.chanjar.weixin.mp.bean;
1+
package me.chanjar.weixin.common.bean;
22

3-
import me.chanjar.weixin.mp.util.json.WxGsonBuilder;
3+
import me.chanjar.weixin.common.util.json.WxGsonBuilder;
44

55
public class WxAccessToken {
66

77
private String accessToken;
88

9-
private int expiresIn;
9+
private int expiresIn = -1;
1010

1111
public String getAccessToken() {
1212
return accessToken;

weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/WxMenu.java renamed to weixin-java-common/src/main/java/me/chanjar/weixin/common/bean/WxMenu.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
1-
package me.chanjar.weixin.mp.bean;
1+
package me.chanjar.weixin.common.bean;
22

33
import java.io.InputStream;
44
import java.io.InputStreamReader;
55
import java.util.ArrayList;
66
import java.util.List;
77

8-
import me.chanjar.weixin.mp.util.json.WxGsonBuilder;
8+
import me.chanjar.weixin.common.util.json.WxGsonBuilder;
99

1010
/**
11-
* 公众号菜单
12-
* @author chanjarster
11+
* 企业号菜单
12+
* @author Daniel Qian
1313
*
1414
*/
1515
public class WxMenu {

weixin-java-enterprise/src/main/java/me/chanjar/weixin/common/bean/result/WxError.java renamed to weixin-java-common/src/main/java/me/chanjar/weixin/common/bean/result/WxError.java

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package me.chanjar.weixin.common.bean.result;
22

3-
import me.chanjar.weixin.enterprise.util.json.WxCpGsonBuilder;
3+
import me.chanjar.weixin.common.util.json.WxGsonBuilder;
44

55
/**
66
* 微信错误码说明
@@ -32,9 +32,16 @@ public void setErrorMsg(String errorMsg) {
3232
this.errorMsg = errorMsg;
3333
}
3434

35+
public String getJson() {
36+
return json;
37+
}
38+
39+
public void setJson(String json) {
40+
this.json = json;
41+
}
42+
3543
public static WxError fromJson(String json) {
36-
WxError error = WxCpGsonBuilder.create().fromJson(json, WxError.class);
37-
error.json = json;
44+
WxError error = WxGsonBuilder.create().fromJson(json, WxError.class);
3845
return error;
3946
}
4047

weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/result/WxMediaUploadResult.java renamed to weixin-java-common/src/main/java/me/chanjar/weixin/common/bean/result/WxMediaUploadResult.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
package me.chanjar.weixin.mp.bean.result;
1+
package me.chanjar.weixin.common.bean.result;
22

3-
import me.chanjar.weixin.mp.util.json.WxGsonBuilder;
3+
import me.chanjar.weixin.common.util.json.WxGsonBuilder;
44

55
public class WxMediaUploadResult {
66

@@ -33,10 +33,6 @@ public void setCreatedAt(long createdAt) {
3333
this.createdAt = createdAt;
3434
}
3535

36-
public static WxMediaUploadResult fromJson(String json) {
37-
return WxGsonBuilder.create().fromJson(json, WxMediaUploadResult.class);
38-
}
39-
4036
public String getThumbMediaId() {
4137
return thumbMediaId;
4238
}
@@ -45,6 +41,10 @@ public void setThumbMediaId(String thumbMediaId) {
4541
this.thumbMediaId = thumbMediaId;
4642
}
4743

44+
public static WxMediaUploadResult fromJson(String json) {
45+
return WxGsonBuilder.create().fromJson(json, WxMediaUploadResult.class);
46+
}
47+
4848
@Override
4949
public String toString() {
5050
return "WxUploadResult [type=" + type + ", media_id=" + mediaId + ", thumb_media_id=" + thumbMediaId

weixin-java-enterprise/src/main/java/me/chanjar/weixin/enterprise/exception/WxErrorException.java renamed to weixin-java-common/src/main/java/me/chanjar/weixin/common/exception/WxErrorException.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package me.chanjar.weixin.enterprise.exception;
1+
package me.chanjar.weixin.common.exception;
22

33
import me.chanjar.weixin.common.bean.result.WxError;
44

weixin-java-enterprise/src/main/java/me/chanjar/weixin/enterprise/util/crypto/ByteGroup.java renamed to weixin-java-common/src/main/java/me/chanjar/weixin/common/util/crypto/ByteGroup.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,26 @@
1-
package me.chanjar.weixin.enterprise.util.crypto;
1+
package me.chanjar.weixin.common.util.crypto;
22

33
import java.util.ArrayList;
44

5-
class ByteGroup {
5+
public class ByteGroup {
66
ArrayList<Byte> byteContainer = new ArrayList<Byte>();
77

8-
byte[] toBytes() {
8+
public byte[] toBytes() {
99
byte[] bytes = new byte[byteContainer.size()];
1010
for (int i = 0; i < byteContainer.size(); i++) {
1111
bytes[i] = byteContainer.get(i);
1212
}
1313
return bytes;
1414
}
1515

16-
ByteGroup addBytes(byte[] bytes) {
16+
public ByteGroup addBytes(byte[] bytes) {
1717
for (byte b : bytes) {
1818
byteContainer.add(b);
1919
}
2020
return this;
2121
}
2222

23-
int size() {
23+
public int size() {
2424
return byteContainer.size();
2525
}
2626
}

0 commit comments

Comments
 (0)