Browse Source

Merge branch 'develop'

master
Daniel Qian 9 years ago
parent
commit
6f3dfc7740
10 changed files with 40 additions and 13 deletions
  1. +2
    -2
      README.md
  2. +1
    -1
      pom.xml
  3. +1
    -1
      weixin-java-common/pom.xml
  4. +1
    -1
      weixin-java-cp/pom.xml
  5. +11
    -1
      weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpServiceImpl.java
  6. +1
    -1
      weixin-java-cp/src/main/java/me/chanjar/weixin/cp/util/json/WxCpMessageGsonAdapter.java
  7. +4
    -4
      weixin-java-cp/src/main/java/me/chanjar/weixin/cp/util/json/WxCpTagGsonAdapter.java
  8. +1
    -1
      weixin-java-mp/pom.xml
  9. +12
    -0
      weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpService.java
  10. +6
    -1
      weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpServiceImpl.java

+ 2
- 2
README.md View File

@@ -17,7 +17,7 @@ weixin-java-tools
<dependency> <dependency>
<groupId>me.chanjar</groupId> <groupId>me.chanjar</groupId>
<artifactId>weixin-java-mp</artifactId> <artifactId>weixin-java-mp</artifactId>
<version>1.1.3</version>
<version>1.1.4</version>
</dependency> </dependency>
``` ```


@@ -27,7 +27,7 @@ weixin-java-tools
<dependency> <dependency>
<groupId>me.chanjar</groupId> <groupId>me.chanjar</groupId>
<artifactId>weixin-java-cp</artifactId> <artifactId>weixin-java-cp</artifactId>
<version>1.1.3</version>
<version>1.1.4</version>
</dependency> </dependency>
``` ```




+ 1
- 1
pom.xml View File

@@ -5,7 +5,7 @@
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<groupId>me.chanjar</groupId> <groupId>me.chanjar</groupId>
<artifactId>weixin-java-parent</artifactId> <artifactId>weixin-java-parent</artifactId>
<version>1.1.3</version>
<version>1.1.4</version>
<packaging>pom</packaging> <packaging>pom</packaging>
<name>WeiXin Java Tools - Parent</name> <name>WeiXin Java Tools - Parent</name>
<description>微信公众号、企业号上级POM</description> <description>微信公众号、企业号上级POM</description>


+ 1
- 1
weixin-java-common/pom.xml View File

@@ -6,7 +6,7 @@
<parent> <parent>
<groupId>me.chanjar</groupId> <groupId>me.chanjar</groupId>
<artifactId>weixin-java-parent</artifactId> <artifactId>weixin-java-parent</artifactId>
<version>1.1.3</version>
<version>1.1.4</version>
</parent> </parent>


<artifactId>weixin-java-common</artifactId> <artifactId>weixin-java-common</artifactId>


+ 1
- 1
weixin-java-cp/pom.xml View File

@@ -6,7 +6,7 @@
<parent> <parent>
<groupId>me.chanjar</groupId> <groupId>me.chanjar</groupId>
<artifactId>weixin-java-parent</artifactId> <artifactId>weixin-java-parent</artifactId>
<version>1.1.3</version>
<version>1.1.4</version>
</parent> </parent>


<artifactId>weixin-java-cp</artifactId> <artifactId>weixin-java-cp</artifactId>


+ 11
- 1
weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpServiceImpl.java View File

@@ -7,6 +7,7 @@ import com.google.gson.JsonPrimitive;
import com.google.gson.internal.Streams; import com.google.gson.internal.Streams;
import com.google.gson.reflect.TypeToken; import com.google.gson.reflect.TypeToken;
import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonReader;
import com.sun.media.sound.SoftTuning;
import me.chanjar.weixin.common.bean.WxAccessToken; import me.chanjar.weixin.common.bean.WxAccessToken;
import me.chanjar.weixin.common.bean.WxJsapiSignature; import me.chanjar.weixin.common.bean.WxJsapiSignature;
import me.chanjar.weixin.common.bean.WxMenu; import me.chanjar.weixin.common.bean.WxMenu;
@@ -46,6 +47,7 @@ import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.io.StringReader; import java.io.StringReader;
import java.math.BigDecimal;
import java.security.NoSuchAlgorithmException; import java.security.NoSuchAlgorithmException;
import java.util.List; import java.util.List;
import java.util.UUID; import java.util.UUID;
@@ -445,7 +447,7 @@ public class WxCpServiceImpl implements WxCpService {


@Override @Override
public String[] oauth2getUserInfo(String code) throws WxErrorException { public String[] oauth2getUserInfo(String code) throws WxErrorException {
return oauth2getUserInfo(code, wxCpConfigStorage.getAgentId());
return oauth2getUserInfo(wxCpConfigStorage.getAgentId(), code);
} }


@Override @Override
@@ -626,4 +628,12 @@ public class WxCpServiceImpl implements WxCpService {
this.sessionManager = sessionManager; this.sessionManager = sessionManager;
} }


public static void main(String[] args) {
Float a = 3.1f;
System.out.println(3.1d);
System.out.println(new BigDecimal(3.1d));
System.out.println(new BigDecimal(a));
System.out.println(a.toString());
System.out.println(a.doubleValue());
}
} }

