🆕 #1767 企业微信外部联系人增加修改客户备注信息的接口

This commit is contained in:
Binary Wang
2020-09-20 00:09:40 +08:00
parent 115f910e3c
commit 7261f23689
6 changed files with 205 additions and 28 deletions

View File

@@ -132,6 +132,20 @@ public interface WxCpExternalContactService {
*/
WxCpUserExternalContactInfo getContactDetail(String userId) throws WxErrorException;
/**
* 修改客户备注信息.
* <pre>
* 企业可通过此接口修改指定用户添加的客户的备注信息。
* 请求方式: POST(HTTP)
* 请求地址:https://qyapi.weixin.qq.com/cgi-bin/externalcontact/remark?access_token=ACCESS_TOKEN
* 文档地址https://work.weixin.qq.com/api/doc/90000/90135/92115
* </pre>
*
* @param request 备注信息请求
* @throws WxErrorException .
*/
void updateRemark(WxCpUpdateRemarkRequest request) throws WxErrorException;
/**
* 获取客户列表.
* <pre>

View File

@@ -8,7 +8,7 @@ import me.chanjar.weixin.common.error.WxCpErrorMsgEnum;
import me.chanjar.weixin.common.error.WxErrorException;
import me.chanjar.weixin.cp.api.WxCpExternalContactService;
import me.chanjar.weixin.cp.api.WxCpService;
import me.chanjar.weixin.cp.bean.*;
import me.chanjar.weixin.cp.bean.WxCpBaseResp;
import me.chanjar.weixin.cp.bean.external.*;
import org.apache.commons.lang3.ArrayUtils;
import org.apache.commons.lang3.StringUtils;
@@ -67,7 +67,7 @@ public class WxCpExternalContactServiceImpl implements WxCpExternalContactServic
@Override
public WxCpBaseResp deleteContactWay(@NonNull String configId) throws WxErrorException {
JsonObject json = new JsonObject();
json.addProperty("config_id",configId);
json.addProperty("config_id", configId);
final String url = this.mainService.getWxCpConfigStorage().getApiUrl(DEL_CONTACT_WAY);
String responseContent = this.mainService.post(url, json.toString());
@@ -79,8 +79,8 @@ public class WxCpExternalContactServiceImpl implements WxCpExternalContactServic
public WxCpBaseResp closeTempChat(@NonNull String userId, @NonNull String externalUserId) throws WxErrorException {
JsonObject json = new JsonObject();
json.addProperty("userid",userId);
json.addProperty("external_userid",externalUserId);
json.addProperty("userid", userId);
json.addProperty("external_userid", externalUserId);
final String url = this.mainService.getWxCpConfigStorage().getApiUrl(CLOSE_TEMP_CHAT);
@@ -103,6 +103,12 @@ public class WxCpExternalContactServiceImpl implements WxCpExternalContactServic
return WxCpUserExternalContactInfo.fromJson(responseContent);
}
@Override
public void updateRemark(WxCpUpdateRemarkRequest request) throws WxErrorException {
final String url = this.mainService.getWxCpConfigStorage().getApiUrl(UPDATE_REMARK);
this.mainService.post(url, request.toJson());
}
@Override
public List<String> listExternalContacts(String userId) throws WxErrorException {
final String url = this.mainService.getWxCpConfigStorage().getApiUrl(LIST_EXTERNAL_CONTACT + userId);
@@ -233,66 +239,66 @@ public class WxCpExternalContactServiceImpl implements WxCpExternalContactServic
@Override
public WxCpUserExternalTagGroupList getCorpTagList(String[] tagId) throws WxErrorException {
JsonObject json = new JsonObject();
if(ArrayUtils.isNotEmpty(tagId)){
json.add("tag_id",new Gson().toJsonTree(tagId).getAsJsonArray());
if (ArrayUtils.isNotEmpty(tagId)) {
json.add("tag_id", new Gson().toJsonTree(tagId).getAsJsonArray());
}
final String url = this.mainService.getWxCpConfigStorage().getApiUrl(GET_CORP_TAG_LIST);
final String result = this.mainService.post(url,json.toString());
final String result = this.mainService.post(url, json.toString());
return WxCpUserExternalTagGroupList.fromJson(result);
}
@Override
public WxCpUserExternalTagGroupInfo addCorpTag(WxCpUserExternalTagGroupInfo tagGroup) throws WxErrorException{
public WxCpUserExternalTagGroupInfo addCorpTag(WxCpUserExternalTagGroupInfo tagGroup) throws WxErrorException {
final String url = this.mainService.getWxCpConfigStorage().getApiUrl(ADD_CORP_TAG);
final String result = this.mainService.post(url,tagGroup.getTagGroup().toJson());
final String result = this.mainService.post(url, tagGroup.getTagGroup().toJson());
return WxCpUserExternalTagGroupInfo.fromJson(result);
}
@Override
public WxCpBaseResp editCorpTag(String id, String name, Integer order) throws WxErrorException{
public WxCpBaseResp editCorpTag(String id, String name, Integer order) throws WxErrorException {
JsonObject json = new JsonObject();
json.addProperty("id",id);
json.addProperty("name",name);
json.addProperty("order",order);
json.addProperty("id", id);
json.addProperty("name", name);
json.addProperty("order", order);
final String url = this.mainService.getWxCpConfigStorage().getApiUrl(EDIT_CORP_TAG);
final String result = this.mainService.post(url,json.toString());
final String result = this.mainService.post(url, json.toString());
return WxCpBaseResp.fromJson(result);
}
@Override
public WxCpBaseResp delCorpTag(String[] tagId, String[] groupId) throws WxErrorException{
public WxCpBaseResp delCorpTag(String[] tagId, String[] groupId) throws WxErrorException {
JsonObject json = new JsonObject();
if(ArrayUtils.isNotEmpty(tagId)){
json.add("tag_id",new Gson().toJsonTree(tagId).getAsJsonArray());
if (ArrayUtils.isNotEmpty(tagId)) {
json.add("tag_id", new Gson().toJsonTree(tagId).getAsJsonArray());
}
if(ArrayUtils.isNotEmpty(groupId)){
json.add("group_id",new Gson().toJsonTree(groupId).getAsJsonArray());
if (ArrayUtils.isNotEmpty(groupId)) {
json.add("group_id", new Gson().toJsonTree(groupId).getAsJsonArray());
}
final String url = this.mainService.getWxCpConfigStorage().getApiUrl(DEL_CORP_TAG);
final String result = this.mainService.post(url,json.toString());
final String result = this.mainService.post(url, json.toString());
return WxCpBaseResp.fromJson(result);
}
@Override
public WxCpBaseResp markTag(String userid, String externalUserid, String[] addTag, String[] removeTag)throws WxErrorException{
public WxCpBaseResp markTag(String userid, String externalUserid, String[] addTag, String[] removeTag) throws WxErrorException {
JsonObject json = new JsonObject();
json.addProperty("userid",userid);
json.addProperty("external_userid",externalUserid);
json.addProperty("userid", userid);
json.addProperty("external_userid", externalUserid);
if(ArrayUtils.isNotEmpty(addTag)){
json.add("add_tag",new Gson().toJsonTree(addTag).getAsJsonArray());
if (ArrayUtils.isNotEmpty(addTag)) {
json.add("add_tag", new Gson().toJsonTree(addTag).getAsJsonArray());
}
if(ArrayUtils.isNotEmpty(removeTag)){
json.add("remove_tag",new Gson().toJsonTree(removeTag).getAsJsonArray());
if (ArrayUtils.isNotEmpty(removeTag)) {
json.add("remove_tag", new Gson().toJsonTree(removeTag).getAsJsonArray());
}
final String url = this.mainService.getWxCpConfigStorage().getApiUrl(MARK_TAG);
final String result = this.mainService.post(url,json.toString());
final String result = this.mainService.post(url, json.toString());
return WxCpBaseResp.fromJson(result);
}
}