Merge branch 'develop'

This commit is contained in:
Daniel Qian 2015-04-16 14:18:54 +08:00
commit 6f3dfc7740
10 changed files with 40 additions and 13 deletions

View File

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

View File

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

View File

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

View File

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

View File

@ -7,6 +7,7 @@ import com.google.gson.JsonPrimitive;
import com.google.gson.internal.Streams;
import com.google.gson.reflect.TypeToken;
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.WxJsapiSignature;
import me.chanjar.weixin.common.bean.WxMenu;
@ -46,6 +47,7 @@ import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.StringReader;
import java.math.BigDecimal;
import java.security.NoSuchAlgorithmException;
import java.util.List;
import java.util.UUID;
@ -445,7 +447,7 @@ public class WxCpServiceImpl implements WxCpService {
@Override
public String[] oauth2getUserInfo(String code) throws WxErrorException {
return oauth2getUserInfo(code, wxCpConfigStorage.getAgentId());
return oauth2getUserInfo(wxCpConfigStorage.getAgentId(), code);
}
@Override
@ -626,4 +628,12 @@ public class WxCpServiceImpl implements WxCpService {
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());
}
}

View File

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

View File

@ -19,17 +19,17 @@ import java.lang.reflect.Type;
*/
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();
o.addProperty("tagid", group.getId());
o.addProperty("tagname", group.getName());
o.addProperty("tagid", tag.getId());
o.addProperty("tagname", tag.getName());
return o;
}
public WxCpTag deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context)
throws JsonParseException {
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"));
}
}

View File

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

View File

@ -387,6 +387,18 @@ public interface WxMpService {
*/
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>
* 用code换取oauth2的access token

View File

@ -363,9 +363,14 @@ public class WxMpServiceImpl implements WxMpService {
@Override
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?" ;
url += "appid=" + wxMpConfigStorage.getAppId();
url += "&redirect_uri=" + URIUtil.encodeURIComponent(wxMpConfigStorage.getOauth2redirectUri());
url += "&redirect_uri=" + URIUtil.encodeURIComponent(redirectURI);
url += "&response_type=code";
url += "&scope=" + scope;
if (state != null) {