1
0
mirror of synced 2025-12-23 10:39:27 +08:00

🆕 #2942【企业微信】增加企业互联相关接口

This commit is contained in:
1ibo
2023-03-05 21:10:24 +08:00
committed by GitHub
parent 3acf55a0d2
commit a9b8667053
26 changed files with 1927 additions and 12 deletions

View File

@@ -0,0 +1,43 @@
package me.chanjar.weixin.cp.api.impl;
import com.google.gson.JsonObject;
import com.google.inject.Inject;
import me.chanjar.weixin.common.bean.WxAccessToken;
import me.chanjar.weixin.common.error.WxErrorException;
import me.chanjar.weixin.cp.api.ApiTestModule;
import me.chanjar.weixin.cp.api.WxCpService;
import me.chanjar.weixin.cp.bean.corpgroup.*;
import me.chanjar.weixin.cp.corpgroup.service.WxCpCgService;
import org.testng.annotations.Guice;
import org.testng.annotations.Test;
import java.util.List;
import static me.chanjar.weixin.cp.constant.WxCpApiPathConsts.CorpGroup.CORP_GET_TOKEN;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertNotNull;
/**
* @Project: WxJava
* @Package: me.chanjar.weixin.cp.api.impl
* @Description:
* @Author: libo
* @Email: 422423229@qq.com
* @Date: 28/2/2023 7:06 PM
*/
@Guice(modules = ApiTestModule.class)
public class WxCpCorpGroupServiceImplTest {
@Inject
private WxCpService wxService;
@Test
public void testListAppShareInfo() throws WxErrorException {
Integer agentId = wxService.getWxCpConfigStorage().getAgentId();
Integer businessType = 0;
String corpId = null;
Integer limit = null;
String cursor = null;
List<WxCpCorpGroupCorp> resp = wxService.getCorpGroupService().listAppShareInfo(agentId, businessType, corpId, limit, cursor);
assertNotNull(resp);
}
}

View File

