Skip to content

Commit

Permalink
🎨 #1849 企业微信外部联系人相关接口重构,优化重复代码,同时获取客户详情接口返回增加标签id字段
Browse files Browse the repository at this point in the history
  • Loading branch information
binarywang committed Nov 4, 2020
1 parent 474ce2a commit a3250c9
Show file tree
Hide file tree
Showing 14 changed files with 312 additions and 339 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
import me.chanjar.weixin.common.error.WxErrorException;
import me.chanjar.weixin.cp.bean.WxCpBaseResp;
import me.chanjar.weixin.cp.bean.external.*;
import me.chanjar.weixin.cp.bean.external.contact.WxCpExternalContactBatchInfo;
import me.chanjar.weixin.cp.bean.external.contact.WxCpExternalContactInfo;

import java.util.Date;
import java.util.List;
Expand Down Expand Up @@ -109,7 +111,7 @@ public interface WxCpExternalContactService {
* @deprecated 建议使用 {@link #getContactDetail(String)}
*/
@Deprecated
WxCpUserExternalContactInfo getExternalContact(String userId) throws WxErrorException;
WxCpExternalContactInfo getExternalContact(String userId) throws WxErrorException;

/**
* 获取客户详情.
Expand All @@ -130,7 +132,7 @@ public interface WxCpExternalContactService {
* @return . contact detail
* @throws WxErrorException .
*/
WxCpUserExternalContactInfo getContactDetail(String userId) throws WxErrorException;
WxCpExternalContactInfo getContactDetail(String userId) throws WxErrorException;

/**
* 批量获取客户详情.
Expand All @@ -153,8 +155,8 @@ public interface WxCpExternalContactService {
* @return wx cp user external contact batch info
* @throws WxErrorException .
*/
WxCpUserExternalContactBatchInfo getContactDetailBatch(String userId, String cursor,
Integer limit)
WxCpExternalContactBatchInfo getContactDetailBatch(String userId, String cursor,
Integer limit)
throws WxErrorException;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import me.chanjar.weixin.common.error.WxErrorException;
import me.chanjar.weixin.cp.bean.WxCpInviteResult;
import me.chanjar.weixin.cp.bean.WxCpUser;
import me.chanjar.weixin.cp.bean.external.WxCpUserExternalContactInfo;
import me.chanjar.weixin.cp.bean.external.contact.WxCpExternalContactInfo;

import java.util.List;
import java.util.Map;
Expand Down Expand Up @@ -167,7 +167,7 @@ public interface WxCpUserService {
* @return 联系人详情
* @throws WxErrorException .
*/
WxCpUserExternalContactInfo getExternalContact(String userId) throws WxErrorException;
WxCpExternalContactInfo getExternalContact(String userId) throws WxErrorException;


}
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
import me.chanjar.weixin.cp.api.WxCpService;
import me.chanjar.weixin.cp.bean.WxCpBaseResp;
import me.chanjar.weixin.cp.bean.external.*;
import me.chanjar.weixin.cp.bean.external.contact.WxCpExternalContactBatchInfo;
import me.chanjar.weixin.cp.bean.external.contact.WxCpExternalContactInfo;
import org.apache.commons.lang3.ArrayUtils;
import org.apache.commons.lang3.StringUtils;

Expand Down Expand Up @@ -91,23 +93,23 @@ public WxCpBaseResp closeTempChat(@NonNull String userId, @NonNull String extern
}

@Override
public WxCpUserExternalContactInfo getExternalContact(String userId) throws WxErrorException {
public WxCpExternalContactInfo getExternalContact(String userId) throws WxErrorException {
final String url = this.mainService.getWxCpConfigStorage().getApiUrl(GET_EXTERNAL_CONTACT + userId);
String responseContent = this.mainService.get(url, null);
return WxCpUserExternalContactInfo.fromJson(responseContent);
return WxCpExternalContactInfo.fromJson(responseContent);
}

@Override
public WxCpUserExternalContactInfo getContactDetail(String userId) throws WxErrorException {
public WxCpExternalContactInfo getContactDetail(String userId) throws WxErrorException {
final String url = this.mainService.getWxCpConfigStorage().getApiUrl(GET_CONTACT_DETAIL + userId);
String responseContent = this.mainService.get(url, null);
return WxCpUserExternalContactInfo.fromJson(responseContent);
return WxCpExternalContactInfo.fromJson(responseContent);
}

@Override
public WxCpUserExternalContactBatchInfo getContactDetailBatch(String userId,
String cursor,
Integer limit)
public WxCpExternalContactBatchInfo getContactDetailBatch(String userId,
String cursor,
Integer limit)
throws WxErrorException {
final String url =
this.mainService
Expand All @@ -122,7 +124,7 @@ public WxCpUserExternalContactBatchInfo getContactDetailBatch(String userId,
json.addProperty("limit", limit);
}
String responseContent = this.mainService.post(url, json.toString());
return WxCpUserExternalContactBatchInfo.fromJson(responseContent);
return WxCpExternalContactBatchInfo.fromJson(responseContent);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import me.chanjar.weixin.cp.api.WxCpUserService;
import me.chanjar.weixin.cp.bean.WxCpInviteResult;
import me.chanjar.weixin.cp.bean.WxCpUser;
import me.chanjar.weixin.cp.bean.external.WxCpUserExternalContactInfo;
import me.chanjar.weixin.cp.bean.external.contact.WxCpExternalContactInfo;
import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder;

import java.util.List;
Expand Down Expand Up @@ -193,9 +193,9 @@ public String getUserId(String mobile) throws WxErrorException {
}

@Override
public WxCpUserExternalContactInfo getExternalContact(String userId) throws WxErrorException {
public WxCpExternalContactInfo getExternalContact(String userId) throws WxErrorException {
String url = this.mainService.getWxCpConfigStorage().getApiUrl(GET_EXTERNAL_CONTACT + userId);
String responseContent = this.mainService.get(url, null);
return WxCpUserExternalContactInfo.fromJson(responseContent);
return WxCpExternalContactInfo.fromJson(responseContent);
}
}

This file was deleted.

Loading

0 comments on commit a3250c9

Please sign in to comment.