mirror of
https://gitee.com/binary/weixin-java-tools.git
synced 2025-06-28 13:16:19 +08:00
🎨 #1849 企业微信外部联系人相关接口重构,优化重复代码,同时获取客户详情接口返回增加标签id字段
This commit is contained in:
parent
474ce2aa7a
commit
a3250c9865
@ -4,6 +4,8 @@ import lombok.NonNull;
|
||||
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;
|
||||
@ -109,7 +111,7 @@ public interface WxCpExternalContactService {
|
||||
* @deprecated 建议使用 {@link #getContactDetail(String)}
|
||||
*/
|
||||
@Deprecated
|
||||
WxCpUserExternalContactInfo getExternalContact(String userId) throws WxErrorException;
|
||||
WxCpExternalContactInfo getExternalContact(String userId) throws WxErrorException;
|
||||
|
||||
/**
|
||||
* 获取客户详情.
|
||||
@ -130,7 +132,7 @@ public interface WxCpExternalContactService {
|
||||
* @return . contact detail
|
||||
* @throws WxErrorException .
|
||||
*/
|
||||
WxCpUserExternalContactInfo getContactDetail(String userId) throws WxErrorException;
|
||||
WxCpExternalContactInfo getContactDetail(String userId) throws WxErrorException;
|
||||
|
||||
/**
|
||||
* 批量获取客户详情.
|
||||
@ -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;
|
||||
|
||||
/**
|
||||
|
@ -3,7 +3,7 @@ package me.chanjar.weixin.cp.api;
|
||||
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;
|
||||
@ -167,7 +167,7 @@ public interface WxCpUserService {
|
||||
* @return 联系人详情
|
||||
* @throws WxErrorException .
|
||||
*/
|
||||
WxCpUserExternalContactInfo getExternalContact(String userId) throws WxErrorException;
|
||||
WxCpExternalContactInfo getExternalContact(String userId) throws WxErrorException;
|
||||
|
||||
|
||||
}
|
||||
|
@ -11,6 +11,8 @@ import me.chanjar.weixin.cp.api.WxCpExternalContactService;
|
||||
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;
|
||||
|
||||
@ -91,23 +93,23 @@ public class WxCpExternalContactServiceImpl implements WxCpExternalContactServic
|
||||
}
|
||||
|
||||
@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
|
||||
@ -122,7 +124,7 @@ public class WxCpExternalContactServiceImpl implements WxCpExternalContactServic
|
||||
json.addProperty("limit", limit);
|
||||
}
|
||||
String responseContent = this.mainService.post(url, json.toString());
|
||||
return WxCpUserExternalContactBatchInfo.fromJson(responseContent);
|
||||
return WxCpExternalContactBatchInfo.fromJson(responseContent);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -10,7 +10,7 @@ import me.chanjar.weixin.cp.api.WxCpService;
|
||||
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;
|
||||
@ -193,9 +193,9 @@ public class WxCpUserServiceImpl implements WxCpUserService {
|
||||
}
|
||||
|
||||
@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);
|
||||
}
|
||||
}
|
||||
|
@ -1,163 +0,0 @@
|
||||
package me.chanjar.weixin.cp.bean.external;
|
||||
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
import me.chanjar.weixin.cp.bean.WxCpBaseResp;
|
||||
import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder;
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 批量获取客户详情
|
||||
* Created by Binary Wang on 2020/10/22.
|
||||
* 参考文档:https://work.weixin.qq.com/api/doc/90000/90135/92994
|
||||
* </pre>
|
||||
*
|
||||
* @author <a href="https://github.com/alucardxh">alucardxh</a>
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
public class WxCpUserExternalContactBatchInfo extends WxCpBaseResp implements Serializable {
|
||||
private static final long serialVersionUID = -5166048319463473186L;
|
||||
|
||||
@SerializedName("external_contact_list")
|
||||
private List<ExternalContactInfo> externalContactList;
|
||||
|
||||
@SerializedName("next_cursor")
|
||||
private String nextCursor;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
public static class ExternalContactInfo {
|
||||
@SerializedName("external_contact")
|
||||
private ExternalContact externalContact;
|
||||
|
||||
@SerializedName("follow_info")
|
||||
private FollowedUser followInfo;
|
||||
}
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
public static class ExternalContact {
|
||||
@SerializedName("external_userid")
|
||||
private String externalUserId;
|
||||
|
||||
@SerializedName("position")
|
||||
private String position;
|
||||
|
||||
@SerializedName("name")
|
||||
private String name;
|
||||
|
||||
@SerializedName("avatar")
|
||||
private String avatar;
|
||||
|
||||
@SerializedName("corp_name")
|
||||
private String corpName;
|
||||
|
||||
@SerializedName("corp_full_name")
|
||||
private String corpFullName;
|
||||
|
||||
@SerializedName("type")
|
||||
private Integer type;
|
||||
|
||||
@SerializedName("gender")
|
||||
private Integer gender;
|
||||
|
||||
@SerializedName("unionid")
|
||||
private String unionId;
|
||||
|
||||
@SerializedName("external_profile")
|
||||
private ExternalProfile externalProfile;
|
||||
}
|
||||
|
||||
@Setter
|
||||
@Getter
|
||||
public static class ExternalProfile {
|
||||
@SerializedName("external_attr")
|
||||
private List<ExternalAttribute> externalAttrs;
|
||||
}
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public static class ExternalAttribute {
|
||||
@Setter
|
||||
@Getter
|
||||
public static class Text {
|
||||
private String value;
|
||||
}
|
||||
|
||||
@Setter
|
||||
@Getter
|
||||
public static class Web {
|
||||
private String title;
|
||||
private String url;
|
||||
}
|
||||
|
||||
@Setter
|
||||
@Getter
|
||||
public static class MiniProgram {
|
||||
@SerializedName("pagepath")
|
||||
private String pagePath;
|
||||
private String appid;
|
||||
private String title;
|
||||
}
|
||||
|
||||
private int type;
|
||||
|
||||
private String name;
|
||||
|
||||
private Text text;
|
||||
|
||||
private Web web;
|
||||
|
||||
@SerializedName("miniprogram")
|
||||
private MiniProgram miniProgram;
|
||||
}
|
||||
|
||||
@Setter
|
||||
@Getter
|
||||
public static class FollowedUser {
|
||||
@SerializedName("userid")
|
||||
private String userId;
|
||||
private String remark;
|
||||
private String description;
|
||||
@SerializedName("createtime")
|
||||
private Long createTime;
|
||||
private String state;
|
||||
@SerializedName("remark_company")
|
||||
private String remarkCompany;
|
||||
@SerializedName("remark_mobiles")
|
||||
private String[] remarkMobiles;
|
||||
private Tag[] tags;
|
||||
@SerializedName("remark_corp_name")
|
||||
private String remarkCorpName;
|
||||
@SerializedName("add_way")
|
||||
private String addWay;
|
||||
@SerializedName("oper_userid")
|
||||
private String operUserId;
|
||||
|
||||
}
|
||||
|
||||
public static WxCpUserExternalContactBatchInfo fromJson(String json) {
|
||||
return WxCpGsonBuilder.create().fromJson(json, WxCpUserExternalContactBatchInfo.class);
|
||||
}
|
||||
|
||||
@Setter
|
||||
@Getter
|
||||
public static class Tag {
|
||||
@SerializedName("group_name")
|
||||
private String groupName;
|
||||
@SerializedName("tag_name")
|
||||
private String tagName;
|
||||
private int type;
|
||||
}
|
||||
|
||||
}
|
@ -1,144 +0,0 @@
|
||||
package me.chanjar.weixin.cp.bean.external;
|
||||
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
import lombok.*;
|
||||
import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 外部联系人详情
|
||||
* Created by Binary Wang on 2018/9/16.
|
||||
* 参考文档:https://work.weixin.qq.com/api/doc#13878
|
||||
* </pre>
|
||||
*
|
||||
* @author <a href="https://github.com/binarywang">Binary Wang</a>
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
public class WxCpUserExternalContactInfo {
|
||||
@SerializedName("external_contact")
|
||||
private ExternalContact externalContact;
|
||||
|
||||
@SerializedName("follow_user")
|
||||
private List<FollowedUser> followedUsers;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
public static class ExternalContact {
|
||||
@SerializedName("external_userid")
|
||||
private String externalUserId;
|
||||
|
||||
@SerializedName("position")
|
||||
private String position;
|
||||
|
||||
@SerializedName("name")
|
||||
private String name;
|
||||
|
||||
@SerializedName("avatar")
|
||||
private String avatar;
|
||||
|
||||
@SerializedName("corp_name")
|
||||
private String corpName;
|
||||
|
||||
@SerializedName("corp_full_name")
|
||||
private String corpFullName;
|
||||
|
||||
@SerializedName("type")
|
||||
private Integer type;
|
||||
|
||||
@SerializedName("gender")
|
||||
private Integer gender;
|
||||
|
||||
@SerializedName("unionid")
|
||||
private String unionId;
|
||||
|
||||
@SerializedName("external_profile")
|
||||
private ExternalProfile externalProfile;
|
||||
}
|
||||
|
||||
@Setter
|
||||
@Getter
|
||||
public static class ExternalProfile {
|
||||
@SerializedName("external_attr")
|
||||
private List<ExternalAttribute> externalAttrs;
|
||||
}
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public static class ExternalAttribute {
|
||||
@Setter
|
||||
@Getter
|
||||
public static class Text {
|
||||
private String value;
|
||||
}
|
||||
|
||||
@Setter
|
||||
@Getter
|
||||
public static class Web {
|
||||
private String title;
|
||||
private String url;
|
||||
}
|
||||
|
||||
@Setter
|
||||
@Getter
|
||||
public static class MiniProgram {
|
||||
@SerializedName("pagepath")
|
||||
private String pagePath;
|
||||
private String appid;
|
||||
private String title;
|
||||
}
|
||||
|
||||
private int type;
|
||||
|
||||
private String name;
|
||||
|
||||
private Text text;
|
||||
|
||||
private Web web;
|
||||
|
||||
@SerializedName("miniprogram")
|
||||
private MiniProgram miniProgram;
|
||||
}
|
||||
|
||||
@Setter
|
||||
@Getter
|
||||
public static class FollowedUser {
|
||||
@SerializedName("userid")
|
||||
private String userId;
|
||||
private String remark;
|
||||
private String description;
|
||||
@SerializedName("createtime")
|
||||
private Long createTime;
|
||||
private String state;
|
||||
@SerializedName("remark_company")
|
||||
private String remarkCompany;
|
||||
@SerializedName("remark_mobiles")
|
||||
private String[] remarkMobiles;
|
||||
private Tag[] tags;
|
||||
@SerializedName("remark_corp_name")
|
||||
private String remarkCorpName;
|
||||
@SerializedName("add_way")
|
||||
private String addWay;
|
||||
@SerializedName("oper_userid")
|
||||
private String operUserId;
|
||||
|
||||
}
|
||||
|
||||
public static WxCpUserExternalContactInfo fromJson(String json) {
|
||||
return WxCpGsonBuilder.create().fromJson(json, WxCpUserExternalContactInfo.class);
|
||||
}
|
||||
|
||||
@Setter
|
||||
@Getter
|
||||
public static class Tag {
|
||||
@SerializedName("group_name")
|
||||
private String groupName;
|
||||
@SerializedName("tag_name")
|
||||
private String tagName;
|
||||
private int type;
|
||||
}
|
||||
}
|
103
weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/external/contact/ExternalContact.java
vendored
Normal file
103
weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/external/contact/ExternalContact.java
vendored
Normal file
@ -0,0 +1,103 @@
|
||||
package me.chanjar.weixin.cp.bean.external.contact;
|
||||
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
import lombok.*;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 外部联系人.
|
||||
*
|
||||
* @author <a href="https://github.com/binarywang">Binary Wang</a>
|
||||
* @date 2020-11-04
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
public class ExternalContact implements Serializable {
|
||||
private static final long serialVersionUID = -1049085217436072418L;
|
||||
|
||||
@SerializedName("external_userid")
|
||||
private String externalUserId;
|
||||
|
||||
@SerializedName("position")
|
||||
private String position;
|
||||
|
||||
@SerializedName("name")
|
||||
private String name;
|
||||
|
||||
@SerializedName("avatar")
|
||||
private String avatar;
|
||||
|
||||
@SerializedName("corp_name")
|
||||
private String corpName;
|
||||
|
||||
@SerializedName("corp_full_name")
|
||||
private String corpFullName;
|
||||
|
||||
@SerializedName("type")
|
||||
private Integer type;
|
||||
|
||||
@SerializedName("gender")
|
||||
private Integer gender;
|
||||
|
||||
@SerializedName("unionid")
|
||||
private String unionId;
|
||||
|
||||
@SerializedName("external_profile")
|
||||
private ExternalProfile externalProfile;
|
||||
|
||||
@Data
|
||||
public static class ExternalProfile implements Serializable {
|
||||
private static final long serialVersionUID = -2899906589789022765L;
|
||||
|
||||
@SerializedName("external_attr")
|
||||
private List<ExternalAttribute> externalAttrs;
|
||||
}
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public static class ExternalAttribute implements Serializable {
|
||||
private static final long serialVersionUID = -1262278808286421085L;
|
||||
|
||||
private int type;
|
||||
|
||||
private String name;
|
||||
|
||||
private Text text;
|
||||
|
||||
private Web web;
|
||||
|
||||
@SerializedName("miniprogram")
|
||||
private MiniProgram miniProgram;
|
||||
|
||||
@Data
|
||||
public static class Text implements Serializable {
|
||||
private static final long serialVersionUID = -8161579335600269094L;
|
||||
|
||||
private String value;
|
||||
}
|
||||
|
||||
@Data
|
||||
public static class Web implements Serializable {
|
||||
private static final long serialVersionUID = 3664557135411521862L;
|
||||
|
||||
private String title;
|
||||
private String url;
|
||||
}
|
||||
|
||||
@Data
|
||||
public static class MiniProgram implements Serializable {
|
||||
private static final long serialVersionUID = -5329210594501835796L;
|
||||
|
||||
@SerializedName("pagepath")
|
||||
private String pagePath;
|
||||
|
||||
private String appid;
|
||||
|
||||
private String title;
|
||||
}
|
||||
}
|
||||
}
|
81
weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/external/contact/FollowedUser.java
vendored
Normal file
81
weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/external/contact/FollowedUser.java
vendored
Normal file
@ -0,0 +1,81 @@
|
||||
package me.chanjar.weixin.cp.bean.external.contact;
|
||||
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 添加了外部联系人的企业成员.
|
||||
*
|
||||
* @author <a href="https://github.com/binarywang">Binary Wang</a>
|
||||
* @date 2020-11-04
|
||||
*/
|
||||
@Data
|
||||
public class FollowedUser {
|
||||
@SerializedName("userid")
|
||||
private String userId;
|
||||
|
||||
private String remark;
|
||||
|
||||
private String description;
|
||||
|
||||
@SerializedName("createtime")
|
||||
private Long createTime;
|
||||
|
||||
private String state;
|
||||
|
||||
@SerializedName("remark_company")
|
||||
private String remarkCompany;
|
||||
|
||||
@SerializedName("remark_mobiles")
|
||||
private String[] remarkMobiles;
|
||||
|
||||
/**
|
||||
* 批量获取客户详情 接口专用
|
||||
*/
|
||||
@SerializedName("tag_id")
|
||||
private String[] tagIds;
|
||||
|
||||
/**
|
||||
* 获取客户详情 接口专用
|
||||
*/
|
||||
private Tag[] tags;
|
||||
|
||||
@SerializedName("remark_corp_name")
|
||||
private String remarkCorpName;
|
||||
|
||||
@SerializedName("add_way")
|
||||
private String addWay;
|
||||
|
||||
@SerializedName("oper_userid")
|
||||
private String operatorUserId;
|
||||
|
||||
@Data
|
||||
public static class Tag implements Serializable {
|
||||
private static final long serialVersionUID = -7556237053703295482L;
|
||||
|
||||
/**
|
||||
* 该成员添加此外部联系人所打标签的分组名称(标签功能需要企业微信升级到2.7.5及以上版本)
|
||||
*/
|
||||
@SerializedName("group_name")
|
||||
private String groupName;
|
||||
|
||||
/**
|
||||
* 该成员添加此外部联系人所打标签名称
|
||||
*/
|
||||
@SerializedName("tag_name")
|
||||
private String tagName;
|
||||
|
||||
/**
|
||||
* 该成员添加此外部联系人所打企业标签的id,仅企业设置(type为1)的标签返回
|
||||
*/
|
||||
@SerializedName("tag_id")
|
||||
private String tagId;
|
||||
|
||||
/**
|
||||
* 该成员添加此外部联系人所打标签类型, 1-企业设置, 2-用户自定义
|
||||
*/
|
||||
private int type;
|
||||
}
|
||||
}
|
@ -0,0 +1,48 @@
|
||||
package me.chanjar.weixin.cp.bean.external.contact;
|
||||
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import me.chanjar.weixin.cp.bean.WxCpBaseResp;
|
||||
import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 批量获取客户详情
|
||||
* 参考文档:https://work.weixin.qq.com/api/doc/90000/90135/92994
|
||||
* </pre>
|
||||
*
|
||||
* @author <a href="https://github.com/alucardxh">alucardxh</a>
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
public class WxCpExternalContactBatchInfo extends WxCpBaseResp implements Serializable {
|
||||
private static final long serialVersionUID = -5166048319463473186L;
|
||||
|
||||
@SerializedName("external_contact_list")
|
||||
private List<ExternalContactInfo> externalContactList;
|
||||
|
||||
@SerializedName("next_cursor")
|
||||
private String nextCursor;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
public static class ExternalContactInfo implements Serializable {
|
||||
private static final long serialVersionUID = 4723983768235723206L;
|
||||
|
||||
@SerializedName("external_contact")
|
||||
private ExternalContact externalContact;
|
||||
|
||||
@SerializedName("follow_info")
|
||||
private FollowedUser followInfo;
|
||||
}
|
||||
|
||||
|
||||
public static WxCpExternalContactBatchInfo fromJson(String json) {
|
||||
return WxCpGsonBuilder.create().fromJson(json, WxCpExternalContactBatchInfo.class);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,33 @@
|
||||
package me.chanjar.weixin.cp.bean.external.contact;
|
||||
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
import lombok.*;
|
||||
import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 外部联系人详情
|
||||
* Created by Binary Wang on 2018/9/16.
|
||||
* 参考文档:https://work.weixin.qq.com/api/doc#13878
|
||||
* </pre>
|
||||
*
|
||||
* @author <a href="https://github.com/binarywang">Binary Wang</a>
|
||||
*/
|
||||
@Data
|
||||
public class WxCpExternalContactInfo implements Serializable {
|
||||
private static final long serialVersionUID = 4311777322534499260L;
|
||||
|
||||
@SerializedName("external_contact")
|
||||
private ExternalContact externalContact;
|
||||
|
||||
@SerializedName("follow_user")
|
||||
private List<FollowedUser> followedUsers;
|
||||
|
||||
public static WxCpExternalContactInfo fromJson(String json) {
|
||||
return WxCpGsonBuilder.create().fromJson(json, WxCpExternalContactInfo.class);
|
||||
}
|
||||
|
||||
}
|
@ -315,6 +315,7 @@ public class WxCpConsts {
|
||||
public static final String MARKDOWN = "markdown";
|
||||
}
|
||||
|
||||
@UtilityClass
|
||||
public static class WorkBenchType {
|
||||
/*
|
||||
* 关键数据型
|
||||
|
@ -5,14 +5,11 @@ import me.chanjar.weixin.common.api.WxErrorExceptionHandler;
|
||||
import me.chanjar.weixin.common.error.WxErrorException;
|
||||
import me.chanjar.weixin.common.session.WxSessionManager;
|
||||
import me.chanjar.weixin.cp.bean.message.WxCpTpXmlMessage;
|
||||
import me.chanjar.weixin.cp.bean.message.WxCpXmlMessage;
|
||||
import me.chanjar.weixin.cp.bean.message.WxCpXmlOutMessage;
|
||||
import me.chanjar.weixin.cp.message.WxCpMessageMatcher;
|
||||
import me.chanjar.weixin.cp.tp.service.WxCpTpService;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
/**
|
||||
* The type Wx cp message router rule.
|
||||
@ -57,6 +54,16 @@ public class WxCpTpMessageRouterRule {
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 匹配 Message infoType
|
||||
*
|
||||
* @param infoType info
|
||||
*/
|
||||
public WxCpTpMessageRouterRule infoType(String infoType) {
|
||||
this.infoType = infoType;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 如果消息匹配某个matcher,用在用户需要自定义更复杂的匹配规则的时候
|
||||
*
|
||||
|
@ -7,6 +7,7 @@ import me.chanjar.weixin.cp.api.ApiTestModule;
|
||||
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.WxCpExternalContactInfo;
|
||||
import org.apache.commons.lang3.time.DateFormatUtils;
|
||||
import org.testng.annotations.Guice;
|
||||
import org.testng.annotations.Test;
|
||||
@ -28,7 +29,7 @@ public class WxCpExternalContactServiceImplTest {
|
||||
@Test
|
||||
public void testGetExternalContact() throws WxErrorException {
|
||||
String externalUserId = this.configStorage.getExternalUserId();
|
||||
WxCpUserExternalContactInfo result = this.wxCpService.getExternalContactService().getExternalContact(externalUserId);
|
||||
WxCpExternalContactInfo result = this.wxCpService.getExternalContactService().getExternalContact(externalUserId);
|
||||
System.out.println(result);
|
||||
assertNotNull(result);
|
||||
}
|
||||
@ -105,7 +106,7 @@ public class WxCpExternalContactServiceImplTest {
|
||||
@Test
|
||||
public void testGetContactDetail() throws WxErrorException {
|
||||
String externalUserId = this.configStorage.getExternalUserId();
|
||||
WxCpUserExternalContactInfo result = this.wxCpService.getExternalContactService().getContactDetail(externalUserId);
|
||||
WxCpExternalContactInfo result = this.wxCpService.getExternalContactService().getContactDetail(externalUserId);
|
||||
System.out.println(result);
|
||||
assertNotNull(result);
|
||||
}
|
||||
|
@ -1,10 +1,12 @@
|
||||
package me.chanjar.weixin.cp.bean;
|
||||
package me.chanjar.weixin.cp.bean.external;
|
||||
|
||||
import me.chanjar.weixin.cp.bean.external.contact.ExternalContact;
|
||||
import me.chanjar.weixin.cp.bean.external.contact.FollowedUser;
|
||||
import me.chanjar.weixin.cp.bean.external.contact.WxCpExternalContactInfo;
|
||||
import org.testng.annotations.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import me.chanjar.weixin.cp.bean.external.WxCpUserExternalContactInfo;
|
||||
import org.testng.annotations.*;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
/**
|
||||
@ -77,7 +79,7 @@ public class WxCpUserExternalContactInfoTest {
|
||||
" ]\n" +
|
||||
"}";
|
||||
|
||||
final WxCpUserExternalContactInfo contactInfo = WxCpUserExternalContactInfo.fromJson(json);
|
||||
final WxCpExternalContactInfo contactInfo = WxCpExternalContactInfo.fromJson(json);
|
||||
assertThat(contactInfo).isNotNull();
|
||||
assertThat(contactInfo.getExternalContact()).isNotNull();
|
||||
|
||||
@ -93,21 +95,21 @@ public class WxCpUserExternalContactInfoTest {
|
||||
|
||||
assertThat(contactInfo.getExternalContact().getExternalProfile()).isNotNull();
|
||||
|
||||
final List<WxCpUserExternalContactInfo.ExternalAttribute> externalAttrs = contactInfo.getExternalContact().getExternalProfile().getExternalAttrs();
|
||||
final List<ExternalContact.ExternalAttribute> externalAttrs = contactInfo.getExternalContact().getExternalProfile().getExternalAttrs();
|
||||
assertThat(externalAttrs).isNotEmpty();
|
||||
|
||||
final WxCpUserExternalContactInfo.ExternalAttribute externalAttr1 = externalAttrs.get(0);
|
||||
final ExternalContact.ExternalAttribute externalAttr1 = externalAttrs.get(0);
|
||||
assertThat(externalAttr1.getType()).isEqualTo(0);
|
||||
assertThat(externalAttr1.getName()).isEqualTo("文本名称");
|
||||
assertThat(externalAttr1.getText().getValue()).isEqualTo("文本");
|
||||
|
||||
final WxCpUserExternalContactInfo.ExternalAttribute externalAttr2 = externalAttrs.get(1);
|
||||
final ExternalContact.ExternalAttribute externalAttr2 = externalAttrs.get(1);
|
||||
assertThat(externalAttr2.getType()).isEqualTo(1);
|
||||
assertThat(externalAttr2.getName()).isEqualTo("网页名称");
|
||||
assertThat(externalAttr2.getWeb().getUrl()).isEqualTo("http://www.test.com");
|
||||
assertThat(externalAttr2.getWeb().getTitle()).isEqualTo("标题");
|
||||
|
||||
final WxCpUserExternalContactInfo.ExternalAttribute externalAttr3 = externalAttrs.get(2);
|
||||
final ExternalContact.ExternalAttribute externalAttr3 = externalAttrs.get(2);
|
||||
assertThat(externalAttr3.getType()).isEqualTo(2);
|
||||
assertThat(externalAttr3.getName()).isEqualTo("测试app");
|
||||
assertThat(externalAttr3.getMiniProgram().getAppid()).isEqualTo("wx8bd80126147df384");
|
||||
@ -115,7 +117,7 @@ public class WxCpUserExternalContactInfoTest {
|
||||
assertThat(externalAttr3.getMiniProgram().getTitle()).isEqualTo("my miniprogram");
|
||||
|
||||
|
||||
List<WxCpUserExternalContactInfo.FollowedUser> followedUsers = contactInfo.getFollowedUsers();
|
||||
List<FollowedUser> followedUsers = contactInfo.getFollowedUsers();
|
||||
assertThat(followedUsers).isNotEmpty();
|
||||
assertThat(followedUsers.get(0).getUserId()).isEqualTo("rocky");
|
||||
assertThat(followedUsers.get(0).getRemark()).isEqualTo("李部长");
|
Loading…
Reference in New Issue
Block a user