diff --git a/spring-boot-starters/wx-java-cp-multi-spring-boot-starter/src/main/java/com/binarywang/spring/starter/wxjava/cp/configuration/services/AbstractWxCpConfiguration.java b/spring-boot-starters/wx-java-cp-multi-spring-boot-starter/src/main/java/com/binarywang/spring/starter/wxjava/cp/configuration/services/AbstractWxCpConfiguration.java index a10bdf9bed..a793a8501f 100644 --- a/spring-boot-starters/wx-java-cp-multi-spring-boot-starter/src/main/java/com/binarywang/spring/starter/wxjava/cp/configuration/services/AbstractWxCpConfiguration.java +++ b/spring-boot-starters/wx-java-cp-multi-spring-boot-starter/src/main/java/com/binarywang/spring/starter/wxjava/cp/configuration/services/AbstractWxCpConfiguration.java @@ -125,7 +125,7 @@ private WxCpService wxCpService(WxCpConfigStorage wxCpConfigStorage, WxCpMultiPr private void configCorp(WxCpDefaultConfigImpl config, WxCpSingleProperties wxCpSingleProperties) { String corpId = wxCpSingleProperties.getCorpId(); String corpSecret = wxCpSingleProperties.getCorpSecret(); - Integer agentId = wxCpSingleProperties.getAgentId(); + Long agentId = wxCpSingleProperties.getAgentId(); String token = wxCpSingleProperties.getToken(); String aesKey = wxCpSingleProperties.getAesKey(); // 企业微信,私钥,会话存档路径 diff --git a/spring-boot-starters/wx-java-cp-multi-spring-boot-starter/src/main/java/com/binarywang/spring/starter/wxjava/cp/properties/WxCpSingleProperties.java b/spring-boot-starters/wx-java-cp-multi-spring-boot-starter/src/main/java/com/binarywang/spring/starter/wxjava/cp/properties/WxCpSingleProperties.java index fcfa654a15..740f5a2a3b 100644 --- a/spring-boot-starters/wx-java-cp-multi-spring-boot-starter/src/main/java/com/binarywang/spring/starter/wxjava/cp/properties/WxCpSingleProperties.java +++ b/spring-boot-starters/wx-java-cp-multi-spring-boot-starter/src/main/java/com/binarywang/spring/starter/wxjava/cp/properties/WxCpSingleProperties.java @@ -52,7 +52,7 @@ public class WxCpSingleProperties implements Serializable { *

使用自建应用 Secret 时,需要填写对应应用的 AgentId。

*

使用通讯录同步 Secret 时,无需填写此字段。

*/ - private Integer agentId; + private Long agentId; /** * 微信企业号应用 EncodingAESKey */ diff --git a/spring-boot-starters/wx-java-cp-spring-boot-starter/src/main/java/com/binarywang/spring/starter/wxjava/cp/properties/WxCpProperties.java b/spring-boot-starters/wx-java-cp-spring-boot-starter/src/main/java/com/binarywang/spring/starter/wxjava/cp/properties/WxCpProperties.java index c93a7e187f..63e730d1b4 100644 --- a/spring-boot-starters/wx-java-cp-spring-boot-starter/src/main/java/com/binarywang/spring/starter/wxjava/cp/properties/WxCpProperties.java +++ b/spring-boot-starters/wx-java-cp-spring-boot-starter/src/main/java/com/binarywang/spring/starter/wxjava/cp/properties/WxCpProperties.java @@ -34,7 +34,7 @@ public class WxCpProperties { /** * 微信企业号应用 ID */ - private Integer agentId; + private Long agentId; /** * 微信企业号应用 EncodingAESKey */ diff --git a/spring-boot-starters/wx-java-cp-spring-boot-starter/src/main/java/com/binarywang/spring/starter/wxjava/cp/storage/AbstractWxCpConfigStorageConfiguration.java b/spring-boot-starters/wx-java-cp-spring-boot-starter/src/main/java/com/binarywang/spring/starter/wxjava/cp/storage/AbstractWxCpConfigStorageConfiguration.java index 2b1d8c13c5..70f620a58d 100644 --- a/spring-boot-starters/wx-java-cp-spring-boot-starter/src/main/java/com/binarywang/spring/starter/wxjava/cp/storage/AbstractWxCpConfigStorageConfiguration.java +++ b/spring-boot-starters/wx-java-cp-spring-boot-starter/src/main/java/com/binarywang/spring/starter/wxjava/cp/storage/AbstractWxCpConfigStorageConfiguration.java @@ -15,7 +15,7 @@ public abstract class AbstractWxCpConfigStorageConfiguration { protected WxCpDefaultConfigImpl config(WxCpDefaultConfigImpl config, WxCpProperties properties) { String corpId = properties.getCorpId(); String corpSecret = properties.getCorpSecret(); - Integer agentId = properties.getAgentId(); + Long agentId = properties.getAgentId(); String token = properties.getToken(); String aesKey = properties.getAesKey(); // 企业微信,私钥,会话存档路径 diff --git a/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/DataUtils.java b/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/DataUtils.java index 095363cf8d..2e9f5d4c7b 100644 --- a/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/DataUtils.java +++ b/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/DataUtils.java @@ -17,8 +17,10 @@ public class DataUtils { */ public static E handleDataWithSecret(E data) { E dataForLog = data; - if (data instanceof String && StringUtils.contains((String) data, "secret=")) { - dataForLog = (E) RegExUtils.replaceAll((String) data, "(^|[?&])secret=[^&]*", "$1secret=******"); + if (data instanceof String) { + String stringData = (String) data; + stringData = RegExUtils.replaceAll(stringData, "(^|[?&])secret=[^&]*", "$1secret=******"); + dataForLog = (E) RegExUtils.replaceAll(stringData, "(\\\"openid\\\"\\s*:\\s*\\\")[^\\\"]*(\\\")", "$1******$2"); } return dataForLog; } diff --git a/weixin-java-common/src/test/java/me/chanjar/weixin/common/util/DataUtilsTest.java b/weixin-java-common/src/test/java/me/chanjar/weixin/common/util/DataUtilsTest.java index 1bda61a237..c5088e78c9 100644 --- a/weixin-java-common/src/test/java/me/chanjar/weixin/common/util/DataUtilsTest.java +++ b/weixin-java-common/src/test/java/me/chanjar/weixin/common/util/DataUtilsTest.java @@ -47,4 +47,14 @@ public void testHandleDataWithSecretEncodedValue() { assertFalse(s.contains("%2F"), "Encoded characters in the secret must be masked too"); assertTrue(s.contains("&secret=******&"), "Secret should be replaced with asterisks"); } + + @Test + public void testHandleDataWithOpenidInJson() { + String data = "{\"code\":\"phone-code\",\"openid\":\"user-openid\"}"; + + String result = DataUtils.handleDataWithSecret(data); + + assertFalse(result.contains("user-openid")); + assertTrue(result.contains("\"openid\":\"******\"")); + } } diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpAgentService.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpAgentService.java index 05f06f1da9..7302a88f0c 100644 --- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpAgentService.java +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpAgentService.java @@ -27,7 +27,7 @@ public interface WxCpAgentService { * @return wx cp agent * @throws WxErrorException the wx error exception */ - WxCpAgent get(Integer agentId) throws WxErrorException; + WxCpAgent get(Long agentId) throws WxErrorException; /** *
@@ -65,6 +65,6 @@ public interface WxCpAgentService {
    * @return admin list
    * @throws WxErrorException the wx error exception
    */
-  WxCpTpAdmin getAdminList(Integer agentId) throws WxErrorException;
+  WxCpTpAdmin getAdminList(Long agentId) throws WxErrorException;
 
 }
diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpCorpGroupService.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpCorpGroupService.java
index 69aea4bca7..16882669b7 100644
--- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpCorpGroupService.java
+++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpCorpGroupService.java
@@ -23,5 +23,5 @@ public interface WxCpCorpGroupService {
    * @return the list
    * @throws WxErrorException the wx error exception
    */
-  List listAppShareInfo(Integer agentId, Integer businessType, String corpId, Integer limit, String cursor) throws WxErrorException;
+  List listAppShareInfo(Long agentId, Integer businessType, String corpId, Integer limit, String cursor) throws WxErrorException;
 }
diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpMenuService.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpMenuService.java
index 07f300dd14..bfa2c1c938 100644
--- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpMenuService.java
+++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpMenuService.java
@@ -40,7 +40,7 @@ public interface WxCpMenuService {
    * @throws WxErrorException the wx error exception
    * @see #create(me.chanjar.weixin.common.bean.menu.WxMenu) #create(me.chanjar.weixin.common.bean.menu.WxMenu)
    */
-  void create(Integer agentId, WxMenu menu) throws WxErrorException;
+  void create(Long agentId, WxMenu menu) throws WxErrorException;
 
   /**
    * 
@@ -67,7 +67,7 @@ public interface WxCpMenuService {
    * @throws WxErrorException the wx error exception
    * @see #delete() #delete()
    */
-  void delete(Integer agentId) throws WxErrorException;
+  void delete(Long agentId) throws WxErrorException;
 
   /**
    * 
@@ -96,5 +96,5 @@ public interface WxCpMenuService {
    * @throws WxErrorException the wx error exception
    * @see #get() #get()
    */
-  WxMenu get(Integer agentId) throws WxErrorException;
+  WxMenu get(Long agentId) throws WxErrorException;
 }
diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpOAuth2Service.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpOAuth2Service.java
index 1824196720..695534ba73 100644
--- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpOAuth2Service.java
+++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpOAuth2Service.java
@@ -85,7 +85,7 @@ public interface WxCpOAuth2Service {
    * @throws WxErrorException 异常
    * @see #getUserInfo(String) #getUserInfo(String)
    */
-  WxCpOauth2UserInfo getUserInfo(Integer agentId, String code) throws WxErrorException;
+  WxCpOauth2UserInfo getUserInfo(Long agentId, String code) throws WxErrorException;
 
   /**
    * 获取家校访问用户身份
diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpAgentServiceImpl.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpAgentServiceImpl.java
index cc08d33bb1..6f2ade2e49 100644
--- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpAgentServiceImpl.java
+++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpAgentServiceImpl.java
@@ -34,7 +34,7 @@ public class WxCpAgentServiceImpl implements WxCpAgentService {
   private final WxCpService mainService;
 
   @Override
-  public WxCpAgent get(Integer agentId) throws WxErrorException {
+  public WxCpAgent get(Long agentId) throws WxErrorException {
     if (agentId == null) {
       throw new IllegalArgumentException("缺少agentid参数");
     }
@@ -67,7 +67,7 @@ public List list() throws WxErrorException {
   }
 
   @Override
-  public WxCpTpAdmin getAdminList(Integer agentId) throws WxErrorException {
+  public WxCpTpAdmin getAdminList(Long agentId) throws WxErrorException {
     if (agentId == null) {
       throw new IllegalArgumentException("缺少agentid参数");
     }
diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpCorpGroupServiceImpl.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpCorpGroupServiceImpl.java
index e3dc1cbe1c..73d11cc15d 100644
--- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpCorpGroupServiceImpl.java
+++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpCorpGroupServiceImpl.java
@@ -25,7 +25,7 @@ public class WxCpCorpGroupServiceImpl implements WxCpCorpGroupService {
   private final WxCpService cpService;
 
   @Override
-  public List listAppShareInfo(Integer agentId, Integer businessType, String corpId,
+  public List listAppShareInfo(Long agentId, Integer businessType, String corpId,
                                                   Integer limit, String cursor) throws WxErrorException {
     final String url = this.cpService.getWxCpConfigStorage().getApiUrl(LIST_SHARE_APP_INFO);
     JsonObject jsonObject = new JsonObject();
diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpMenuServiceImpl.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpMenuServiceImpl.java
index d008e77083..0920c2b3e0 100644
--- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpMenuServiceImpl.java
+++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpMenuServiceImpl.java
@@ -27,7 +27,7 @@ public void create(WxMenu menu) throws WxErrorException {
   }
 
   @Override
-  public void create(Integer agentId, WxMenu menu) throws WxErrorException {
+  public void create(Long agentId, WxMenu menu) throws WxErrorException {
     String url = String.format(this.mainService.getWxCpConfigStorage().getApiUrl(MENU_CREATE), agentId);
     this.mainService.post(url, menu.toJson());
   }
@@ -38,7 +38,7 @@ public void delete() throws WxErrorException {
   }
 
   @Override
-  public void delete(Integer agentId) throws WxErrorException {
+  public void delete(Long agentId) throws WxErrorException {
     String url = String.format(this.mainService.getWxCpConfigStorage().getApiUrl(MENU_DELETE), agentId);
     this.mainService.get(url, null);
   }
@@ -49,7 +49,7 @@ public WxMenu get() throws WxErrorException {
   }
 
   @Override
-  public WxMenu get(Integer agentId) throws WxErrorException {
+  public WxMenu get(Long agentId) throws WxErrorException {
     String url = String.format(this.mainService.getWxCpConfigStorage().getApiUrl(MENU_GET), agentId);
     try {
       String resultContent = this.mainService.get(url, null);
diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpMessageServiceImpl.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpMessageServiceImpl.java
index 6daea8ef2f..def73e4152 100644
--- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpMessageServiceImpl.java
+++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpMessageServiceImpl.java
@@ -21,7 +21,7 @@ public class WxCpMessageServiceImpl implements WxCpMessageService {
 
   @Override
   public WxCpMessageSendResult send(WxCpMessage message) throws WxErrorException {
-    Integer agentId = message.getAgentId();
+    Long agentId = message.getAgentId();
     if (null == agentId) {
       message.setAgentId(this.cpService.getWxCpConfigStorage().getAgentId());
     }
@@ -38,7 +38,7 @@ public WxCpMessageSendStatistics getStatistics(int timeType) throws WxErrorExcep
 
   @Override
   public WxCpLinkedCorpMessageSendResult sendLinkedCorpMessage(WxCpLinkedCorpMessage message) throws WxErrorException {
-    Integer agentId = message.getAgentId();
+    Long agentId = message.getAgentId();
     if (null == agentId) {
       message.setAgentId(this.cpService.getWxCpConfigStorage().getAgentId());
     }
diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpOAuth2ServiceImpl.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpOAuth2ServiceImpl.java
index d04a051c0e..9b390b5ec8 100644
--- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpOAuth2ServiceImpl.java
+++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpOAuth2ServiceImpl.java
@@ -69,7 +69,7 @@ public WxCpOauth2UserInfo getUserInfo(String code) throws WxErrorException {
   }
 
   @Override
-  public WxCpOauth2UserInfo getUserInfo(Integer agentId, String code) throws WxErrorException {
+  public WxCpOauth2UserInfo getUserInfo(Long agentId, String code) throws WxErrorException {
     String responseText =
       this.mainService.get(String.format(this.mainService.getWxCpConfigStorage().getApiUrl(GET_USER_INFO), code,
         agentId), null);
diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpTaskCardServiceImpl.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpTaskCardServiceImpl.java
index 8469451428..0cf0ab6665 100644
--- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpTaskCardServiceImpl.java
+++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpTaskCardServiceImpl.java
@@ -28,7 +28,7 @@ public class WxCpTaskCardServiceImpl implements WxCpTaskCardService {
 
   @Override
   public void update(List userIds, String taskId, String replaceName) throws WxErrorException {
-    Integer agentId = this.mainService.getWxCpConfigStorage().getAgentId();
+    Long agentId = this.mainService.getWxCpConfigStorage().getAgentId();
 
     Map data = new HashMap<>(4);
     data.put("userids", userIds);
@@ -45,7 +45,7 @@ public void update(List userIds, String taskId, String replaceName) thro
   public void updateTemplateCardButton(List userIds, List partyIds,
                                        List tagIds, Integer atAll,
                                        String responseCode, String replaceName) throws WxErrorException {
-    Integer agentId = this.mainService.getWxCpConfigStorage().getAgentId();
+    Long agentId = this.mainService.getWxCpConfigStorage().getAgentId();
     Map data = new HashMap<>(7);
     data.put("userids", userIds);
     data.put("partyids", partyIds);
diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/WxCpAgent.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/WxCpAgent.java
index 5d61b3a199..8f96a729a0 100644
--- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/WxCpAgent.java
+++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/WxCpAgent.java
@@ -32,7 +32,7 @@ public class WxCpAgent implements Serializable {
   private String errMsg;
 
   @SerializedName("agentid")
-  private Integer agentId;
+  private Long agentId;
 
   @SerializedName("name")
   private String name;
diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/WxCpAgentJsapiSignature.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/WxCpAgentJsapiSignature.java
index 4562d9b9b0..8ca7a6cb95 100644
--- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/WxCpAgentJsapiSignature.java
+++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/WxCpAgentJsapiSignature.java
@@ -21,7 +21,7 @@ public class WxCpAgentJsapiSignature implements Serializable {
 
   private String corpid;
 
-  private Integer agentid;
+  private Long agentid;
 
   private long timestamp;
 
diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/corpgroup/WxCpCorpGroupCorpGetTokenReq.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/corpgroup/WxCpCorpGroupCorpGetTokenReq.java
index 6370fc7c11..7fa00a3ada 100644
--- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/corpgroup/WxCpCorpGroupCorpGetTokenReq.java
+++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/corpgroup/WxCpCorpGroupCorpGetTokenReq.java
@@ -17,5 +17,5 @@ public class WxCpCorpGroupCorpGetTokenReq implements Serializable {
   @SerializedName("business_type")
   private int businessType;
   @SerializedName("agentid")
-  private int agentId;
+  private long agentId;
 }
diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/message/WxCpLinkedCorpMessage.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/message/WxCpLinkedCorpMessage.java
index 7e777384eb..46784158f3 100644
--- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/message/WxCpLinkedCorpMessage.java
+++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/message/WxCpLinkedCorpMessage.java
@@ -55,7 +55,15 @@ public class WxCpLinkedCorpMessage implements Serializable {
   /**
    * 企业应用的id,整型。可在应用的设置页面查看
    */
-  private Integer agentId;
+  private Long agentId;
+
+  public void setAgentId(long agentId) {
+    this.agentId = Long.valueOf(agentId);
+  }
+
+  public void setAgentId(Long agentId) {
+    this.agentId = agentId;
+  }
   private String msgType;
   /**
    * 消息内容,最长不超过2048个字节
diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/message/WxCpMessage.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/message/WxCpMessage.java
index ca3fbceccb..c25b5208f1 100644
--- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/message/WxCpMessage.java
+++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/message/WxCpMessage.java
@@ -45,7 +45,15 @@ public class WxCpMessage implements Serializable {
   /**
    * 企业应用的id,整型。企业内部开发,可在应用的设置页面查看;第三方服务商,可通过接口 获取企业授权信息 获取该参数值
    */
-  private Integer agentId;
+  private Long agentId;
+
+  public void setAgentId(long agentId) {
+    this.agentId = Long.valueOf(agentId);
+  }
+
+  public void setAgentId(Long agentId) {
+    this.agentId = agentId;
+  }
   /**
    * 消息类型
    * 文本消息: text
diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/message/WxCpSchoolContactMessage.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/message/WxCpSchoolContactMessage.java
index a13205cd6b..04ec5b135b 100644
--- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/message/WxCpSchoolContactMessage.java
+++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/message/WxCpSchoolContactMessage.java
@@ -74,7 +74,15 @@ public class WxCpSchoolContactMessage implements Serializable {
    * 企业应用的id,整型。可在应用的设置页面查看
    */
   @SerializedName("agentid")
-  private Integer agentId;
+  private Long agentId;
+
+  public void setAgentId(long agentId) {
+    this.agentId = Long.valueOf(agentId);
+  }
+
+  public void setAgentId(Long agentId) {
+    this.agentId = agentId;
+  }
 
   /**
    * 消息内容,最长不超过2048个字节(支持id转译)
diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/messagebuilder/BaseBuilder.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/messagebuilder/BaseBuilder.java
index e7c2267018..fa0c747c16 100644
--- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/messagebuilder/BaseBuilder.java
+++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/messagebuilder/BaseBuilder.java
@@ -15,7 +15,7 @@ public abstract class BaseBuilder {
   /**
    * The Agent id.
    */
-  protected Integer agentId;
+  protected Long agentId;
   /**
    * The To user.
    */
@@ -39,11 +39,15 @@ public abstract class BaseBuilder {
    * @param agentId the agent id
    * @return the t
    */
-  public T agentId(Integer agentId) {
+  public T agentId(Long agentId) {
     this.agentId = agentId;
     return (T) this;
   }
 
+  public T agentId(long agentId) {
+    return this.agentId(Long.valueOf(agentId));
+  }
+
   /**
    * To user t.
    *
diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/config/WxCpConfigStorage.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/config/WxCpConfigStorage.java
index 7f66f05094..0efe7dd606 100644
--- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/config/WxCpConfigStorage.java
+++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/config/WxCpConfigStorage.java
@@ -158,7 +158,7 @@ public interface WxCpConfigStorage {
    *
    * @return the agent id
    */
-  Integer getAgentId();
+  Long getAgentId();
 
   /**
    * Gets token.
diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/config/WxCpCorpGroupConfigStorage.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/config/WxCpCorpGroupConfigStorage.java
index df758ac3a2..61b3b4043b 100644
--- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/config/WxCpCorpGroupConfigStorage.java
+++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/config/WxCpCorpGroupConfigStorage.java
@@ -36,7 +36,7 @@ public interface WxCpCorpGroupConfigStorage {
    * @param corpAccessToken  the corp access token
    * @param expiresInSeconds the expires in seconds
    */
-  void updateCorpAccessToken(String corpId, Integer agentId, String corpAccessToken, int expiresInSeconds);
+  void updateCorpAccessToken(String corpId, Long agentId, String corpAccessToken, int expiresInSeconds);
 
   /**
    * 授权企业的access token相关
@@ -45,7 +45,7 @@ public interface WxCpCorpGroupConfigStorage {
    * @param agentId 应用ID
    * @return the access token
    */
-  String getCorpAccessToken(String corpId, Integer agentId);
+  String getCorpAccessToken(String corpId, Long agentId);
 
   /**
    * Gets access token entity.
@@ -54,7 +54,7 @@ public interface WxCpCorpGroupConfigStorage {
    * @param agentId 应用ID
    * @return the access token entity
    */
-  WxAccessToken getCorpAccessTokenEntity(String corpId, Integer agentId);
+  WxAccessToken getCorpAccessTokenEntity(String corpId, Long agentId);
 
   /**
    * Is access token expired boolean.
@@ -63,7 +63,7 @@ public interface WxCpCorpGroupConfigStorage {
    * @param agentId 应用ID
    * @return the boolean
    */
-  boolean isCorpAccessTokenExpired(String corpId, Integer agentId);
+  boolean isCorpAccessTokenExpired(String corpId, Long agentId);
 
   /**
    * Expire access token.
@@ -71,7 +71,7 @@ public interface WxCpCorpGroupConfigStorage {
    * @param corpId  企业ID
    * @param agentId 应用ID
    */
-  void expireCorpAccessToken(String corpId, Integer agentId);
+  void expireCorpAccessToken(String corpId, Long agentId);
 
   /**
    * 网络代理相关
@@ -122,11 +122,11 @@ public interface WxCpCorpGroupConfigStorage {
    * @param agentId 应用ID
    * @return the access token lock
    */
-  Lock getCorpAccessTokenLock(String corpId, Integer agentId);
+  Lock getCorpAccessTokenLock(String corpId, Long agentId);
 
   void setCorpId(String corpId);
 
-  void setAgentId(Integer agentId);
+  void setAgentId(Long agentId);
 
   /**
    * Gets corp id.
@@ -140,5 +140,5 @@ public interface WxCpCorpGroupConfigStorage {
    *
    * @return the agent id
    */
-  Integer getAgentId();
+  Long getAgentId();
 }
diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/config/impl/AbstractWxCpInRedisConfigImpl.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/config/impl/AbstractWxCpInRedisConfigImpl.java
index 448d2b62dd..dd9879a42a 100644
--- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/config/impl/AbstractWxCpInRedisConfigImpl.java
+++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/config/impl/AbstractWxCpInRedisConfigImpl.java
@@ -74,7 +74,7 @@ public AbstractWxCpInRedisConfigImpl(@NonNull WxRedisOps redisOps, String keyPre
    * @param agentId 应用 agentId
    */
   @Override
-  public void setAgentId(Integer agentId) {
+  public void setAgentId(Long agentId) {
     super.setAgentId(agentId);
     String ukey;
     if (agentId != null) {
diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/config/impl/WxCpCorpGroupDefaultConfigImpl.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/config/impl/WxCpCorpGroupDefaultConfigImpl.java
index b3d4834426..ac57fbeb7a 100644
--- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/config/impl/WxCpCorpGroupDefaultConfigImpl.java
+++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/config/impl/WxCpCorpGroupDefaultConfigImpl.java
@@ -39,7 +39,7 @@ public class WxCpCorpGroupDefaultConfigImpl implements WxCpCorpGroupConfigStorag
   /**
    * 微信企业号应用 ID
    */
-  private volatile Integer agentId;
+  private volatile Long agentId;
 
   @Override
   public void setBaseApiUrl(String baseUrl) {
@@ -65,17 +65,17 @@ public void setCorpId(String corpId) {
   }
 
   @Override
-  public Integer getAgentId() {
+  public Long getAgentId() {
     return agentId;
   }
 
   @Override
-  public void setAgentId(Integer agentId) {
+  public void setAgentId(Long agentId) {
     this.agentId = agentId;
   }
 
   @Override
-  public void updateCorpAccessToken(String corpId, Integer agentId, String corpAccessToken, int expiresInSeconds) {
+  public void updateCorpAccessToken(String corpId, Long agentId, String corpAccessToken, int expiresInSeconds) {
     String key = generateAccessTokenKey(corpId, agentId);
     corpAccessTokenMap.put(key, corpAccessToken);
     //预留200秒的时间
@@ -83,12 +83,12 @@ public void updateCorpAccessToken(String corpId, Integer agentId, String corpAcc
   }
 
   @Override
-  public String getCorpAccessToken(String corpId, Integer agentId) {
+  public String getCorpAccessToken(String corpId, Long agentId) {
     return this.corpAccessTokenMap.get(generateAccessTokenKey(corpId, agentId));
   }
 
   @Override
-  public WxAccessToken getCorpAccessTokenEntity(String corpId, Integer agentId) {
+  public WxAccessToken getCorpAccessTokenEntity(String corpId, Long agentId) {
     String key = generateAccessTokenKey(corpId, agentId);
     String accessToken = corpAccessTokenMap.getOrDefault(key, StringUtils.EMPTY);
     Long expire = corpAccessTokenExpireTimeMap.getOrDefault(key, 0L);
@@ -99,7 +99,7 @@ public WxAccessToken getCorpAccessTokenEntity(String corpId, Integer agentId) {
   }
 
   @Override
-  public boolean isCorpAccessTokenExpired(String corpId, Integer agentId) {
+  public boolean isCorpAccessTokenExpired(String corpId, Long agentId) {
     //不存在或者过期
     String key = generateAccessTokenKey(corpId, agentId);
     return corpAccessTokenExpireTimeMap.get(key) == null
@@ -107,7 +107,7 @@ public boolean isCorpAccessTokenExpired(String corpId, Integer agentId) {
   }
 
   @Override
-  public void expireCorpAccessToken(String corpId, Integer agentId) {
+  public void expireCorpAccessToken(String corpId, Long agentId) {
     String key = generateAccessTokenKey(corpId, agentId);
     corpAccessTokenMap.remove(key);
     corpAccessTokenExpireTimeMap.remove(key);
@@ -189,12 +189,12 @@ public boolean autoRefreshToken() {
   }
 
   @Override
-  public Lock getCorpAccessTokenLock(String corpId, Integer agentId) {
+  public Lock getCorpAccessTokenLock(String corpId, Long agentId) {
     return this.corpAccessTokenLocker
       .computeIfAbsent(generateAccessTokenKey(corpId, agentId), key -> new ReentrantLock());
   }
 
-  private String generateAccessTokenKey(String corpId, Integer agentId) {
+  private String generateAccessTokenKey(String corpId, Long agentId) {
     return String.join(":", this.corpId, String.valueOf(this.agentId), corpId, String.valueOf(agentId));
   }
 }
diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/config/impl/WxCpCorpGroupRedissonConfigImpl.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/config/impl/WxCpCorpGroupRedissonConfigImpl.java
index 1ef05ba8b3..d5b566a5e5 100644
--- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/config/impl/WxCpCorpGroupRedissonConfigImpl.java
+++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/config/impl/WxCpCorpGroupRedissonConfigImpl.java
@@ -60,7 +60,7 @@ public class WxCpCorpGroupRedissonConfigImpl implements WxCpCorpGroupConfigStora
   /**
    * 微信企业号应用 ID
    */
-  private volatile Integer agentId;
+  private volatile Long agentId;
 
   @Override
   public void setBaseApiUrl(String baseUrl) {
@@ -86,27 +86,27 @@ public void setCorpId(String corpId) {
   }
 
   @Override
-  public Integer getAgentId() {
+  public Long getAgentId() {
     return agentId;
   }
 
   @Override
-  public void setAgentId(Integer agentId) {
+  public void setAgentId(Long agentId) {
     this.agentId = agentId;
   }
 
   @Override
-  public void updateCorpAccessToken(String corpId, Integer agentId, String corpAccessToken, int expiresInSeconds) {
+  public void updateCorpAccessToken(String corpId, Long agentId, String corpAccessToken, int expiresInSeconds) {
     wxRedisOps.setValue(generateAccessTokenKey(corpId, agentId), corpAccessToken, expiresInSeconds, TimeUnit.SECONDS);
   }
 
   @Override
-  public String getCorpAccessToken(String corpId, Integer agentId) {
+  public String getCorpAccessToken(String corpId, Long agentId) {
     return wxRedisOps.getValue(generateAccessTokenKey(corpId, agentId));
   }
 
   @Override
-  public WxAccessToken getCorpAccessTokenEntity(String corpId, Integer agentId) {
+  public WxAccessToken getCorpAccessTokenEntity(String corpId, Long agentId) {
     String key = generateAccessTokenKey(corpId, agentId);
     String accessToken = wxRedisOps.getValue(key);
     Long expire = wxRedisOps.getExpire(key);
@@ -120,13 +120,13 @@ public WxAccessToken getCorpAccessTokenEntity(String corpId, Integer agentId) {
   }
 
   @Override
-  public boolean isCorpAccessTokenExpired(String corpId, Integer agentId) {
+  public boolean isCorpAccessTokenExpired(String corpId, Long agentId) {
     String key = generateAccessTokenKey(corpId, agentId);
     return wxRedisOps.getExpire(key) == 0L || wxRedisOps.getExpire(key) == -2;
   }
 
   @Override
-  public void expireCorpAccessToken(String corpId, Integer agentId) {
+  public void expireCorpAccessToken(String corpId, Long agentId) {
     wxRedisOps.expire(generateAccessTokenKey(corpId, agentId), 0, TimeUnit.SECONDS);
   }
 
@@ -206,11 +206,11 @@ public boolean autoRefreshToken() {
   }
 
   @Override
-  public Lock getCorpAccessTokenLock(String corpId, Integer agentId) {
+  public Lock getCorpAccessTokenLock(String corpId, Long agentId) {
     return this.getLockByKey(String.join(":", corpId, String.valueOf(agentId), LOCKER_CORP_ACCESS_TOKEN));
   }
 
-  private String generateAccessTokenKey(String corpId, Integer agentId) {
+  private String generateAccessTokenKey(String corpId, Long agentId) {
     return String.join(":", keyPrefix, CG_ACCESS_TOKEN_KEY, corpId, String.valueOf(agentId));
   }
 
diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/config/impl/WxCpDefaultConfigImpl.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/config/impl/WxCpDefaultConfigImpl.java
index 6435370150..484e0c4284 100644
--- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/config/impl/WxCpDefaultConfigImpl.java
+++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/config/impl/WxCpDefaultConfigImpl.java
@@ -30,7 +30,7 @@ public class WxCpDefaultConfigImpl implements WxCpConfigStorage, Serializable {
   /**
    * The Agent id.
    */
-  protected volatile Integer agentId;
+  protected volatile Long agentId;
   /**
    * The Jsapi ticket lock.
    */
@@ -320,7 +320,7 @@ public void setAesKey(String aesKey) {
   }
 
   @Override
-  public Integer getAgentId() {
+  public Long getAgentId() {
     return this.agentId;
   }
 
@@ -329,10 +329,14 @@ public Integer getAgentId() {
    *
    * @param agentId the agent id
    */
-  public void setAgentId(Integer agentId) {
+  public void setAgentId(Long agentId) {
     this.agentId = agentId;
   }
 
+  public void setAgentId(long agentId) {
+    this.setAgentId(Long.valueOf(agentId));
+  }
+
   /**
    * 设置企微会话存档路径.
    *
diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/config/impl/WxCpRedisConfigImpl.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/config/impl/WxCpRedisConfigImpl.java
index 85d136e01d..a013a9b930 100644
--- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/config/impl/WxCpRedisConfigImpl.java
+++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/config/impl/WxCpRedisConfigImpl.java
@@ -40,7 +40,7 @@ public class WxCpRedisConfigImpl implements WxCpConfigStorage {
   private volatile String corpSecret;
   private volatile String token;
   private volatile String aesKey;
-  private volatile Integer agentId;
+  private volatile Long agentId;
   private volatile String msgAuditPriKey;
   private volatile String msgAuditLibPath;
   private volatile String oauth2redirectUri;
@@ -312,7 +312,7 @@ public void setCorpSecret(String corpSecret) {
   }
 
   @Override
-  public Integer getAgentId() {
+  public Long getAgentId() {
     return this.agentId;
   }
 
@@ -321,7 +321,7 @@ public Integer getAgentId() {
    *
    * @param agentId the agent id
    */
-  public void setAgentId(Integer agentId) {
+  public void setAgentId(Long agentId) {
     this.agentId = agentId;
   }
 
diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/corpgroup/service/WxCpCgService.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/corpgroup/service/WxCpCgService.java
index f94c14a4f1..a8d0de682e 100644
--- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/corpgroup/service/WxCpCgService.java
+++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/corpgroup/service/WxCpCgService.java
@@ -24,11 +24,11 @@ public interface WxCpCgService {
    * @param corpAccessToken  the corp access token
    * @param expiresInSeconds the expires in seconds
    */
-  void updateCorpAccessToken(String corpId, Integer agentId, String corpAccessToken, int expiresInSeconds);
+  void updateCorpAccessToken(String corpId, Long agentId, String corpAccessToken, int expiresInSeconds);
 
-  String getCorpAccessToken(String corpId, Integer agentId, Integer businessType) throws WxErrorException;
+  String getCorpAccessToken(String corpId, Long agentId, Integer businessType) throws WxErrorException;
 
-  String getCorpAccessToken(String corpId, Integer agentId, Integer businessType, boolean forceRefresh) throws WxErrorException;
+  String getCorpAccessToken(String corpId, Long agentId, Integer businessType, boolean forceRefresh) throws WxErrorException;
 
   /**
    * 授权企业的access token相关
@@ -39,7 +39,7 @@ public interface WxCpCgService {
    * @return the access token
    * @throws WxErrorException 微信错误异常
    */
-  WxAccessToken getCorpAccessTokenEntity(String corpId, Integer agentId, Integer businessType) throws WxErrorException;
+  WxAccessToken getCorpAccessTokenEntity(String corpId, Long agentId, Integer businessType) throws WxErrorException;
 
   /**
    * Gets access token entity.
@@ -51,7 +51,7 @@ public interface WxCpCgService {
    * @return the access token entity
    * @throws WxErrorException 微信错误异常
    */
-  WxAccessToken getCorpAccessTokenEntity(String corpId, Integer agentId, Integer businessType, boolean forceRefresh) throws WxErrorException;
+  WxAccessToken getCorpAccessTokenEntity(String corpId, Long agentId, Integer businessType, boolean forceRefresh) throws WxErrorException;
 
   /**
    * Is access token expired boolean.
@@ -60,7 +60,7 @@ public interface WxCpCgService {
    * @param agentId 应用ID
    * @return the boolean
    */
-  boolean isCorpAccessTokenExpired(String corpId, Integer agentId);
+  boolean isCorpAccessTokenExpired(String corpId, Long agentId);
 
   /**
    * Expire access token.
@@ -68,7 +68,7 @@ public interface WxCpCgService {
    * @param corpId  企业ID
    * @param agentId 应用ID
    */
-  void expireCorpAccessToken(String corpId, Integer agentId);
+  void expireCorpAccessToken(String corpId, Long agentId);
 
   /**
    * 当本Service没有实现某个API的时候,可以用这个,针对所有微信API中的GET请求.
diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/corpgroup/service/impl/BaseWxCpCgServiceImpl.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/corpgroup/service/impl/BaseWxCpCgServiceImpl.java
index e4fe2a686a..5439849f2a 100644
--- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/corpgroup/service/impl/BaseWxCpCgServiceImpl.java
+++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/corpgroup/service/impl/BaseWxCpCgServiceImpl.java
@@ -43,17 +43,17 @@ public abstract class BaseWxCpCgServiceImpl implements WxCpCgService, Requ
   private final WxCpLinkedCorpService linkedCorpService = new WxCpLinkedCorpServiceImpl(this);
 
   @Override
-  public void updateCorpAccessToken(String corpId, Integer agentId, String corpAccessToken, int expiresInSeconds) {
+  public void updateCorpAccessToken(String corpId, Long agentId, String corpAccessToken, int expiresInSeconds) {
 
   }
 
   @Override
-  public String getCorpAccessToken(String corpId, Integer agentId, Integer businessType) throws WxErrorException {
+  public String getCorpAccessToken(String corpId, Long agentId, Integer businessType) throws WxErrorException {
     return getCorpAccessToken(corpId, agentId, businessType, false);
   }
 
   @Override
-  public String getCorpAccessToken(String corpId, Integer agentId, Integer businessType, boolean forceRefresh) throws WxErrorException {
+  public String getCorpAccessToken(String corpId, Long agentId, Integer businessType, boolean forceRefresh) throws WxErrorException {
     if (!this.configStorage.isCorpAccessTokenExpired(corpId, agentId) && !forceRefresh) {
       return this.configStorage.getCorpAccessToken(corpId, agentId);
     }
@@ -71,23 +71,23 @@ public String getCorpAccessToken(String corpId, Integer agentId, Integer busines
   }
 
   @Override
-  public WxAccessToken getCorpAccessTokenEntity(String corpId, Integer agentId, Integer businessType) throws WxErrorException {
+  public WxAccessToken getCorpAccessTokenEntity(String corpId, Long agentId, Integer businessType) throws WxErrorException {
     return this.getCorpAccessTokenEntity(corpId, agentId, businessType, false);
   }
 
 
   @Override
-  public WxAccessToken getCorpAccessTokenEntity(String corpId, Integer agentId, Integer businessType, boolean forceRefresh) throws WxErrorException {
+  public WxAccessToken getCorpAccessTokenEntity(String corpId, Long agentId, Integer businessType, boolean forceRefresh) throws WxErrorException {
     return this.configStorage.getCorpAccessTokenEntity(corpId, agentId);
   }
 
   @Override
-  public boolean isCorpAccessTokenExpired(String corpId, Integer agentId) {
+  public boolean isCorpAccessTokenExpired(String corpId, Long agentId) {
     return this.configStorage.isCorpAccessTokenExpired(corpId, agentId);
   }
 
   @Override
-  public void expireCorpAccessToken(String corpId, Integer agentId) {
+  public void expireCorpAccessToken(String corpId, Long agentId) {
     this.configStorage.expireCorpAccessToken(corpId, agentId);
   }
 
diff --git a/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/api/impl/BaseWxCpServiceImplTest.java b/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/api/impl/BaseWxCpServiceImplTest.java
index bdc85afcfc..115eafd182 100644
--- a/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/api/impl/BaseWxCpServiceImplTest.java
+++ b/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/api/impl/BaseWxCpServiceImplTest.java
@@ -121,7 +121,7 @@ public WxCpConfigStorage getWxCpConfigStorage() {
         return config;
       }
     };
-    config.setAgentId(1);
+    config.setAgentId(1L);
     service.setWxCpConfigStorage(config);
     RequestExecutor re = mock(RequestExecutor.class);
 
diff --git a/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/api/impl/WxCpAgentServiceImplTest.java b/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/api/impl/WxCpAgentServiceImplTest.java
index cbd947b925..e9004c6cf9 100644
--- a/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/api/impl/WxCpAgentServiceImplTest.java
+++ b/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/api/impl/WxCpAgentServiceImplTest.java
@@ -43,7 +43,7 @@ public class WxCpAgentServiceImplTest {
    */
   @Test
   public void testGet() throws Exception {
-    final Integer agentId = this.wxCpService.getWxCpConfigStorage().getAgentId();
+    final Long agentId = this.wxCpService.getWxCpConfigStorage().getAgentId();
     WxCpAgent wxCpAgent = this.wxCpService.getAgentService().get(agentId);
 
     assertThat(wxCpAgent.getAgentId()).isEqualTo(agentId);
@@ -60,7 +60,7 @@ public void testGet() throws Exception {
    */
   @Test
   public void testSet() throws WxErrorException {
-    final Integer agentId = this.wxCpService.getWxCpConfigStorage().getAgentId();
+    final Long agentId = this.wxCpService.getWxCpConfigStorage().getAgentId();
 
     this.wxCpService.getAgentService().set(WxCpAgent.builder()
       .description("abcddd")
@@ -92,7 +92,7 @@ public void testList() throws WxErrorException {
    */
   @Test
   public void testGetAdminList() throws WxErrorException {
-    final Integer agentId = this.wxCpService.getWxCpConfigStorage().getAgentId();
+    final Long agentId = this.wxCpService.getWxCpConfigStorage().getAgentId();
     WxCpTpAdmin adminList = this.wxCpService.getAgentService().getAdminList(agentId);
 
     assertThat(adminList).isNotNull();
@@ -124,7 +124,7 @@ public void testGet() throws Exception {
       when(wxService.getAgentService()).thenReturn(new WxCpAgentServiceImpl(wxService));
 
       WxCpAgentService wxAgentService = this.wxService.getAgentService();
-      WxCpAgent wxCpAgent = wxAgentService.get(9);
+      WxCpAgent wxCpAgent = wxAgentService.get(9L);
 
       assertEquals(9, wxCpAgent.getAgentId().intValue());
 
@@ -171,7 +171,7 @@ public void testGetAdminList() throws Exception {
       when(wxService.getAgentService()).thenReturn(new WxCpAgentServiceImpl(wxService));
 
       WxCpAgentService wxAgentService = this.wxService.getAgentService();
-      WxCpTpAdmin adminList = wxAgentService.getAdminList(9);
+      WxCpTpAdmin adminList = wxAgentService.getAdminList(9L);
 
       assertEquals(0, adminList.getErrcode().intValue());
       assertEquals(2, adminList.getAdmin().size());
diff --git a/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/api/impl/WxCpCorpGroupServiceImplTest.java b/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/api/impl/WxCpCorpGroupServiceImplTest.java
index e78ce5c008..44928e3e74 100644
--- a/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/api/impl/WxCpCorpGroupServiceImplTest.java
+++ b/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/api/impl/WxCpCorpGroupServiceImplTest.java
@@ -23,7 +23,7 @@ public class WxCpCorpGroupServiceImplTest {
 
   @Test
   public void testListAppShareInfo() throws WxErrorException {
-    Integer agentId = wxService.getWxCpConfigStorage().getAgentId();
+    Long agentId = wxService.getWxCpConfigStorage().getAgentId();
     Integer businessType = 1;
     String corpId = null;
     Integer limit = null;
diff --git a/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/bean/message/WxCpLinkedCorpMessageTest.java b/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/bean/message/WxCpLinkedCorpMessageTest.java
index cab57e1510..e008e47720 100644
--- a/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/bean/message/WxCpLinkedCorpMessageTest.java
+++ b/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/bean/message/WxCpLinkedCorpMessageTest.java
@@ -27,7 +27,7 @@ public void testToJson_text() {
       .toUsers(new String[]{"userid1", "userid2", "CorpId1/userid1", "CorpId2/userid2"})
       .toParties(new String[]{"partyid1", "partyid2", "LinkedId1/partyid1", "LinkedId2/partyid2"})
       .toTags(new String[]{"tagid1", "tagid2"})
-      .agentId(1)
+      .agentId(1L)
       .isToAll(false)
       .isSafe(false)
       .content("你的快递已到,请携带工卡前往邮件中心领取。\n出发前可查看邮件中心视频实况,聪明避开排队。")
@@ -61,7 +61,7 @@ public void testToJson_image() {
       .toUsers(new String[]{"userid1", "userid2", "CorpId1/userid1", "CorpId2/userid2"})
       .toParties(new String[]{"partyid1", "partyid2", "LinkedId1/partyid1", "LinkedId2/partyid2"})
       .toTags(new String[]{"tagid1", "tagid2"})
-      .agentId(1)
+      .agentId(1L)
       .isToAll(false)
       .isSafe(false)
       .mediaId("MEDIA_ID")
@@ -94,7 +94,7 @@ public void testToJson_video() {
       .toUsers(new String[]{"userid1", "userid2", "CorpId1/userid1", "CorpId2/userid2"})
       .toParties(new String[]{"partyid1", "partyid2", "LinkedId1/partyid1", "LinkedId2/partyid2"})
       .toTags(new String[]{"tagid1", "tagid2"})
-      .agentId(1)
+      .agentId(1L)
       .isToAll(false)
       .isSafe(false)
       .mediaId("MEDIA_ID")
@@ -131,7 +131,7 @@ public void testToJson_file() {
       .toUsers(new String[]{"userid1", "userid2", "CorpId1/userid1", "CorpId2/userid2"})
       .toParties(new String[]{"partyid1", "partyid2", "LinkedId1/partyid1", "LinkedId2/partyid2"})
       .toTags(new String[]{"tagid1", "tagid2"})
-      .agentId(1)
+      .agentId(1L)
       .isToAll(false)
       .isSafe(false)
       .mediaId("1Yv-zXfHjSjU-7LH-GwtYqDGS-zz6w22KmWAT5COgP7o")
@@ -164,7 +164,7 @@ public void testToJson_textCard() {
       .toUsers(new String[]{"userid1", "userid2", "CorpId1/userid1", "CorpId2/userid2"})
       .toParties(new String[]{"partyid1", "partyid2", "LinkedId1/partyid1", "LinkedId2/partyid2"})
       .toTags(new String[]{"tagid1", "tagid2"})
-      .agentId(1)
+      .agentId(1L)
       .isToAll(false)
       .title("领奖通知")
       .description("
2016年9月26日
恭喜你抽中iPhone 7一台,领奖码:xxxx
**事项详情**\n" + diff --git a/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/bean/message/WxCpMessageTest.java b/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/bean/message/WxCpMessageTest.java index 9d6210b460..04f22a3d80 100644 --- a/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/bean/message/WxCpMessageTest.java +++ b/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/bean/message/WxCpMessageTest.java @@ -238,7 +238,7 @@ public void TestTemplateCardBuilder_text_notice() { WxCpMessage reply = WxCpMessage.TEMPLATECARD().toUser("OPENID") .toParty("PartyID1 | PartyID2") .toTag("TagID1 | TagID2") - .agentId(1000002) + .agentId(1000002L) .cardType(WxConsts.TemplateCardType.TEXT_NOTICE) .taskId("task_id") .sourceIconUrl("图片的url") @@ -328,7 +328,7 @@ public void TestTemplateCardBuilder_news_notice() { .build(); WxCpMessage reply = WxCpMessage.TEMPLATECARD().toUser("OPENID") - .agentId(1000002) + .agentId(1000002L) .cardType(WxConsts.TemplateCardType.NEWS_NOTICE) .sourceIconUrl("图片的url") .sourceDesc("企业微信") @@ -395,7 +395,7 @@ public void TestTemplateCardBuilder_button_interaction() { .build(); WxCpMessage reply = WxCpMessage.TEMPLATECARD().toUser("OPENID") - .agentId(1000002) + .agentId(1000002L) .cardType(WxConsts.TemplateCardType.BUTTON_INTERACTION) .sourceIconUrl("图片的url") .sourceDesc("企业微信") @@ -444,7 +444,7 @@ public void TestTemplateCardBuilder_vote_interaction() { .build(); WxCpMessage reply = WxCpMessage.TEMPLATECARD().toUser("OPENID") - .agentId(1000002) + .agentId(1000002L) .cardType(WxConsts.TemplateCardType.VOTE_INTERACTION) .sourceIconUrl("图片的url") .sourceDesc("企业微信") @@ -510,7 +510,7 @@ public void TestTemplateCardBuilder_multiple_interaction() { WxCpMessage reply = WxCpMessage.TEMPLATECARD().toUser("OPENID") - .agentId(1000002) + .agentId(1000002L) .cardType(WxConsts.TemplateCardType.MULTIPLE_INTERACTION) .sourceIconUrl("图片的url") .sourceDesc("企业微信") diff --git a/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/bean/message/WxCpSchoolContactMessageTest.java b/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/bean/message/WxCpSchoolContactMessageTest.java index f261827059..8fd627ec9c 100644 --- a/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/bean/message/WxCpSchoolContactMessageTest.java +++ b/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/bean/message/WxCpSchoolContactMessageTest.java @@ -109,7 +109,7 @@ public void testToJson_text() { .toStudentUserId(new String[]{"student_userid1", "student_userid2"}) .toParty(new String[]{"partyid1", "partyid2"}) .toAll(false) - .agentId(1) + .agentId(1L) .content("你的快递已到,请携带工卡前往邮件中心领取。\n出发前可查看邮件中心视频实况,聪明避开排队。") .enableIdTrans(false) .enableDuplicateCheck(false) @@ -123,7 +123,7 @@ public void testToJson_text() { schoolContactMessage1.setToStudentUserId(new String[]{"student_userid1", "student_userid2"}); schoolContactMessage1.setToParty(new String[]{"partyid1", "partyid2"}); schoolContactMessage1.setToAll(false); - schoolContactMessage1.setAgentId(1); + schoolContactMessage1.setAgentId(1L); schoolContactMessage1.setContent("你的快递已到,请携带工卡前往邮件中心领取"); schoolContactMessage1.setEnableIdTrans(false); schoolContactMessage1.setEnableDuplicateCheck(false); @@ -163,7 +163,7 @@ public void testToJson_image() { .toStudentUserId(new String[]{"student_userid1", "student_userid2"}) .toParty(new String[]{"partyid1", "partyid2"}) .toAll(false) - .agentId(1) + .agentId(1L) .mediaId("MEDIA_ID") .build(); @@ -198,7 +198,7 @@ public void testToJson_voice() { .toStudentUserId(new String[]{"student_userid1", "student_userid2"}) .toParty(new String[]{"partyid1", "partyid2"}) .toAll(false) - .agentId(1) + .agentId(1L) .mediaId("MEDIA_ID") .build(); @@ -233,7 +233,7 @@ public void testToJson_video() { .toStudentUserId(new String[]{"student_userid1", "student_userid2"}) .toParty(new String[]{"partyid1", "partyid2"}) .toAll(false) - .agentId(1) + .agentId(1L) .mediaId("MEDIA_ID") .title("Title") .description("Description") @@ -272,7 +272,7 @@ public void testToJson_file() { .toStudentUserId(new String[]{"student_userid1", "student_userid2"}) .toParty(new String[]{"partyid1", "partyid2"}) .toAll(false) - .agentId(1) + .agentId(1L) .mediaId("1Yv-zXfHjSjU-7LH-GwtYqDGS-zz6w22KmWAT5COgP7o") .build(); @@ -307,7 +307,7 @@ public void testToJson_news() { .toStudentUserId(new String[]{"student_userid1", "student_userid2"}) .toParty(new String[]{"partyid1", "partyid2"}) .toAll(false) - .agentId(1) + .agentId(1L) .articles(Lists.newArrayList(NewArticle.builder() .title("中秋节礼品领取") .description("今年中秋节公司有豪礼相送") @@ -357,7 +357,7 @@ public void testToJson_mpnews() { .toStudentUserId(new String[]{"student_userid1", "student_userid2"}) .toParty(new String[]{"partyid1", "partyid2"}) .toAll(false) - .agentId(1) + .agentId(1L) .mpNewsArticles(Lists.newArrayList(MpnewsArticle.newBuilder() .title("Title") .thumbMediaId("MEDIA_ID") @@ -409,7 +409,7 @@ public void testToJson_miniProgram() { .toStudentUserId(new String[]{"student_userid1", "student_userid2"}) .toParty(new String[]{"partyid1", "partyid2"}) .toAll(false) - .agentId(1) + .agentId(1L) .appId("APPID") .title("欢迎报名夏令营") .thumbMediaId("MEDIA_ID") diff --git a/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/config/impl/AbstractWxCpInRedisConfigImplTest.java b/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/config/impl/AbstractWxCpInRedisConfigImplTest.java index 201286943e..3f96797a83 100644 --- a/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/config/impl/AbstractWxCpInRedisConfigImplTest.java +++ b/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/config/impl/AbstractWxCpInRedisConfigImplTest.java @@ -29,7 +29,7 @@ public void setUp() { // 使用匿名类提供具体实现用于测试 }; config.setCorpId("testCorpId"); - config.setAgentId(1); + config.setAgentId(1L); } /** diff --git a/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/config/impl/DemoToStringFix.java b/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/config/impl/DemoToStringFix.java index 48fe9a6639..1edbe6b4ca 100644 --- a/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/config/impl/DemoToStringFix.java +++ b/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/config/impl/DemoToStringFix.java @@ -30,7 +30,7 @@ public void expire(String key, int expire, java.util.concurrent.TimeUnit timeUni }; config.setCorpId("demoCorpId"); - config.setAgentId(1001); + config.setAgentId(1001L); System.out.println("Testing toString() method:"); try { diff --git a/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/config/impl/WxCpDefaultConfigImplTest.java b/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/config/impl/WxCpDefaultConfigImplTest.java new file mode 100644 index 0000000000..06807137e0 --- /dev/null +++ b/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/config/impl/WxCpDefaultConfigImplTest.java @@ -0,0 +1,17 @@ +package me.chanjar.weixin.cp.config.impl; + +import org.testng.annotations.Test; + +import static org.testng.Assert.assertEquals; + +public class WxCpDefaultConfigImplTest { + + @Test + public void shouldStoreAgentIdBeyondIntegerRange() { + WxCpDefaultConfigImpl config = new WxCpDefaultConfigImpl(); + + config.setAgentId(1013699173317L); + + assertEquals(config.getAgentId(), Long.valueOf(1013699173317L)); + } +} diff --git a/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/corpgroup/service/impl/WxCpCgServiceApacheHttpClientImplTest.java b/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/corpgroup/service/impl/WxCpCgServiceApacheHttpClientImplTest.java index 4c99dbf5ed..7fcd0b91e7 100644 --- a/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/corpgroup/service/impl/WxCpCgServiceApacheHttpClientImplTest.java +++ b/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/corpgroup/service/impl/WxCpCgServiceApacheHttpClientImplTest.java @@ -38,7 +38,7 @@ public class WxCpCgServiceApacheHttpClientImplTest { //下游企业的corpId String corpId = ""; //下游企业的agentId - int agentId = 0; + Long agentId = 0L; int businessType = 0; String userId = ""; WxCpCorpGroupCorpGetTokenReq wxCpCorpGroupCorpGetTokenReq; diff --git a/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/tp/service/impl/WxCpTpMessageServiceImplTest.java b/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/tp/service/impl/WxCpTpMessageServiceImplTest.java index ff0a143b71..48ee6bb804 100644 --- a/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/tp/service/impl/WxCpTpMessageServiceImplTest.java +++ b/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/tp/service/impl/WxCpTpMessageServiceImplTest.java @@ -77,7 +77,7 @@ public void testSendMessage() throws WxErrorException { + "?access_token=" + accessToken; when(wxCpTpService.post(eq(expectedUrl), anyString(), eq(true))).thenReturn(mockResponse); - WxCpMessage message = WxCpMessage.TEXT().toUser("zhangsan").content("hello").agentId(1).build(); + WxCpMessage message = WxCpMessage.TEXT().toUser("zhangsan").content("hello").agentId(1L).build(); WxCpMessageSendResult result = wxCpTpMessageService.send(message, corpId); assertNotNull(result); diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/WxMaUserService.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/WxMaUserService.java index bc8b69a14f..65b817f79f 100644 --- a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/WxMaUserService.java +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/WxMaUserService.java @@ -73,6 +73,19 @@ public interface WxMaUserService { */ WxMaPhoneNumberInfo getPhoneNumber(String code) throws WxErrorException; + /** + * 获取手机号信息,并校验手机号获取凭证与用户的绑定关系。 + * + * @param code 每个code只能使用一次,code的有效期为5min。code获取方式参考手机号快速验证组件 + * @param openid 用户openid,传入后微信服务端将校验其与code的绑定关系 + * @return 用户手机号信息 + * @throws WxErrorException . + * @apiNote 该接口用于将code换取用户手机号。 + */ + default WxMaPhoneNumberInfo getPhoneNumber(String code, String openid) throws WxErrorException { + return this.getPhoneNumber(code); + } + /** * 获取手机号信息,基础库:2.21.2及以上或2023年8月28日起 * diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/impl/BaseWxMaServiceImpl.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/impl/BaseWxMaServiceImpl.java index 9d6c2c0fa6..bf69439a65 100644 --- a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/impl/BaseWxMaServiceImpl.java +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/impl/BaseWxMaServiceImpl.java @@ -374,7 +374,7 @@ public WxMaApiResponse execute( Map headers, String data) throws WxErrorException { - String dataForLog = "Headers: " + headers.toString() + " Body: " + data; + String dataForLog = "Headers: " + headers.toString() + " Body: " + DataUtils.handleDataWithSecret(data); return executeWithRetry( (uriWithAccessToken) -> executor.execute(uriWithAccessToken, headers, data, WxType.MiniApp), uri, diff --git a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/impl/WxMaUserServiceImpl.java b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/impl/WxMaUserServiceImpl.java index c9c7a7b773..abbb021e8c 100644 --- a/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/impl/WxMaUserServiceImpl.java +++ b/weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/impl/WxMaUserServiceImpl.java @@ -16,6 +16,7 @@ import me.chanjar.weixin.common.util.SignUtils; import me.chanjar.weixin.common.util.json.GsonParser; import org.apache.commons.codec.digest.DigestUtils; +import org.apache.commons.lang3.StringUtils; import java.util.Map; @@ -67,8 +68,16 @@ public WxMaPhoneNumberInfo getPhoneNoInfo(String sessionKey, String encryptedDat @Override public WxMaPhoneNumberInfo getPhoneNumber(String code) throws WxErrorException { + return this.getPhoneNumber(code, null); + } + + @Override + public WxMaPhoneNumberInfo getPhoneNumber(String code, String openid) throws WxErrorException { JsonObject param = new JsonObject(); param.addProperty("code", code); + if (StringUtils.isNotBlank(openid)) { + param.addProperty("openid", openid); + } String responseContent = this.service.post(GET_PHONE_NUMBER_URL, param.toString()); JsonObject response = GsonParser.parse(responseContent); if (response.has(PHONE_INFO)) { diff --git a/weixin-java-miniapp/src/test/java/cn/binarywang/wx/miniapp/api/impl/WxMaUserServiceImplPhoneNumberTest.java b/weixin-java-miniapp/src/test/java/cn/binarywang/wx/miniapp/api/impl/WxMaUserServiceImplPhoneNumberTest.java new file mode 100644 index 0000000000..610cd13bf8 --- /dev/null +++ b/weixin-java-miniapp/src/test/java/cn/binarywang/wx/miniapp/api/impl/WxMaUserServiceImplPhoneNumberTest.java @@ -0,0 +1,50 @@ +package cn.binarywang.wx.miniapp.api.impl; + +import cn.binarywang.wx.miniapp.api.WxMaService; +import com.google.gson.JsonObject; +import me.chanjar.weixin.common.error.WxErrorException; +import me.chanjar.weixin.common.util.json.GsonParser; +import org.mockito.ArgumentCaptor; +import org.testng.annotations.Test; + +import static cn.binarywang.wx.miniapp.constant.WxMaApiUrlConstants.User.GET_PHONE_NUMBER_URL; +import static org.mockito.ArgumentMatchers.anyString; +import static org.mockito.ArgumentMatchers.eq; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; +import static org.testng.Assert.assertEquals; +import static org.testng.Assert.assertFalse; + +/** + * {@link WxMaUserServiceImpl} 获取手机号接口的单元测试。 + */ +public class WxMaUserServiceImplPhoneNumberTest { + + @Test + public void shouldSendOpenidWhenGettingPhoneNumber() throws WxErrorException { + WxMaService wxMaService = mock(WxMaService.class); + when(wxMaService.post(anyString(), anyString())).thenReturn("{\"phone_info\":{}}"); + + new WxMaUserServiceImpl(wxMaService).getPhoneNumber("phone-code", "user-openid"); + + ArgumentCaptor requestBody = ArgumentCaptor.forClass(String.class); + verify(wxMaService).post(eq(GET_PHONE_NUMBER_URL), requestBody.capture()); + JsonObject request = GsonParser.parse(requestBody.getValue()); + assertEquals(request.get("code").getAsString(), "phone-code"); + assertEquals(request.get("openid").getAsString(), "user-openid"); + } + + @Test + public void shouldIgnoreBlankOpenidWhenGettingPhoneNumber() throws WxErrorException { + WxMaService wxMaService = mock(WxMaService.class); + when(wxMaService.post(anyString(), anyString())).thenReturn("{\"phone_info\":{}}"); + + new WxMaUserServiceImpl(wxMaService).getPhoneNumber("phone-code", " "); + + ArgumentCaptor requestBody = ArgumentCaptor.forClass(String.class); + verify(wxMaService).post(eq(GET_PHONE_NUMBER_URL), requestBody.capture()); + JsonObject request = GsonParser.parse(requestBody.getValue()); + assertFalse(request.has("openid")); + } +}