|
@@ -0,0 +1,421 @@
|
|
|
+package cn.nosum.wx.cp.api.impl;
|
|
|
+
|
|
|
+import cn.nosum.wx.common.error.WxRuntimeException;
|
|
|
+import cn.nosum.wx.common.utils.json.GsonParser;
|
|
|
+import cn.nosum.wx.cp.api.WxCpExternalContactService;
|
|
|
+import cn.nosum.wx.cp.api.WxCpService;
|
|
|
+import cn.nosum.wx.cp.entity.WxCpBaseResp;
|
|
|
+import cn.nosum.wx.cp.entity.external.*;
|
|
|
+import cn.nosum.wx.cp.entity.external.contact.WxCpExternalContactBatchInfo;
|
|
|
+import cn.nosum.wx.cp.entity.external.contact.WxCpExternalContactInfo;
|
|
|
+import com.google.gson.Gson;
|
|
|
+import com.google.gson.JsonObject;
|
|
|
+import lombok.NonNull;
|
|
|
+import lombok.RequiredArgsConstructor;
|
|
|
+import org.apache.commons.lang3.ArrayUtils;
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
+
|
|
|
+import java.util.Date;
|
|
|
+import java.util.List;
|
|
|
+
|
|
|
+import static cn.nosum.wx.cp.constant.WxCpApiPathConsts.ExternalContact.*;
|
|
|
+
|
|
|
+/**
|
|
|
+ * 外部联系人实现.
|
|
|
+ *
|
|
|
+ * @author Young
|
|
|
+ */
|
|
|
+@RequiredArgsConstructor
|
|
|
+public class WxCpExternalContactServiceImpl implements WxCpExternalContactService {
|
|
|
+
|
|
|
+ private final WxCpService mainService;
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public WxCpContactWayResult addContactWay(@NonNull WxCpContactWayInfo info) {
|
|
|
+
|
|
|
+ if (info.getContactWay().getUsers() != null && info.getContactWay().getUsers().size() > 100) {
|
|
|
+ throw new WxRuntimeException("「联系我」使用人数默认限制不超过100人(包括部门展开后的人数)");
|
|
|
+ }
|
|
|
+
|
|
|
+ final String url = this.mainService.getWxCpConfigStorage().getApiUrl(ADD_CONTACT_WAY);
|
|
|
+ String responseContent = this.mainService.post(url, info.getContactWay().toJson());
|
|
|
+
|
|
|
+ return WxCpContactWayResult.fromJson(responseContent);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public WxCpContactWayInfo getContactWay(@NonNull String configId) {
|
|
|
+ JsonObject json = new JsonObject();
|
|
|
+ json.addProperty("config_id", configId);
|
|
|
+
|
|
|
+ final String url = this.mainService.getWxCpConfigStorage().getApiUrl(GET_CONTACT_WAY);
|
|
|
+ String responseContent = this.mainService.post(url, json.toString());
|
|
|
+ return WxCpContactWayInfo.fromJson(responseContent);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public WxCpBaseResp updateContactWay(@NonNull WxCpContactWayInfo info) {
|
|
|
+ if (StringUtils.isBlank(info.getContactWay().getConfigId())) {
|
|
|
+ throw new WxRuntimeException("更新「联系我」方式需要指定configId");
|
|
|
+ }
|
|
|
+ if (info.getContactWay().getUsers() != null && info.getContactWay().getUsers().size() > 100) {
|
|
|
+ throw new WxRuntimeException("「联系我」使用人数默认限制不超过100人(包括部门展开后的人数)");
|
|
|
+ }
|
|
|
+
|
|
|
+ final String url = this.mainService.getWxCpConfigStorage().getApiUrl(UPDATE_CONTACT_WAY);
|
|
|
+ String responseContent = this.mainService.post(url, info.getContactWay().toJson());
|
|
|
+
|
|
|
+ return WxCpBaseResp.fromJson(responseContent);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public WxCpBaseResp deleteContactWay(@NonNull String configId) {
|
|
|
+ JsonObject json = new JsonObject();
|
|
|
+ json.addProperty("config_id", configId);
|
|
|
+
|
|
|
+ final String url = this.mainService.getWxCpConfigStorage().getApiUrl(DEL_CONTACT_WAY);
|
|
|
+ String responseContent = this.mainService.post(url, json.toString());
|
|
|
+
|
|
|
+ return WxCpBaseResp.fromJson(responseContent);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public WxCpBaseResp closeTempChat(@NonNull String userId, @NonNull String externalUserId) {
|
|
|
+
|
|
|
+ JsonObject json = new JsonObject();
|
|
|
+ json.addProperty("userid", userId);
|
|
|
+ json.addProperty("external_userid", externalUserId);
|
|
|
+
|
|
|
+
|
|
|
+ final String url = this.mainService.getWxCpConfigStorage().getApiUrl(CLOSE_TEMP_CHAT);
|
|
|
+ String responseContent = this.mainService.post(url, json.toString());
|
|
|
+
|
|
|
+ return WxCpBaseResp.fromJson(responseContent);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public WxCpExternalContactInfo getExternalContact(String userId) {
|
|
|
+ final String url = this.mainService.getWxCpConfigStorage().getApiUrl(GET_EXTERNAL_CONTACT + userId);
|
|
|
+ String responseContent = this.mainService.get(url, null);
|
|
|
+ return WxCpExternalContactInfo.fromJson(responseContent);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public WxCpExternalContactInfo getContactDetail(String userId) {
|
|
|
+ final String url = this.mainService.getWxCpConfigStorage().getApiUrl(GET_CONTACT_DETAIL + userId);
|
|
|
+ String responseContent = this.mainService.get(url, null);
|
|
|
+ return WxCpExternalContactInfo.fromJson(responseContent);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public String convertToOpenid(String externalUserId) {
|
|
|
+ JsonObject json = new JsonObject();
|
|
|
+ json.addProperty("external_userid", externalUserId);
|
|
|
+ final String url = this.mainService.getWxCpConfigStorage().getApiUrl(CONVERT_TO_OPENID);
|
|
|
+ String responseContent = this.mainService.post(url, json.toString());
|
|
|
+ JsonObject tmpJson = GsonParser.parse(responseContent);
|
|
|
+ return tmpJson.get("openid").getAsString();
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public String unionidToExternalUserid(String unionid) {
|
|
|
+ JsonObject json = new JsonObject();
|
|
|
+ json.addProperty("unionid", unionid);
|
|
|
+ final String url = this.mainService.getWxCpConfigStorage().getApiUrl(UNIONID_TO_EXTERNAL_USERID);
|
|
|
+ String responseContent = this.mainService.post(url, json.toString());
|
|
|
+ JsonObject tmpJson = GsonParser.parse(responseContent);
|
|
|
+ return tmpJson.get("external_userid").getAsString();
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public WxCpExternalContactBatchInfo getContactDetailBatch(String[] userIdList,
|
|
|
+ String cursor,
|
|
|
+ Integer limit) {
|
|
|
+ final String url =
|
|
|
+ this.mainService
|
|
|
+ .getWxCpConfigStorage()
|
|
|
+ .getApiUrl(GET_CONTACT_DETAIL_BATCH);
|
|
|
+ JsonObject json = new JsonObject();
|
|
|
+ json.add("userid_list", new Gson().toJsonTree(userIdList).getAsJsonArray());
|
|
|
+ if (StringUtils.isNotBlank(cursor)) {
|
|
|
+ json.addProperty("cursor", cursor);
|
|
|
+ }
|
|
|
+ if (limit != null) {
|
|
|
+ json.addProperty("limit", limit);
|
|
|
+ }
|
|
|
+ String responseContent = this.mainService.post(url, json.toString());
|
|
|
+ return WxCpExternalContactBatchInfo.fromJson(responseContent);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void updateRemark(WxCpUpdateRemarkRequest request) {
|
|
|
+ final String url = this.mainService.getWxCpConfigStorage().getApiUrl(UPDATE_REMARK);
|
|
|
+ this.mainService.post(url, request.toJson());
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public List<String> listExternalContacts(String userId) {
|
|
|
+ final String url = this.mainService.getWxCpConfigStorage().getApiUrl(LIST_EXTERNAL_CONTACT + userId);
|
|
|
+ String responseContent = this.mainService.get(url, null);
|
|
|
+ return WxCpUserExternalContactList.fromJson(responseContent).getExternalUserId();
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public List<String> listFollowers() {
|
|
|
+ final String url = this.mainService.getWxCpConfigStorage().getApiUrl(GET_FOLLOW_USER_LIST);
|
|
|
+ String responseContent = this.mainService.get(url, null);
|
|
|
+ return WxCpUserWithExternalPermission.fromJson(responseContent).getFollowers();
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public WxCpUserExternalUnassignList listUnassignedList(Integer pageIndex, Integer pageSize) {
|
|
|
+ JsonObject json = new JsonObject();
|
|
|
+ json.addProperty("page_id", pageIndex == null ? 0 : pageIndex);
|
|
|
+ json.addProperty("page_size", pageSize == null ? 100 : pageSize);
|
|
|
+ final String url = this.mainService.getWxCpConfigStorage().getApiUrl(LIST_UNASSIGNED_CONTACT);
|
|
|
+ final String result = this.mainService.post(url, json.toString());
|
|
|
+ return WxCpUserExternalUnassignList.fromJson(result);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public WxCpBaseResp transferExternalContact(String externalUserid, String handOverUserid, String takeOverUserid) {
|
|
|
+ JsonObject json = new JsonObject();
|
|
|
+ json.addProperty("external_userid", externalUserid);
|
|
|
+ json.addProperty("handover_userid", handOverUserid);
|
|
|
+ json.addProperty("takeover_userid", takeOverUserid);
|
|
|
+ final String url = this.mainService.getWxCpConfigStorage().getApiUrl(TRANSFER_UNASSIGNED_CONTACT);
|
|
|
+ final String result = this.mainService.post(url, json.toString());
|
|
|
+ return WxCpBaseResp.fromJson(result);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public WxCpUserTransferCustomerResp transferCustomer(WxCpUserTransferCustomerReq req) {
|
|
|
+ final String url = this.mainService.getWxCpConfigStorage().getApiUrl(TRANSFER_CUSTOMER);
|
|
|
+ final String result = this.mainService.post(url, req.toJson());
|
|
|
+ return WxCpUserTransferCustomerResp.fromJson(result);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public WxCpUserTransferResultResp transferResult(String handOverUserid, String takeOverUserid, String cursor) {
|
|
|
+ JsonObject json = new JsonObject();
|
|
|
+ json.addProperty("cursor", cursor);
|
|
|
+ json.addProperty("handover_userid", handOverUserid);
|
|
|
+ json.addProperty("takeover_userid", takeOverUserid);
|
|
|
+ final String url = this.mainService.getWxCpConfigStorage().getApiUrl(TRANSFER_RESULT);
|
|
|
+ final String result = this.mainService.post(url, json.toString());
|
|
|
+ return WxCpUserTransferResultResp.fromJson(result);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public WxCpUserTransferCustomerResp resignedTransferCustomer(WxCpUserTransferCustomerReq req) {
|
|
|
+ final String url = this.mainService.getWxCpConfigStorage().getApiUrl(RESIGNED_TRANSFER_CUSTOMER);
|
|
|
+ final String result = this.mainService.post(url, req.toJson());
|
|
|
+ return WxCpUserTransferCustomerResp.fromJson(result);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public WxCpUserTransferResultResp resignedTransferResult(String handOverUserid, String takeOverUserid, String cursor) {
|
|
|
+ JsonObject json = new JsonObject();
|
|
|
+ json.addProperty("cursor", cursor);
|
|
|
+ json.addProperty("handover_userid", handOverUserid);
|
|
|
+ json.addProperty("takeover_userid", takeOverUserid);
|
|
|
+ final String url = this.mainService.getWxCpConfigStorage().getApiUrl(RESIGNED_TRANSFER_RESULT);
|
|
|
+ final String result = this.mainService.post(url, json.toString());
|
|
|
+ return WxCpUserTransferResultResp.fromJson(result);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public WxCpUserExternalGroupChatList listGroupChat(Integer pageIndex, Integer pageSize, int status, String[] userIds, String[] partyIds) {
|
|
|
+ JsonObject json = new JsonObject();
|
|
|
+ json.addProperty("offset", pageIndex == null ? 0 : pageIndex);
|
|
|
+ json.addProperty("limit", pageSize == null ? 100 : pageSize);
|
|
|
+ json.addProperty("status_filter", status);
|
|
|
+ if (ArrayUtils.isNotEmpty(userIds) || ArrayUtils.isNotEmpty(partyIds)) {
|
|
|
+ JsonObject ownerFilter = new JsonObject();
|
|
|
+ if (ArrayUtils.isNotEmpty(userIds)) {
|
|
|
+ ownerFilter.add("userid_list", new Gson().toJsonTree(userIds).getAsJsonArray());
|
|
|
+ }
|
|
|
+ if (ArrayUtils.isNotEmpty(partyIds)) {
|
|
|
+ ownerFilter.add("partyid_list", new Gson().toJsonTree(partyIds).getAsJsonArray());
|
|
|
+ }
|
|
|
+ json.add("owner_filter", ownerFilter);
|
|
|
+ }
|
|
|
+ final String url = this.mainService.getWxCpConfigStorage().getApiUrl(GROUP_CHAT_LIST);
|
|
|
+ final String result = this.mainService.post(url, json.toString());
|
|
|
+ return WxCpUserExternalGroupChatList.fromJson(result);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public WxCpUserExternalGroupChatList listGroupChat(Integer limit, String cursor, int status, String[] userIds) {
|
|
|
+ JsonObject json = new JsonObject();
|
|
|
+ json.addProperty("cursor", cursor == null ? "" : cursor);
|
|
|
+ json.addProperty("limit", limit == null ? 100 : limit);
|
|
|
+ json.addProperty("status_filter", status);
|
|
|
+ if (ArrayUtils.isNotEmpty(userIds)) {
|
|
|
+ JsonObject ownerFilter = new JsonObject();
|
|
|
+ if (ArrayUtils.isNotEmpty(userIds)) {
|
|
|
+ ownerFilter.add("userid_list", new Gson().toJsonTree(userIds).getAsJsonArray());
|
|
|
+ }
|
|
|
+ json.add("owner_filter", ownerFilter);
|
|
|
+ }
|
|
|
+ final String url = this.mainService.getWxCpConfigStorage().getApiUrl(GROUP_CHAT_LIST);
|
|
|
+ final String result = this.mainService.post(url, json.toString());
|
|
|
+ return WxCpUserExternalGroupChatList.fromJson(result);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public WxCpUserExternalGroupChatInfo getGroupChat(String chatId, Integer needName) {
|
|
|
+ JsonObject json = new JsonObject();
|
|
|
+ json.addProperty("chat_id", chatId);
|
|
|
+ json.addProperty("need_name", needName);
|
|
|
+ final String url = this.mainService.getWxCpConfigStorage().getApiUrl(GROUP_CHAT_INFO);
|
|
|
+ final String result = this.mainService.post(url, json.toString());
|
|
|
+ return WxCpUserExternalGroupChatInfo.fromJson(result);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public WxCpUserExternalGroupChatTransferResp transferGroupChat(String[] chatIds, String newOwner) {
|
|
|
+ JsonObject json = new JsonObject();
|
|
|
+ if (ArrayUtils.isNotEmpty(chatIds)) {
|
|
|
+ json.add("chat_id_list", new Gson().toJsonTree(chatIds).getAsJsonArray());
|
|
|
+ }
|
|
|
+ json.addProperty("new_owner", newOwner);
|
|
|
+ final String url = this.mainService.getWxCpConfigStorage().getApiUrl(GROUP_CHAT_TRANSFER);
|
|
|
+ final String result = this.mainService.post(url, json.toString());
|
|
|
+ return WxCpUserExternalGroupChatTransferResp.fromJson(result);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public WxCpUserExternalUserBehaviorStatistic getUserBehaviorStatistic(Date startTime, Date endTime, String[] userIds, String[] partyIds) {
|
|
|
+ JsonObject json = new JsonObject();
|
|
|
+ json.addProperty("start_time", startTime.getTime() / 1000);
|
|
|
+ json.addProperty("end_time", endTime.getTime() / 1000);
|
|
|
+ if (ArrayUtils.isNotEmpty(userIds) || ArrayUtils.isNotEmpty(partyIds)) {
|
|
|
+ if (ArrayUtils.isNotEmpty(userIds)) {
|
|
|
+ json.add("userid", new Gson().toJsonTree(userIds).getAsJsonArray());
|
|
|
+ }
|
|
|
+ if (ArrayUtils.isNotEmpty(partyIds)) {
|
|
|
+ json.add("partyid", new Gson().toJsonTree(partyIds).getAsJsonArray());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ final String url = this.mainService.getWxCpConfigStorage().getApiUrl(LIST_USER_BEHAVIOR_DATA);
|
|
|
+ final String result = this.mainService.post(url, json.toString());
|
|
|
+ return WxCpUserExternalUserBehaviorStatistic.fromJson(result);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public WxCpUserExternalGroupChatStatistic getGroupChatStatistic(Date startTime, Integer orderBy, Integer orderAsc, Integer pageIndex, Integer pageSize, String[] userIds, String[] partyIds) {
|
|
|
+ JsonObject json = new JsonObject();
|
|
|
+ json.addProperty("day_begin_time", startTime.getTime() / 1000);
|
|
|
+ json.addProperty("order_by", orderBy == null ? 1 : orderBy);
|
|
|
+ json.addProperty("order_asc", orderAsc == null ? 0 : orderAsc);
|
|
|
+ json.addProperty("offset", pageIndex == null ? 0 : pageIndex);
|
|
|
+ json.addProperty("limit", pageSize == null ? 500 : pageSize);
|
|
|
+ if (ArrayUtils.isNotEmpty(userIds) || ArrayUtils.isNotEmpty(partyIds)) {
|
|
|
+ JsonObject ownerFilter = new JsonObject();
|
|
|
+ if (ArrayUtils.isNotEmpty(userIds)) {
|
|
|
+ ownerFilter.add("userid_list", new Gson().toJsonTree(userIds).getAsJsonArray());
|
|
|
+ }
|
|
|
+ if (ArrayUtils.isNotEmpty(partyIds)) {
|
|
|
+ ownerFilter.add("partyid_list", new Gson().toJsonTree(partyIds).getAsJsonArray());
|
|
|
+ }
|
|
|
+ json.add("owner_filter", ownerFilter);
|
|
|
+ }
|
|
|
+ final String url = this.mainService.getWxCpConfigStorage().getApiUrl(LIST_GROUP_CHAT_DATA);
|
|
|
+ final String result = this.mainService.post(url, json.toString());
|
|
|
+ return WxCpUserExternalGroupChatStatistic.fromJson(result);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public WxCpMsgTemplateAddResult addMsgTemplate(WxCpMsgTemplate wxCpMsgTemplate) {
|
|
|
+ final String url = this.mainService.getWxCpConfigStorage().getApiUrl(ADD_MSG_TEMPLATE);
|
|
|
+ final String result = this.mainService.post(url, wxCpMsgTemplate.toJson());
|
|
|
+ return WxCpMsgTemplateAddResult.fromJson(result);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void sendWelcomeMsg(WxCpWelcomeMsg msg) {
|
|
|
+ final String url = this.mainService.getWxCpConfigStorage().getApiUrl(SEND_WELCOME_MSG);
|
|
|
+ this.mainService.post(url, msg.toJson());
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public WxCpUserExternalTagGroupList getCorpTagList(String[] tagId) {
|
|
|
+ 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 WxCpUserExternalTagGroupList.fromJson(result);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public WxCpUserExternalTagGroupList getCorpTagList(String[] tagId, String[] groupId) {
|
|
|
+ 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(groupId).getAsJsonArray());
|
|
|
+ }
|
|
|
+ final String url = this.mainService.getWxCpConfigStorage().getApiUrl(GET_CORP_TAG_LIST);
|
|
|
+ final String result = this.mainService.post(url, json.toString());
|
|
|
+ return WxCpUserExternalTagGroupList.fromJson(result);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public WxCpUserExternalTagGroupInfo addCorpTag(WxCpUserExternalTagGroupInfo tagGroup) {
|
|
|
+
|
|
|
+ final String url = this.mainService.getWxCpConfigStorage().getApiUrl(ADD_CORP_TAG);
|
|
|
+ final String result = this.mainService.post(url, tagGroup.getTagGroup().toJson());
|
|
|
+ return WxCpUserExternalTagGroupInfo.fromJson(result);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public WxCpBaseResp editCorpTag(String id, String name, Integer order) {
|
|
|
+
|
|
|
+ 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) {
|
|
|
+ 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(groupId).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) {
|
|
|
+
|
|
|
+
|
|
|
+ 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);
|
|
|
+ }
|
|
|
+}
|