1
0
mirror of synced 2026-10-18 13:26:12 +08:00

🎨 #4079 【企业微信】支持长整型的企业微信应用ID

This commit is contained in:
Binary Wang
2026-07-31 00:21:52 +08:00
committed by GitHub
parent bdf947e2ca
commit 6014c833bc
41 changed files with 162 additions and 113 deletions

View File

@@ -121,7 +121,7 @@ public class BaseWxCpServiceImplTest {
return config;
}
};
config.setAgentId(1);
config.setAgentId(1L);
service.setWxCpConfigStorage(config);
RequestExecutor<Object, Object> re = mock(RequestExecutor.class);

View File

@@ -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 class WxCpAgentServiceImplTest {
*/
@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 class WxCpAgentServiceImplTest {
*/
@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 class WxCpAgentServiceImplTest {
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 class WxCpAgentServiceImplTest {
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());

View File

@@ -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;

View File

@@ -27,7 +27,7 @@ public class WxCpLinkedCorpMessageTest {
.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出发前可查看<a href=\"http://work.weixin.qq.com\">邮件中心视频实况</a>,聪明避开排队。")
@@ -61,7 +61,7 @@ public class WxCpLinkedCorpMessageTest {
.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 class WxCpLinkedCorpMessageTest {
.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 class WxCpLinkedCorpMessageTest {
.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 class WxCpLinkedCorpMessageTest {
.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("<div class=\"gray\">2016年9月26日</div> <div class=\"normal\">恭喜你抽中iPhone 7一台,领奖码:xxxx</div><div " +
@@ -203,7 +203,7 @@ public class WxCpLinkedCorpMessageTest {
.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)
.articles(Lists.newArrayList(NewArticle.builder()
.title("中秋节礼品领取")
@@ -250,7 +250,7 @@ public class WxCpLinkedCorpMessageTest {
.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)
.mpNewsArticles(Lists.newArrayList(MpnewsArticle.newBuilder()
@@ -299,7 +299,7 @@ public class WxCpLinkedCorpMessageTest {
.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)
.content("您的会议室已经预定,稍后会同步到`邮箱`\n" +
" >**事项详情**\n" +

View File

@@ -238,7 +238,7 @@ public class WxCpMessageTest {
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 class WxCpMessageTest {
.build();
WxCpMessage reply = WxCpMessage.TEMPLATECARD().toUser("OPENID")
.agentId(1000002)
.agentId(1000002L)
.cardType(WxConsts.TemplateCardType.NEWS_NOTICE)
.sourceIconUrl("图片的url")
.sourceDesc("企业微信")
@@ -395,7 +395,7 @@ public class WxCpMessageTest {
.build();
WxCpMessage reply = WxCpMessage.TEMPLATECARD().toUser("OPENID")
.agentId(1000002)
.agentId(1000002L)
.cardType(WxConsts.TemplateCardType.BUTTON_INTERACTION)
.sourceIconUrl("图片的url")
.sourceDesc("企业微信")
@@ -444,7 +444,7 @@ public class WxCpMessageTest {
.build();
WxCpMessage reply = WxCpMessage.TEMPLATECARD().toUser("OPENID")
.agentId(1000002)
.agentId(1000002L)
.cardType(WxConsts.TemplateCardType.VOTE_INTERACTION)
.sourceIconUrl("图片的url")
.sourceDesc("企业微信")
@@ -510,7 +510,7 @@ public class WxCpMessageTest {
WxCpMessage reply = WxCpMessage.TEMPLATECARD().toUser("OPENID")
.agentId(1000002)
.agentId(1000002L)
.cardType(WxConsts.TemplateCardType.MULTIPLE_INTERACTION)
.sourceIconUrl("图片的url")
.sourceDesc("企业微信")

View File

@@ -109,7 +109,7 @@ public class WxCpSchoolContactMessageTest {
.toStudentUserId(new String[]{"student_userid1", "student_userid2"})
.toParty(new String[]{"partyid1", "partyid2"})
.toAll(false)
.agentId(1)
.agentId(1L)
.content("你的快递已到,请携带工卡前往邮件中心领取。\n出发前可查看<a href=\"http://work.weixin.qq.com\">邮件中心视频实况</a>,聪明避开排队。")
.enableIdTrans(false)
.enableDuplicateCheck(false)
@@ -123,7 +123,7 @@ public class WxCpSchoolContactMessageTest {
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 class WxCpSchoolContactMessageTest {
.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 class WxCpSchoolContactMessageTest {
.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 class WxCpSchoolContactMessageTest {
.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 class WxCpSchoolContactMessageTest {
.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 class WxCpSchoolContactMessageTest {
.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 class WxCpSchoolContactMessageTest {
.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 class WxCpSchoolContactMessageTest {
.toStudentUserId(new String[]{"student_userid1", "student_userid2"})
.toParty(new String[]{"partyid1", "partyid2"})
.toAll(false)
.agentId(1)
.agentId(1L)
.appId("APPID")
.title("欢迎报名夏令营")
.thumbMediaId("MEDIA_ID")

View File

@@ -29,7 +29,7 @@ public class AbstractWxCpInRedisConfigImplTest {
// 使用匿名类提供具体实现用于测试
};
config.setCorpId("testCorpId");
config.setAgentId(1);
config.setAgentId(1L);
}
/**

View File

@@ -30,7 +30,7 @@ public class DemoToStringFix {
};
config.setCorpId("demoCorpId");
config.setAgentId(1001);
config.setAgentId(1001L);
System.out.println("Testing toString() method:");
try {

View File

@@ -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));
}
}

View File

@@ -38,7 +38,7 @@ public class WxCpCgServiceApacheHttpClientImplTest {
//下游企业的corpId
String corpId = "";
//下游企业的agentId
int agentId = 0;
Long agentId = 0L;
int businessType = 0;
String userId = "";
WxCpCorpGroupCorpGetTokenReq wxCpCorpGroupCorpGetTokenReq;

View File

@@ -77,7 +77,7 @@ public class WxCpTpMessageServiceImplTest {
+ "?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);