🆕 #1493 企业微信增加管理企业客户标签的相关接口
This commit is contained in:
@@ -246,4 +246,61 @@ public interface WxCpExternalContactService {
|
||||
WxCpUserExternalGroupChatStatistic getGroupChatStatistic(Date startTime, Integer orderBy, Integer orderAsc, Integer pageIndex, Integer pageSize, String[] userIds, String[] partyIds) throws WxErrorException;
|
||||
|
||||
WxCpMsgTemplateAddResult addMsgTemplate(WxCpMsgTemplate wxCpMsgTemplate) throws WxErrorException;
|
||||
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 企业可通过此接口获取企业客户标签详情。
|
||||
* </pre>
|
||||
* @param tagId
|
||||
* @return
|
||||
*/
|
||||
WxCpUserExternalTagGroup getCorpTagList(String [] tagId) throws WxErrorException;
|
||||
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 企业可通过此接口向客户标签库中添加新的标签组和标签,每个企业最多可配置3000个企业标签。
|
||||
* 暂不支持第三方调用。
|
||||
* </pre>
|
||||
* @param tagGroup
|
||||
* @return
|
||||
*/
|
||||
WxCpUserExternalTagGroup addCorpTag(WxCpUserExternalTagGroup tagGroup)throws WxErrorException;
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 企业可通过此接口编辑客户标签/标签组的名称或次序值。
|
||||
* 暂不支持第三方调用。
|
||||
* </pre>
|
||||
* @param id
|
||||
* @param name
|
||||
* @param order
|
||||
* @return
|
||||
*/
|
||||
WxCpBaseResp editCorpTag(String id,String name,Integer order)throws WxErrorException;
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 企业可通过此接口删除客户标签库中的标签,或删除整个标签组。
|
||||
* 暂不支持第三方调用。
|
||||
* </pre>
|
||||
* @param tagId
|
||||
* @param groupId
|
||||
* @return
|
||||
*/
|
||||
WxCpBaseResp delCorpTag(String [] tagId,String[] groupId)throws WxErrorException;
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 企业可通过此接口为指定成员的客户添加上由企业统一配置的标签。
|
||||
* https://work.weixin.qq.com/api/doc/90000/90135/92117
|
||||
* </pre>
|
||||
* @param userid
|
||||
* @param externalUserid
|
||||
* @param addTag
|
||||
* @param removeTag
|
||||
* @return
|
||||
*/
|
||||
WxCpBaseResp markTag(String userid,String externalUserid,String[] addTag,String [] removeTag)throws WxErrorException;
|
||||
}
|
||||
|
||||
@@ -223,4 +223,70 @@ public class WxCpExternalContactServiceImpl implements WxCpExternalContactServic
|
||||
final String result = this.mainService.post(url, wxCpMsgTemplate.toJson());
|
||||
return WxCpMsgTemplateAddResult.fromJson(result);
|
||||
}
|
||||
|
||||
@Override
|
||||
public WxCpUserExternalTagGroup getCorpTagList(String[] tagId) throws WxErrorException {
|
||||
JsonObject json = new JsonObject();
|
||||
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());
|
||||
return WxCpUserExternalTagGroup.fromJson(result);
|
||||
}
|
||||
|
||||
@Override
|
||||
public WxCpUserExternalTagGroup addCorpTag(WxCpUserExternalTagGroup tagGroup) throws WxErrorException{
|
||||
|
||||
final String url = this.mainService.getWxCpConfigStorage().getApiUrl(ADD_CORP_TAG);
|
||||
final String result = this.mainService.post(url,tagGroup.toJson());
|
||||
return WxCpUserExternalTagGroup.fromJson(result);
|
||||
}
|
||||
|
||||
@Override
|
||||
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);
|
||||
final String url = this.mainService.getWxCpConfigStorage().getApiUrl(EDIT_CORP_TAG);
|
||||
final String result = this.mainService.post(url,json.toString());
|
||||
return WxCpBaseResp.fromJson(result);
|
||||
}
|
||||
|
||||
@Override
|
||||
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(groupId)){
|
||||
json.add("group_id",new Gson().toJsonTree(tagId).getAsJsonArray());
|
||||
}
|
||||
|
||||
final String url = this.mainService.getWxCpConfigStorage().getApiUrl(DEL_CORP_TAG);
|
||||
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{
|
||||
|
||||
|
||||
JsonObject json = new JsonObject();
|
||||
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(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());
|
||||
return WxCpBaseResp.fromJson(result);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,69 @@
|
||||
package me.chanjar.weixin.cp.bean;
|
||||
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import me.chanjar.weixin.common.util.json.WxGsonBuilder;
|
||||
import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
public class WxCpUserExternalTagGroup extends WxCpBaseResp {
|
||||
|
||||
@SerializedName("group_id")
|
||||
private String groupId;
|
||||
|
||||
@SerializedName("group_name")
|
||||
private String groupName;
|
||||
|
||||
@SerializedName("create_time")
|
||||
private Long createTime;
|
||||
|
||||
@SerializedName("order")
|
||||
private Integer order;
|
||||
|
||||
@SerializedName("deleted")
|
||||
private Boolean deleted;
|
||||
|
||||
|
||||
@SerializedName("tag")
|
||||
private List<Tag> tag;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
public static class Tag {
|
||||
|
||||
/**
|
||||
* 客户群ID
|
||||
*/
|
||||
@SerializedName("id")
|
||||
private String id;
|
||||
|
||||
|
||||
@SerializedName("name")
|
||||
private String name;
|
||||
|
||||
@SerializedName("create_time")
|
||||
private Long createTime;
|
||||
|
||||
@SerializedName("order")
|
||||
private Integer order;
|
||||
|
||||
@SerializedName("deleted")
|
||||
private Boolean deleted;
|
||||
|
||||
}
|
||||
|
||||
public String toJson() {
|
||||
return WxGsonBuilder.create().toJson(this);
|
||||
}
|
||||
|
||||
public static WxCpUserExternalTagGroup fromJson(String json) {
|
||||
return WxCpGsonBuilder.create().fromJson(json, WxCpUserExternalTagGroup.class);
|
||||
}
|
||||
}
|
||||
@@ -132,5 +132,11 @@ public final class WxCpApiPathConsts {
|
||||
public static final String LIST_USER_BEHAVIOR_DATA = "/cgi-bin/externalcontact/get_user_behavior_data";
|
||||
public static final String LIST_GROUP_CHAT_DATA = "/cgi-bin/externalcontact/groupchat/statistic";
|
||||
public static final String ADD_MSG_TEMPLATE = "/cgi-bin/externalcontact/add_msg_template";
|
||||
|
||||
public static final String GET_CORP_TAG_LIST = "/cgi-bin/externalcontact/get_corp_tag_list";
|
||||
public static final String ADD_CORP_TAG = "/cgi-bin/externalcontact/add_corp_tag";
|
||||
public static final String EDIT_CORP_TAG = "/cgi-bin/externalcontact/edit_corp_tag";
|
||||
public static final String DEL_CORP_TAG = "/cgi-bin/externalcontact/del_corp_tag";
|
||||
public static final String MARK_TAG = "/cgi-bin/externalcontact/mark_tag";
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user