🆕 #3823 【企业微信】添加获取应用管理员列表的接口
This commit is contained in:
@@ -2,6 +2,7 @@ package me.chanjar.weixin.cp.api;
|
||||
|
||||
import me.chanjar.weixin.common.error.WxErrorException;
|
||||
import me.chanjar.weixin.cp.bean.WxCpAgent;
|
||||
import me.chanjar.weixin.cp.bean.WxCpTpAdmin;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -52,4 +53,18 @@ public interface WxCpAgentService {
|
||||
*/
|
||||
List<WxCpAgent> list() throws WxErrorException;
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 获取应用管理员列表
|
||||
* 第三方服务商可以用此接口获取授权企业中某个第三方应用或者代开发应用的管理员列表(不包括外部管理员),
|
||||
* 以便服务商在用户进入应用主页之后根据是否管理员身份做权限的区分。
|
||||
* 详情请见: <a href="https://developer.work.weixin.qq.com/document/path/90506">文档</a>
|
||||
* </pre>
|
||||
*
|
||||
* @param agentId 应用id
|
||||
* @return admin list
|
||||
* @throws WxErrorException the wx error exception
|
||||
*/
|
||||
WxCpTpAdmin getAdminList(Integer agentId) throws WxErrorException;
|
||||
|
||||
}
|
||||
|
||||
@@ -11,6 +11,7 @@ import me.chanjar.weixin.common.util.json.GsonParser;
|
||||
import me.chanjar.weixin.cp.api.WxCpAgentService;
|
||||
import me.chanjar.weixin.cp.api.WxCpService;
|
||||
import me.chanjar.weixin.cp.bean.WxCpAgent;
|
||||
import me.chanjar.weixin.cp.bean.WxCpTpAdmin;
|
||||
import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder;
|
||||
|
||||
import java.util.List;
|
||||
@@ -65,4 +66,21 @@ public class WxCpAgentServiceImpl implements WxCpAgentService {
|
||||
}.getType());
|
||||
}
|
||||
|
||||
@Override
|
||||
public WxCpTpAdmin getAdminList(Integer agentId) throws WxErrorException {
|
||||
if (agentId == null) {
|
||||
throw new IllegalArgumentException("缺少agentid参数");
|
||||
}
|
||||
|
||||
JsonObject jsonObject = new JsonObject();
|
||||
jsonObject.addProperty("agentid", agentId);
|
||||
String url = this.mainService.getWxCpConfigStorage().getApiUrl(AGENT_GET_ADMIN_LIST);
|
||||
String responseContent = this.mainService.post(url, jsonObject.toString());
|
||||
JsonObject respObj = GsonParser.parse(responseContent);
|
||||
if (respObj.get(WxConsts.ERR_CODE).getAsInt() != 0) {
|
||||
throw new WxErrorException(WxError.fromJson(responseContent, WxType.CP));
|
||||
}
|
||||
return WxCpTpAdmin.fromJson(responseContent);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -112,6 +112,10 @@ public interface WxCpApiPathConsts {
|
||||
* The constant AGENT_LIST.
|
||||
*/
|
||||
String AGENT_LIST = "/cgi-bin/agent/list";
|
||||
/**
|
||||
* The constant AGENT_GET_ADMIN_LIST.
|
||||
*/
|
||||
String AGENT_GET_ADMIN_LIST = "/cgi-bin/agent/get_admin_list";
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user