mirror of
https://gitee.com/binary/weixin-java-tools.git
synced 2025-06-28 13:16:19 +08:00
【企业微信】接待人员管理 添加接待人员/删除接待人员 增加 department_id_list
This commit is contained in:
parent
a113746ca8
commit
8bd2c1dbbb
@ -75,6 +75,19 @@ public interface WxCpKfService {
|
|||||||
*/
|
*/
|
||||||
WxCpKfServicerOpResp addServicer(String openKfid, List<String> userIdList) throws WxErrorException;
|
WxCpKfServicerOpResp addServicer(String openKfid, List<String> userIdList) throws WxErrorException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 接待人员管理
|
||||||
|
* 添加指定客服账号的接待人员,每个客服账号目前最多可添加2000个接待人员,20个部门。
|
||||||
|
* userid_list和department_id_list至少需要填其中一个
|
||||||
|
*
|
||||||
|
* @param openKfid 客服帐号ID
|
||||||
|
* @param userIdList 接待人员userid列表。第三方应用填密文userid,即open_userid 可填充个数:1 ~ 100。超过100个需分批调用。
|
||||||
|
* @param departmentIdList 接待人员部门id列表 可填充个数:0 ~ 20。
|
||||||
|
* @return 添加客服账号结果 wx cp kf servicer op resp
|
||||||
|
* @throws WxErrorException 异常
|
||||||
|
*/
|
||||||
|
WxCpKfServicerOpResp addServicer(String openKfid, List<String> userIdList,List<String> departmentIdList) throws WxErrorException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 接待人员管理
|
* 接待人员管理
|
||||||
* 从客服帐号删除接待人员
|
* 从客服帐号删除接待人员
|
||||||
@ -86,6 +99,19 @@ public interface WxCpKfService {
|
|||||||
*/
|
*/
|
||||||
WxCpKfServicerOpResp delServicer(String openKfid, List<String> userIdList) throws WxErrorException;
|
WxCpKfServicerOpResp delServicer(String openKfid, List<String> userIdList) throws WxErrorException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 接待人员管理
|
||||||
|
* 从客服帐号删除接待人员
|
||||||
|
* userid_list和department_id_list至少需要填其中一个
|
||||||
|
*
|
||||||
|
* @param openKfid 客服帐号ID
|
||||||
|
* @param userIdList 接待人员userid列表。第三方应用填密文userid,即open_userid 可填充个数:1 ~ 100。超过100个需分批调用。
|
||||||
|
* @param departmentIdList 接待人员部门id列表 可填充个数:0 ~ 100。超过100个需分批调用。
|
||||||
|
* @return 删除客服账号结果 wx cp kf servicer op resp
|
||||||
|
* @throws WxErrorException 异常
|
||||||
|
*/
|
||||||
|
WxCpKfServicerOpResp delServicer(String openKfid, List<String> userIdList, List<String> departmentIdList) throws WxErrorException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 接待人员管理
|
* 接待人员管理
|
||||||
* 获取某个客服帐号的接待人员列表
|
* 获取某个客服帐号的接待人员列表
|
||||||
|
@ -70,23 +70,62 @@ public class WxCpKfServiceImpl implements WxCpKfService {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public WxCpKfServicerOpResp addServicer(String openKfid, List<String> userIdList) throws WxErrorException {
|
public WxCpKfServicerOpResp addServicer(String openKfid, List<String> userIdList) throws WxErrorException {
|
||||||
return servicerOp(openKfid, userIdList, SERVICER_ADD);
|
return servicerOp(openKfid, userIdList, null, SERVICER_ADD);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public WxCpKfServicerOpResp addServicer(String openKfId, List<String> userIdList, List<String> departmentIdList) throws WxErrorException {
|
||||||
|
validateParameters(SERVICER_ADD, userIdList, departmentIdList);
|
||||||
|
return servicerOp(openKfId, userIdList, departmentIdList, SERVICER_ADD);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public WxCpKfServicerOpResp delServicer(String openKfid, List<String> userIdList) throws WxErrorException {
|
public WxCpKfServicerOpResp delServicer(String openKfid, List<String> userIdList) throws WxErrorException {
|
||||||
return servicerOp(openKfid, userIdList, SERVICER_DEL);
|
return servicerOp(openKfid, userIdList, null, SERVICER_DEL);
|
||||||
}
|
}
|
||||||
|
|
||||||
private WxCpKfServicerOpResp servicerOp(String openKfid, List<String> userIdList, String uri) throws WxErrorException {
|
@Override
|
||||||
|
public WxCpKfServicerOpResp delServicer(String openKfid, List<String> userIdList, List<String> departmentIdList) throws WxErrorException {
|
||||||
|
validateParameters(SERVICER_DEL, userIdList, departmentIdList);
|
||||||
|
return servicerOp(openKfid, userIdList, departmentIdList, SERVICER_DEL);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void validateParameters(String uri, List<String> userIdList, List<String> departmentIdList) {
|
||||||
|
if ((userIdList == null || userIdList.isEmpty()) && (departmentIdList == null || departmentIdList.isEmpty())) {
|
||||||
|
throw new IllegalArgumentException("userid_list和department_id_list至少需要填其中一个");
|
||||||
|
}
|
||||||
|
if (SERVICER_DEL.equals(uri)) {
|
||||||
|
if (userIdList != null && userIdList.size() > 100) {
|
||||||
|
throw new IllegalArgumentException("可填充个数:0 ~ 100。超过100个需分批调用。");
|
||||||
|
}
|
||||||
|
if (departmentIdList != null && departmentIdList.size() > 100) {
|
||||||
|
throw new IllegalArgumentException("可填充个数:0 ~ 100。超过100个需分批调用。");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (userIdList != null && userIdList.size() > 100) {
|
||||||
|
throw new IllegalArgumentException("可填充个数:0 ~ 100。超过100个需分批调用。");
|
||||||
|
}
|
||||||
|
if (departmentIdList != null && departmentIdList.size() > 20) {
|
||||||
|
throw new IllegalArgumentException("可填充个数:0 ~ 20。");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private WxCpKfServicerOpResp servicerOp(String openKfid, List<String> userIdList, List<String> departmentIdList, String uri) throws WxErrorException {
|
||||||
String url = cpService.getWxCpConfigStorage().getApiUrl(uri);
|
String url = cpService.getWxCpConfigStorage().getApiUrl(uri);
|
||||||
|
|
||||||
JsonObject json = new JsonObject();
|
JsonObject json = new JsonObject();
|
||||||
json.addProperty("open_kfid", openKfid);
|
json.addProperty("open_kfid", openKfid);
|
||||||
|
if (userIdList != null && !userIdList.isEmpty()) {
|
||||||
JsonArray userIdArray = new JsonArray();
|
JsonArray userIdArray = new JsonArray();
|
||||||
userIdList.forEach(userIdArray::add);
|
userIdList.forEach(userIdArray::add);
|
||||||
json.add("userid_list", userIdArray);
|
json.add("userid_list", userIdArray);
|
||||||
|
}
|
||||||
|
if (departmentIdList != null && !departmentIdList.isEmpty()) {
|
||||||
|
JsonArray departmentIdArray = new JsonArray();
|
||||||
|
departmentIdList.forEach(departmentIdArray::add);
|
||||||
|
json.add("department_id_list", departmentIdArray);
|
||||||
|
}
|
||||||
String responseContent = cpService.post(url, json.toString());
|
String responseContent = cpService.post(url, json.toString());
|
||||||
return WxCpKfServicerOpResp.fromJson(responseContent);
|
return WxCpKfServicerOpResp.fromJson(responseContent);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user