@@ -79,7 +79,7 @@ public class WxCpMeetingServiceImplTest {
wxCpMeeting.setTitle("修改会议");
wxCpMeeting.setDescription("修改会议描述");
WxCpMeetingUpdateResult wxCpMeetingUpdateResult = wxCpMeetingService.update(wxCpMeeting);
assertEquals(wxCpMeetingUpdateResult.getErrcode(), 0L);
assertEquals(wxCpMeetingUpdateResult.getErrcode().longValue(), 0L);
/*
测试 获取会议详情
*/

View File

@@ -0,0 +1,114 @@
package me.chanjar.weixin.cp.corpgroup.service.impl;
import com.google.gson.JsonObject;
import com.google.inject.Inject;
import me.chanjar.weixin.common.bean.WxAccessToken;
import me.chanjar.weixin.cp.api.ApiTestModule;
import me.chanjar.weixin.cp.api.WxCpService;
import me.chanjar.weixin.cp.api.impl.WxCpServiceApacheHttpClientImpl;
import me.chanjar.weixin.cp.bean.WxCpAgent;
import me.chanjar.weixin.cp.bean.WxCpUser;
import me.chanjar.weixin.cp.bean.corpgroup.WxCpCorpGroupCorpGetTokenReq;
import me.chanjar.weixin.cp.bean.corpgroup.WxCpMaTransferSession;
import me.chanjar.weixin.cp.config.WxCpCorpGroupConfigStorage;
import me.chanjar.weixin.cp.config.impl.WxCpCorpGroupDefaultConfigImpl;
import me.chanjar.weixin.cp.config.impl.WxCpCorpGroupRedissonConfigImpl;
import me.chanjar.weixin.cp.constant.WxCpApiPathConsts;
import me.chanjar.weixin.cp.corpgroup.service.WxCpCgService;
import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder;
import org.mockito.Mockito;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Guice;
import org.testng.annotations.Test;
import static me.chanjar.weixin.cp.constant.WxCpApiPathConsts.CorpGroup.MA_TRANSFER_SESSION;
import static org.testng.Assert.assertNotNull;
/**
* @Project: WxJava
* @Package: me.chanjar.weixin.cp.corpgroup.service.impl
* @Description:
* @Author: libo
* @Email: 422423229@qq.com
* @Date: 2/3/2023 4:00 PM
*/
@Guice(modules = ApiTestModule.class)
public class WxCpCgServiceApacheHttpClientImplTest {
private final WxCpCgService cgService = Mockito.spy(new WxCpCgServiceApacheHttpClientImpl());
WxCpCorpGroupConfigStorage wxCpCorpGroupConfigStorage;
@Inject
WxCpService wxCpService;
//下游企业的corpId
String corpId = "";
//下游企业的agentId
int agentId = 0;
int businessType = 0;
String userId = "";
WxCpCorpGroupCorpGetTokenReq wxCpCorpGroupCorpGetTokenReq;
@BeforeMethod
public void setUp() {
cgService.setWxCpCorpGroupConfigStorage(wxCpCorpGroupConfigStorage());
cgService.setWxCpService(wxCpService);
wxCpCorpGroupCorpGetTokenReq = new WxCpCorpGroupCorpGetTokenReq();
wxCpCorpGroupCorpGetTokenReq.setCorpId(corpId);
wxCpCorpGroupCorpGetTokenReq.setAgentId(agentId);
wxCpCorpGroupCorpGetTokenReq.setBusinessType(businessType);
}
public WxCpCorpGroupConfigStorage wxCpCorpGroupConfigStorage() {
wxCpCorpGroupConfigStorage = new WxCpCorpGroupDefaultConfigImpl();
wxCpCorpGroupConfigStorage.setCorpId(wxCpService.getWxCpConfigStorage().getCorpId());
wxCpCorpGroupConfigStorage.setAgentId(wxCpService.getWxCpConfigStorage().getAgentId());
return wxCpCorpGroupConfigStorage;
}
@Test
public void testGetCorpAccessToken() throws Exception {
String corpAccessToken = cgService.getCorpAccessToken(corpId, agentId, businessType);
assertNotNull(corpAccessToken);
}
/**
* 通讯录-读取成员
*
* @throws Exception
*/
@Test
public void testGetCorpUser() throws Exception {
String result = cgService.get(wxCpService.getWxCpConfigStorage().getApiUrl(WxCpApiPathConsts.User.USER_GET + userId), null, wxCpCorpGroupCorpGetTokenReq);
assertNotNull(result);
WxCpUser wxCpUser = WxCpUser.fromJson(result);
assertNotNull(wxCpUser.getUserId());
}
/**
* 应用管理-获取指定的应用详情
*
* @throws Exception
*/
@Test
public void testGetAgent() throws Exception {
String result = cgService.get(wxCpService.getWxCpConfigStorage().getApiUrl(String.format(WxCpApiPathConsts.Agent.AGENT_GET, agentId)), null, wxCpCorpGroupCorpGetTokenReq);
assertNotNull(result);
WxCpAgent wxCpAgent = WxCpAgent.fromJson(result);
assertNotNull(wxCpAgent.getAgentId());
}
/**
* 获取下级/下游企业小程序session
*
* @throws Exception
*/
@Test
public void testGetTransferSession() throws Exception {
String sessionKey = "";
WxCpMaTransferSession wxCpMaTransferSession = cgService.getCorpTransferSession(userId, sessionKey, wxCpCorpGroupCorpGetTokenReq);
assertNotNull(wxCpMaTransferSession);
}
}

View File

@@ -0,0 +1,98 @@
package me.chanjar.weixin.cp.corpgroup.service.impl;
import com.google.inject.Inject;
import me.chanjar.weixin.common.error.WxErrorException;
import me.chanjar.weixin.cp.api.ApiTestModule;
import me.chanjar.weixin.cp.api.WxCpService;
import me.chanjar.weixin.cp.bean.corpgroup.WxCpCorpGroupCorpGetTokenReq;
import me.chanjar.weixin.cp.bean.linkedcorp.WxCpLinkedCorpAgentPerm;
import me.chanjar.weixin.cp.bean.linkedcorp.WxCpLinkedCorpDepartment;
import me.chanjar.weixin.cp.bean.linkedcorp.WxCpLinkedCorpUser;
import me.chanjar.weixin.cp.config.WxCpCorpGroupConfigStorage;
import me.chanjar.weixin.cp.config.impl.WxCpCorpGroupDefaultConfigImpl;
import me.chanjar.weixin.cp.corpgroup.service.WxCpCgService;
import org.mockito.Mockito;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Guice;
import org.testng.annotations.Test;
import java.util.List;
import static org.testng.Assert.assertNotNull;
/**
* @Project: WxJava
* @Package: me.chanjar.weixin.cp.api.impl
* @Description:
* @Author: libo
* @Email: 422423229@qq.com
* @Date: 28/2/2023 7:06 PM
*/
@Guice(modules = ApiTestModule.class)
public class WxCpLinkedCorpServiceImplTest {
WxCpCorpGroupConfigStorage wxCpCorpGroupConfigStorage;
@Inject
WxCpService wxCpService;
WxCpCgService cgService;
//下游企业的corpId
String corpId = "";
//下游企业的agentId
int agentId = 0;
int businessType = 0;
//CorpID/UserID
String corpUserId = "";
String departmentId = "";
WxCpCorpGroupCorpGetTokenReq wxCpCorpGroupCorpGetTokenReq;
@BeforeMethod
public void setUp() {
cgService = new WxCpCgServiceApacheHttpClientImpl();
cgService.setWxCpCorpGroupConfigStorage(wxCpCorpGroupConfigStorage());
cgService.setWxCpService(wxCpService);
wxCpCorpGroupCorpGetTokenReq = new WxCpCorpGroupCorpGetTokenReq();
wxCpCorpGroupCorpGetTokenReq.setCorpId(corpId);
wxCpCorpGroupCorpGetTokenReq.setAgentId(agentId);
wxCpCorpGroupCorpGetTokenReq.setBusinessType(businessType);
}
public WxCpCorpGroupConfigStorage wxCpCorpGroupConfigStorage() {
wxCpCorpGroupConfigStorage = new WxCpCorpGroupDefaultConfigImpl();
wxCpCorpGroupConfigStorage.setCorpId(wxCpService.getWxCpConfigStorage().getCorpId());
wxCpCorpGroupConfigStorage.setAgentId(wxCpService.getWxCpConfigStorage().getAgentId());
return wxCpCorpGroupConfigStorage;
}
@Test
public void testGetLinkedCorpAgentPerm() throws WxErrorException {
WxCpLinkedCorpAgentPerm resp = cgService.getLinkedCorpService().getLinkedCorpAgentPerm(wxCpCorpGroupCorpGetTokenReq);
assertNotNull(resp);
}
@Test
public void testGetLinkedCorpUser() throws WxErrorException {
WxCpLinkedCorpUser resp = cgService.getLinkedCorpService().getLinkedCorpUser(corpUserId, wxCpCorpGroupCorpGetTokenReq);
assertNotNull(resp);
}
@Test
public void testGetLinkedCorpSimpleUserList() throws WxErrorException {
List<WxCpLinkedCorpUser> resp = cgService.getLinkedCorpService().getLinkedCorpSimpleUserList(departmentId, wxCpCorpGroupCorpGetTokenReq);
assertNotNull(resp);
}
@Test
public void testGetLinkedCorpUserList() throws WxErrorException {
List<WxCpLinkedCorpUser> resp = cgService.getLinkedCorpService().getLinkedCorpUserList(departmentId, wxCpCorpGroupCorpGetTokenReq);
assertNotNull(resp);
}
@Test
public void testGetLinkedCorpDepartmentList() throws WxErrorException {
List<WxCpLinkedCorpDepartment> resp = cgService.getLinkedCorpService().getLinkedCorpDepartmentList(departmentId, wxCpCorpGroupCorpGetTokenReq);
assertNotNull(resp);
}
}

View File

@@ -8,11 +8,9 @@ import me.chanjar.weixin.cp.bean.WxCpTpCorp;
import me.chanjar.weixin.cp.bean.WxCpTpPermanentCodeInfo;
import me.chanjar.weixin.cp.bean.WxTpCustomizedAuthUrl;
import me.chanjar.weixin.cp.config.WxCpTpConfigStorage;
import me.chanjar.weixin.cp.config.impl.WxCpDefaultConfigImpl;
import me.chanjar.weixin.cp.config.impl.WxCpTpDefaultConfigImpl;
import me.chanjar.weixin.cp.config.impl.WxCpTpRedissonConfigImpl;
import me.chanjar.weixin.cp.tp.service.WxCpTpService;
import org.apache.http.util.Asserts;
import org.mockito.Mockito;
import org.redisson.Redisson;
import org.redisson.api.RedissonClient;
@@ -22,7 +20,6 @@ import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Objects;