修改WxCpMessage中agentId的数据类型, String-> Integer

This commit is contained in:
cty
2016-11-16 15:05:29 +08:00
parent 88f0eb83aa
commit 6d01fa5210
8 changed files with 294 additions and 298 deletions

1
.gitignore vendored
View File

@ -26,6 +26,7 @@ test-config.xml
/gradle/ /gradle/
*.bat *.bat
/gradlew /gradlew
**/build/
# OSX # OSX
# Icon must end with two \r # Icon must end with two \r

View File

@ -45,7 +45,7 @@ public interface WxCpConfigStorage {
String getCorpSecret(); String getCorpSecret();
String getAgentId(); Integer getAgentId();
String getToken(); String getToken();

View File

@ -19,7 +19,7 @@ public class WxCpInMemoryConfigStorage implements WxCpConfigStorage {
protected volatile String token; protected volatile String token;
protected volatile String accessToken; protected volatile String accessToken;
protected volatile String aesKey; protected volatile String aesKey;
protected volatile String agentId; protected volatile Integer agentId;
protected volatile long expiresTime; protected volatile long expiresTime;
protected volatile String oauth2redirectUri; protected volatile String oauth2redirectUri;
@ -146,11 +146,11 @@ public class WxCpInMemoryConfigStorage implements WxCpConfigStorage {
} }
@Override @Override
public String getAgentId() { public Integer getAgentId() {
return this.agentId; return this.agentId;
} }
public void setAgentId(String agentId) { public void setAgentId(Integer agentId) {
this.agentId = agentId; this.agentId = agentId;
} }

View File

@ -25,7 +25,7 @@ public class WxCpJedisConfigStorage implements WxCpConfigStorage {
private volatile String token; private volatile String token;
private volatile String aesKey; private volatile String aesKey;
private volatile String agentId; private volatile Integer agentId;
private volatile String oauth2redirectUri; private volatile String oauth2redirectUri;
@ -150,7 +150,7 @@ public class WxCpJedisConfigStorage implements WxCpConfigStorage {
} }
@Override @Override
public String getAgentId() { public Integer getAgentId() {
return this.agentId; return this.agentId;
} }
@ -230,7 +230,7 @@ public class WxCpJedisConfigStorage implements WxCpConfigStorage {
this.aesKey = aesKey; this.aesKey = aesKey;
} }
public void setAgentId(String agentId) { public void setAgentId(Integer agentId) {
this.agentId = agentId; this.agentId = agentId;
} }

View File