+ 1
- 1
weixin-java-cp/src/main/java/me/chanjar/weixin/cp/util/json/WxCpMessageGsonAdapter.java View File

@@ -34,7 +34,7 @@ public class WxCpMessageGsonAdapter implements JsonSerializer<WxCpMessage> {
messageJson.addProperty("toparty", message.getToParty()); messageJson.addProperty("toparty", message.getToParty());
} }
if (StringUtils.isNotBlank(message.getToTag())) { if (StringUtils.isNotBlank(message.getToTag())) {
messageJson.addProperty("totag", message.getToUser());
messageJson.addProperty("totag", message.getToTag());
} }
if (WxConsts.CUSTOM_MSG_TEXT.equals(message.getMsgType())) { if (WxConsts.CUSTOM_MSG_TEXT.equals(message.getMsgType())) {
JsonObject text = new JsonObject(); JsonObject text = new JsonObject();


+ 4
- 4
weixin-java-cp/src/main/java/me/chanjar/weixin/cp/util/json/WxCpTagGsonAdapter.java View File

@@ -19,17 +19,17 @@ import java.lang.reflect.Type;
*/ */
public class WxCpTagGsonAdapter implements JsonSerializer<WxCpTag>, JsonDeserializer<WxCpTag> { public class WxCpTagGsonAdapter implements JsonSerializer<WxCpTag>, JsonDeserializer<WxCpTag> {


public JsonElement serialize(WxCpTag group, Type typeOfSrc, JsonSerializationContext context) {
public JsonElement serialize(WxCpTag tag, Type typeOfSrc, JsonSerializationContext context) {
JsonObject o = new JsonObject(); JsonObject o = new JsonObject();
o.addProperty("tagid", group.getId());
o.addProperty("tagname", group.getName());
o.addProperty("tagid", tag.getId());
o.addProperty("tagname", tag.getName());
return o; return o;
} }


public WxCpTag deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) public WxCpTag deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context)
throws JsonParseException { throws JsonParseException {
JsonObject jsonObject = json.getAsJsonObject(); JsonObject jsonObject = json.getAsJsonObject();
return new WxCpTag(GsonHelper.getString(jsonObject, "tagid"), GsonHelper.getString(jsonObject, "name"));
return new WxCpTag(GsonHelper.getString(jsonObject, "tagid"), GsonHelper.getString(jsonObject, "tagname"));
} }


} }

+ 1
- 1
weixin-java-mp/pom.xml View File

@@ -6,7 +6,7 @@
<parent> <parent>
<groupId>me.chanjar</groupId> <groupId>me.chanjar</groupId>
<artifactId>weixin-java-parent</artifactId> <artifactId>weixin-java-parent</artifactId>
<version>1.1.3</version>
<version>1.1.4</version>
</parent> </parent>
<artifactId>weixin-java-mp</artifactId> <artifactId>weixin-java-mp</artifactId>
<name>WeiXin Java Tools - MP</name> <name>WeiXin Java Tools - MP</name>


+ 12
- 0
weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpService.java View File

@@ -387,6 +387,18 @@ public interface WxMpService {
*/ */
public String oauth2buildAuthorizationUrl(String scope, String state); public String oauth2buildAuthorizationUrl(String scope, String state);


/**
* <pre>
* 构造oauth2授权的url连接
* 详情请见: http://mp.weixin.qq.com/wiki/index.php?title=网页授权获取用户基本信息
* </pre>
* @param redirectURI
* 用户授权完成后的重定向链接,无需urlencode, 方法内会进行encode
* @param scope
* @param state
* @return code
*/
public String oauth2buildAuthorizationUrl(String redirectURI, String scope, String state);
/** /**
* <pre> * <pre>
* 用code换取oauth2的access token * 用code换取oauth2的access token


+ 6
- 1
weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpServiceImpl.java View File

@@ -363,9 +363,14 @@ public class WxMpServiceImpl implements WxMpService {


@Override @Override
public String oauth2buildAuthorizationUrl(String scope, String state) { public String oauth2buildAuthorizationUrl(String scope, String state) {
return this.oauth2buildAuthorizationUrl(wxMpConfigStorage.getOauth2redirectUri(), scope, state);
}

@Override
public String oauth2buildAuthorizationUrl(String redirectURI, String scope, String state) {
String url = "https://open.weixin.qq.com/connect/oauth2/authorize?" ; String url = "https://open.weixin.qq.com/connect/oauth2/authorize?" ;
url += "appid=" + wxMpConfigStorage.getAppId(); url += "appid=" + wxMpConfigStorage.getAppId();
url += "&redirect_uri=" + URIUtil.encodeURIComponent(wxMpConfigStorage.getOauth2redirectUri());
url += "&redirect_uri=" + URIUtil.encodeURIComponent(redirectURI);
url += "&response_type=code"; url += "&response_type=code";
url += "&scope=" + scope; url += "&scope=" + scope;
if (state != null) { if (state != null) {


Loading…
Cancel
Save