@ -160,7 +160,7 @@ public interface WxCpService {
* *
* @param menu * @param menu
* @throws WxErrorException * @throws WxErrorException
* @see #menuCreate(String, me.chanjar.weixin.common.bean.menu.WxMenu) * @see #menuCreate(Integer, WxMenu)
*/ */
void menuCreate(WxMenu menu) throws WxErrorException; void menuCreate(WxMenu menu) throws WxErrorException;
@ -177,7 +177,7 @@ public interface WxCpService {
* @throws WxErrorException * @throws WxErrorException
* @see #menuCreate(me.chanjar.weixin.common.bean.menu.WxMenu) * @see #menuCreate(me.chanjar.weixin.common.bean.menu.WxMenu)
*/ */
void menuCreate(String agentId, WxMenu menu) throws WxErrorException; void menuCreate(Integer agentId, WxMenu menu) throws WxErrorException;
/** /**
* <pre> * <pre>
@ -188,7 +188,7 @@ public interface WxCpService {
* </pre> * </pre>
* *
* @throws WxErrorException * @throws WxErrorException
* @see #menuDelete(String) * @see #menuDelete(Integer)
*/ */
void menuDelete() throws WxErrorException; void menuDelete() throws WxErrorException;
@ -204,7 +204,7 @@ public interface WxCpService {
* @throws WxErrorException * @throws WxErrorException
* @see #menuDelete() * @see #menuDelete()
*/ */
void menuDelete(String agentId) throws WxErrorException; void menuDelete(Integer agentId) throws WxErrorException;
/** /**
* <pre> * <pre>
@ -215,7 +215,7 @@ public interface WxCpService {
* </pre> * </pre>
* *
* @throws WxErrorException * @throws WxErrorException
* @see #menuGet(String) * @see #menuGet(Integer)
*/ */
WxMenu menuGet() throws WxErrorException; WxMenu menuGet() throws WxErrorException;
@ -231,7 +231,7 @@ public interface WxCpService {
* @throws WxErrorException * @throws WxErrorException
* @see #menuGet() * @see #menuGet()
*/ */
WxMenu menuGet(String agentId) throws WxErrorException; WxMenu menuGet(Integer agentId) throws WxErrorException;
/** /**
* <pre> * <pre>
@ -425,7 +425,7 @@ public interface WxCpService {
* *
* @param code * @param code
* @return [userid, deviceid] * @return [userid, deviceid]
* @see #oauth2getUserInfo(String, String) * @see #oauth2getUserInfo(Integer, String)
*/ */
String[] oauth2getUserInfo(String code) throws WxErrorException; String[] oauth2getUserInfo(String code) throws WxErrorException;
@ -443,7 +443,7 @@ public interface WxCpService {
* @return [userid, deviceid] * @return [userid, deviceid]
* @see #oauth2getUserInfo(String) * @see #oauth2getUserInfo(String)
*/ */
String[] oauth2getUserInfo(String agentId, String code) throws WxErrorException; String[] oauth2getUserInfo(Integer agentId, String code) throws WxErrorException;
/** /**

View File

@ -191,7 +191,7 @@ public class WxCpServiceImpl implements WxCpService {
} }
@Override @Override
public void menuCreate(String agentId, WxMenu menu) throws WxErrorException { public void menuCreate(Integer agentId, WxMenu menu) throws WxErrorException {
String url = "https://qyapi.weixin.qq.com/cgi-bin/menu/create?agentid=" String url = "https://qyapi.weixin.qq.com/cgi-bin/menu/create?agentid="
+ this.configStorage.getAgentId(); + this.configStorage.getAgentId();
post(url, menu.toJson()); post(url, menu.toJson());
@ -203,7 +203,7 @@ public class WxCpServiceImpl implements WxCpService {
} }
@Override @Override
public void menuDelete(String agentId) throws WxErrorException { public void menuDelete(Integer agentId) throws WxErrorException {
String url = "https://qyapi.weixin.qq.com/cgi-bin/menu/delete?agentid=" + agentId; String url = "https://qyapi.weixin.qq.com/cgi-bin/menu/delete?agentid=" + agentId;
get(url, null); get(url, null);
} }
@ -214,7 +214,7 @@ public class WxCpServiceImpl implements WxCpService {
} }
@Override @Override
public WxMenu menuGet(String agentId) throws WxErrorException { public WxMenu menuGet(Integer agentId) throws WxErrorException {
String url = "https://qyapi.weixin.qq.com/cgi-bin/menu/get?agentid=" + agentId; String url = "https://qyapi.weixin.qq.com/cgi-bin/menu/get?agentid=" + agentId;
try { try {
String resultContent = get(url, null); String resultContent = get(url, null);
@ -487,7 +487,7 @@ this.configStorage.getOauth2redirectUri(),
} }
@Override @Override
public String[] oauth2getUserInfo(String agentId, String code) throws WxErrorException { public String[] oauth2getUserInfo(Integer agentId, String code) throws WxErrorException {
String url = "https://qyapi.weixin.qq.com/cgi-bin/user/getuserinfo?" String url = "https://qyapi.weixin.qq.com/cgi-bin/user/getuserinfo?"
+ "code=" + code + "code=" + code
+ "&agentid=" + agentId; + "&agentid=" + agentId;

View File

@ -1,17 +1,12 @@
package me.chanjar.weixin.cp.bean; package me.chanjar.weixin.cp.bean;
import me.chanjar.weixin.cp.bean.messagebuilder.*;
import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder;
import java.io.Serializable; import java.io.Serializable;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import me.chanjar.weixin.cp.bean.messagebuilder.FileBuilder;
import me.chanjar.weixin.cp.bean.messagebuilder.ImageBuilder;
import me.chanjar.weixin.cp.bean.messagebuilder.NewsBuilder;
import me.chanjar.weixin.cp.bean.messagebuilder.TextBuilder;
import me.chanjar.weixin.cp.bean.messagebuilder.VideoBuilder;
import me.chanjar.weixin.cp.bean.messagebuilder.VoiceBuilder;
import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder;
/** /**
* 消息 * 消息
* *
@ -23,7 +18,7 @@ public class WxCpMessage implements Serializable {
private String toUser; private String toUser;
private String toParty; private String toParty;
private String toTag; private String toTag;
private String agentId; private Integer agentId;
private String msgType; private String msgType;
private String content; private String content;
private String mediaId; private String mediaId;
@ -101,11 +96,11 @@ public class WxCpMessage implements Serializable {
this.toTag = toTag; this.toTag = toTag;
} }
public String getAgentId() { public Integer getAgentId() {
return this.agentId; return this.agentId;
} }
public void setAgentId(String agentId) { public void setAgentId(Integer agentId) {
this.agentId = agentId; this.agentId = agentId;
} }

View File

@ -5,13 +5,13 @@ import me.chanjar.weixin.cp.bean.WxCpMessage;
public class BaseBuilder<T> { public class BaseBuilder<T> {
protected String msgType; protected String msgType;
protected String agentId; protected Integer agentId;
protected String toUser; protected String toUser;
protected String toParty; protected String toParty;
protected String toTag; protected String toTag;
protected String safe; protected String safe;
public T agentId(String agentId) { public T agentId(Integer agentId) {
this.agentId = agentId; this.agentId = agentId;
return (T) this; return (T) this;
} }