diff --git a/.gitignore b/.gitignore index 0cbb1bd..ad1c45a 100644 --- a/.gitignore +++ b/.gitignore @@ -48,4 +48,5 @@ yarn.lock ### Cloudflare ### .wrangler/ .dev.vars -wrangler.toml.local \ No newline at end of file +wrangler.toml.local +/src/test/resources/app.properties diff --git a/docs/guide/sns.md b/docs/guide/sns.md index a4a1b4e..aca1710 100644 --- a/docs/guide/sns.md +++ b/docs/guide/sns.md @@ -283,3 +283,83 @@ GroupGetRequest request = GroupGetRequest.builder() GroupGetResult result = client.sns.groupGet(request); ``` + +## 关注用户 + +关注用户,支持批量关注用户。 + +使用示例: + +```java +FollowRequestItem followRequestItem = FollowRequestItem.builder().toAccount("test2").build(); +List followRequestItemList = Collections.singletonList(followRequestItem); +FollowAddRequest request = FollowAddRequest.builder() + .fromAccount("test1") + .followItemList(followRequestItemList) + .build(); + +FollowAddResult result = client.sns.followAdd(request); +``` + +## 取消关注用户 + +取消关注用户,支持批量取关。 + +使用示例: + +```java +List toAccount = Collections.singletonList("test2"); +FollowDeleteRequest request = FollowDeleteRequest.builder() + .fromAccount("test1") + .toAccount(toAccount) + .build(); + +FollowDeleteResult result = client.sns.followDelete(request); +``` + +## 拉取关注、粉丝与互关列表 + +分页拉取指定用户的粉丝/关注/互关列表。 + +使用示例: + +```java +FollowGetRequest request = FollowGetRequest.builder() + .fromAccount("test2") + .followType(1) + .build(); + +FollowGetResult result = client.sns.followGet(request); +``` + +## 检查关注关系 + +支持批量检查关注关系。 + +使用示例: + +```java +List toAccount = Collections.singletonList("test2"); +FollowCheckRequest request = FollowCheckRequest.builder() + .fromAccount("test1") + .toAccount(toAccount) + .build(); + +FollowCheckResult result = client.sns.followCheck(request); +``` + +## 获取用户的关注、粉丝与互关数 + +批量查询指定用户的粉丝/关注/互关数。 + +使用示例: + +```java +List toAccount = Collections.singletonList("test2"); +FollowGetInfoRequest request = FollowGetInfoRequest.builder() + .fromAccount("test1") + .toAccount(toAccount) + .build(); + +FollowGetInfoResult result = client.sns.followGetInfo(request); +``` \ No newline at end of file diff --git a/src/main/java/io/github/doocs/im/ImClient.java b/src/main/java/io/github/doocs/im/ImClient.java index 15de1c7..4c2e4f5 100644 --- a/src/main/java/io/github/doocs/im/ImClient.java +++ b/src/main/java/io/github/doocs/im/ImClient.java @@ -40,6 +40,7 @@ public class ImClient { public final Robot robot; public final Audit audit; public final OfficialAccount officialAccount; + public final CloudSearch cloudSearch; public static ImClient getInstance(long sdkAppId, String userId, String key) { return new ImClient(sdkAppId, userId, key); @@ -97,6 +98,7 @@ public ImClient(long sdkAppId, String userId, String key, String domain, ClientC robot = new Robot(this); audit = new Audit(this); officialAccount = new OfficialAccount(this); + cloudSearch = new CloudSearch(this); } /** diff --git a/src/main/java/io/github/doocs/im/core/CloudSearch.java b/src/main/java/io/github/doocs/im/core/CloudSearch.java new file mode 100644 index 0000000..29f52b8 --- /dev/null +++ b/src/main/java/io/github/doocs/im/core/CloudSearch.java @@ -0,0 +1,125 @@ +package io.github.doocs.im.core; + +import io.github.doocs.im.ImClient; +import io.github.doocs.im.model.request.*; +import io.github.doocs.im.model.response.*; +import io.github.doocs.im.util.HttpUtil; + +import java.io.IOException; + +/** + *

+ * 云端搜索 + *

+ * + * @author MC.Yang + * @version V1.0 + **/ +public class CloudSearch { + /** + * 云端搜索服务名 + */ + public static final String SERVICE_NAME_USER = "user_search"; + public static final String SERVICE_NAME_GROUP = "group_search"; + public static final String SERVICE_NAME_GROUP_MEMBER = "group_member_search"; + public static final String SERVICE_NAME_IM_OPEN = "im_open_search"; + + /** + * 云端搜索相关命令字 + */ + public static final String SEARCH_COMMAND = "search"; + public static final String SET_VISIBILITY_COMMAND = "set_visibility"; + public static final String GET_NO_VISIBILITY_COMMAND = "get_no_visibility"; + + private final ImClient imClient; + + public CloudSearch(ImClient imClient) { + this.imClient = imClient; + } + + /** + * 用户搜索 + * + * @param userSearchRequest 用户搜索请求参数 + * @return 用户搜索结果 + * @throws IOException 用户搜索异常 + */ + public UserSearchResult userSearch(UserSearchRequest userSearchRequest) throws IOException { + String url = imClient.getUrl(SERVICE_NAME_USER, SEARCH_COMMAND); + return HttpUtil.post(url, userSearchRequest, UserSearchResult.class, imClient.getConfig()); + } + + public UserSearchResult userSearch(UserSearchRequest userSearchRequest, long random) throws IOException { + String url = imClient.getUrl(SERVICE_NAME_USER, SEARCH_COMMAND, random); + return HttpUtil.post(url, userSearchRequest, UserSearchResult.class, imClient.getConfig()); + } + + /** + * 群组搜索 + * + * @param groupSearchRequest 群组搜索请求参数 + * @return 群组搜索结果 + * @throws IOException 群组搜索异常 + */ + public GroupSearchResult groupSearch(GroupSearchRequest groupSearchRequest) throws IOException { + String url = imClient.getUrl(SERVICE_NAME_GROUP, SEARCH_COMMAND); + return HttpUtil.post(url, groupSearchRequest, GroupSearchResult.class, imClient.getConfig()); + } + + public GroupSearchResult groupSearch(GroupSearchRequest groupSearchRequest, long random) throws IOException { + String url = imClient.getUrl(SERVICE_NAME_GROUP, SEARCH_COMMAND, random); + return HttpUtil.post(url, groupSearchRequest, GroupSearchResult.class, imClient.getConfig()); + } + + /** + * 群成员搜索 + * + * @param groupMemberSearchRequest 群成员搜索请求参数 + * @return 群成员搜索结果 + * @throws IOException 群成员搜索异常 + */ + public GroupMemberSearchResult groupMemberSearch(GroupMemberSearchRequest groupMemberSearchRequest) throws IOException { + String url = imClient.getUrl(SERVICE_NAME_GROUP_MEMBER, SEARCH_COMMAND); + return HttpUtil.post(url, groupMemberSearchRequest, GroupMemberSearchResult.class, imClient.getConfig()); + } + + public GroupMemberSearchResult groupMemberSearch(GroupMemberSearchRequest groupMemberSearchRequest, long random) throws IOException { + String url = imClient.getUrl(SERVICE_NAME_GROUP_MEMBER, SEARCH_COMMAND, random); + return HttpUtil.post(url, groupMemberSearchRequest, GroupMemberSearchResult.class, imClient.getConfig()); + } + + /** + * 隐藏搜索对象 + * + * @param setVisibilityRequest 隐藏搜索对象请求参数 + * @return 隐藏搜索对象结果 + * @throws IOException 隐藏搜索对象异常 + */ + public SetVisibilitySearchResult setVisibility(SetVisibilityRequest setVisibilityRequest) throws IOException { + String url = imClient.getUrl(SERVICE_NAME_IM_OPEN, SET_VISIBILITY_COMMAND); + return HttpUtil.post(url, setVisibilityRequest, SetVisibilitySearchResult.class, imClient.getConfig()); + } + + public SetVisibilitySearchResult setVisibility(SetVisibilityRequest setVisibilityRequest, long random) throws IOException { + String url = imClient.getUrl(SERVICE_NAME_IM_OPEN, SET_VISIBILITY_COMMAND, random); + return HttpUtil.post(url, setVisibilityRequest, SetVisibilitySearchResult.class, imClient.getConfig()); + } + + /** + * 查询隐藏搜索对象 + * + * @param getNoVisibilityRequest 查询隐藏搜索对象请求参数 + * @return 查询隐藏搜索对象结果 + * @throws IOException 查询隐藏搜索对象异常 + */ + public GetNoVisibilitySearchResult getNoVisibility(GetNoVisibilityRequest getNoVisibilityRequest) throws IOException { + String url = imClient.getUrl(SERVICE_NAME_IM_OPEN, GET_NO_VISIBILITY_COMMAND); + return HttpUtil.post(url, getNoVisibilityRequest, GetNoVisibilitySearchResult.class, imClient.getConfig()); + } + + public GetNoVisibilitySearchResult getNoVisibility(GetNoVisibilityRequest getNoVisibilityRequest, long random) throws IOException { + String url = imClient.getUrl(SERVICE_NAME_IM_OPEN, GET_NO_VISIBILITY_COMMAND, random); + return HttpUtil.post(url, getNoVisibilityRequest, GetNoVisibilitySearchResult.class, imClient.getConfig()); + } + +} diff --git a/src/main/java/io/github/doocs/im/model/request/GetNoVisibilityRequest.java b/src/main/java/io/github/doocs/im/model/request/GetNoVisibilityRequest.java new file mode 100644 index 0000000..f3ea073 --- /dev/null +++ b/src/main/java/io/github/doocs/im/model/request/GetNoVisibilityRequest.java @@ -0,0 +1,115 @@ +package io.github.doocs.im.model.request; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +import java.io.Serializable; + +/** + *

+ * 查询隐藏搜索对象-请求参数 + *

+ * + * @author MC.Yang + * @version V1.0 + **/ +@JsonInclude(JsonInclude.Include.NON_NULL) +public class GetNoVisibilityRequest extends GenericRequest implements Serializable { + private static final long serialVersionUID = 8616458085271489051L; + + /** + * 搜索对象类型: + * 1=用户搜索。 + * 2=群组搜索。 + * 3=群成员搜索。 + */ + @JsonProperty("SetType") + private Integer setType; + + /** + * 当次查询搜索对象的数量。 + */ + @JsonProperty("Count") + private Integer count; + + /** + * 续拉参数,上个请求的 Response 中带回,首次请求为空。 + */ + @JsonProperty("Cursor") + private String cursor; + + public GetNoVisibilityRequest() { + } + + public GetNoVisibilityRequest(Integer setType) { + this.setType = setType; + } + + public GetNoVisibilityRequest(Integer setType, Integer count, String cursor) { + this.setType = setType; + this.count = count; + this.cursor = cursor; + } + + private GetNoVisibilityRequest(Builder builder) { + this.setType = builder.setType; + this.count = builder.count; + this.cursor = builder.cursor; + } + + public static Builder builder() { + return new Builder(); + } + + public Integer getSetType() { + return setType; + } + + public void setSetType(Integer setType) { + this.setType = setType; + } + + public Integer getCount() { + return count; + } + + public void setCount(Integer count) { + this.count = count; + } + + public String getCursor() { + return cursor; + } + + public void setCursor(String cursor) { + this.cursor = cursor; + } + + public static final class Builder { + private Integer setType; + private Integer count; + private String cursor; + + private Builder() { + } + + public GetNoVisibilityRequest build() { + return new GetNoVisibilityRequest(this); + } + + public Builder setType(Integer setType) { + this.setType = setType; + return this; + } + + public Builder count(Integer count) { + this.count = count; + return this; + } + + public Builder cursor(String cursor) { + this.cursor = cursor; + return this; + } + } +} diff --git a/src/main/java/io/github/doocs/im/model/request/GroupMemberSearchRequest.java b/src/main/java/io/github/doocs/im/model/request/GroupMemberSearchRequest.java new file mode 100644 index 0000000..e5934df --- /dev/null +++ b/src/main/java/io/github/doocs/im/model/request/GroupMemberSearchRequest.java @@ -0,0 +1,180 @@ +package io.github.doocs.im.model.request; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +import java.io.Serializable; +import java.util.List; + +/** + *

+ * 群成员搜索-请求参数 + *

+ * + * @author MC.Yang + * @version V1.0 + **/ +@JsonInclude(JsonInclude.Include.NON_NULL) +public class GroupMemberSearchRequest extends GenericRequest implements Serializable { + private static final long serialVersionUID = -8624057806267198381L; + + /** + * 群组类型 + * {@link io.github.doocs.im.constant.GroupType} + */ + @JsonProperty("GroupType") + private List groupType; + + /** + * 过滤群组范围 + */ + @JsonProperty("GroupIdList") + private List groupIdList; + + /** + * 逻辑运算符。 + * 1:and + * 0:or + * 默认为 or。 + */ + @JsonProperty("KeywordMatchType") + private Integer keywordMatchType; + + /** + * 模糊搜索的 Keywords。 + */ + @JsonProperty("Keywords") + private List keywords; + + /** + * 一次请求最大记录数,最大100条,超过100条按100处理。 + */ + @JsonProperty("Count") + private Integer count; + + /** + * 续拉参数,上个请求的 Response 中带回,首次请求为空。 + */ + @JsonProperty("Cursor") + private String cursor; + + public GroupMemberSearchRequest() { + } + + public GroupMemberSearchRequest(List groupType, List groupIdList, Integer keywordMatchType, + List keywords, Integer count, String cursor) { + this.groupType = groupType; + this.groupIdList = groupIdList; + this.keywordMatchType = keywordMatchType; + this.keywords = keywords; + this.count = count; + this.cursor = cursor; + } + + private GroupMemberSearchRequest(Builder builder) { + this.groupType = builder.groupType; + this.groupIdList = builder.groupIdList; + this.keywordMatchType = builder.keywordMatchType; + this.keywords = builder.keywords; + this.count = builder.count; + this.cursor = builder.cursor; + } + + public static Builder builder() { + return new Builder(); + } + + public List getGroupType() { + return groupType; + } + + public void setGroupType(List groupType) { + this.groupType = groupType; + } + + public List getGroupIdList() { + return groupIdList; + } + + public void setGroupIdList(List groupIdList) { + this.groupIdList = groupIdList; + } + + public Integer getKeywordMatchType() { + return keywordMatchType; + } + + public void setKeywordMatchType(Integer keywordMatchType) { + this.keywordMatchType = keywordMatchType; + } + + public List getKeywords() { + return keywords; + } + + public void setKeywords(List keywords) { + this.keywords = keywords; + } + + public Integer getCount() { + return count; + } + + public void setCount(Integer count) { + this.count = count; + } + + public String getCursor() { + return cursor; + } + + public void setCursor(String cursor) { + this.cursor = cursor; + } + + public static final class Builder { + private List groupType; + private List groupIdList; + private Integer keywordMatchType; + private List keywords; + private Integer count; + private String cursor; + + private Builder() { + } + + public GroupMemberSearchRequest build() { + return new GroupMemberSearchRequest(this); + } + + public Builder groupType(List groupType) { + this.groupType = groupType; + return this; + } + + public Builder groupIdList(List groupIdList) { + this.groupIdList = groupIdList; + return this; + } + + public Builder keywordMatchType(Integer keywordMatchType) { + this.keywordMatchType = keywordMatchType; + return this; + } + + public Builder keywords(List keywords) { + this.keywords = keywords; + return this; + } + + public Builder count(Integer count) { + this.count = count; + return this; + } + + public Builder cursor(String cursor) { + this.cursor = cursor; + return this; + } + } +} diff --git a/src/main/java/io/github/doocs/im/model/request/GroupSearchRequest.java b/src/main/java/io/github/doocs/im/model/request/GroupSearchRequest.java new file mode 100644 index 0000000..3939e0d --- /dev/null +++ b/src/main/java/io/github/doocs/im/model/request/GroupSearchRequest.java @@ -0,0 +1,157 @@ +package io.github.doocs.im.model.request; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +import java.io.Serializable; +import java.util.List; + +/** + *

+ * 群组搜索-请求参数 + *

+ * + * @author MC.Yang + * @version V1.0 + **/ +@JsonInclude(JsonInclude.Include.NON_NULL) +public class GroupSearchRequest extends GenericRequest implements Serializable { + private static final long serialVersionUID = 2674240830817188609L; + + /** + * 群组类型 + * {@link io.github.doocs.im.constant.GroupType} + */ + @JsonProperty("GroupType") + private List groupType; + + /** + * 逻辑运算符。 + * 1:and + * 0:or + * 默认为 or。 + */ + @JsonProperty("KeywordMatchType") + private Integer keywordMatchType; + + /** + * 模糊搜索的 Keywords。 + */ + @JsonProperty("Keywords") + private List keywords; + + /** + * 一次请求最大记录数,最大100条,超过100条按100条处理。 + */ + @JsonProperty("Count") + private Integer count; + + /** + * 续拉参数,上个请求的 Response 中带回,首次请求为空。 + */ + @JsonProperty("Cursor") + private String cursor; + + public GroupSearchRequest() { + } + + public GroupSearchRequest(List groupType, Integer keywordMatchType, List keywords, Integer count, String cursor) { + this.groupType = groupType; + this.keywordMatchType = keywordMatchType; + this.keywords = keywords; + this.count = count; + this.cursor = cursor; + } + + private GroupSearchRequest(Builder builder) { + this.groupType = builder.groupType; + this.keywordMatchType = builder.keywordMatchType; + this.keywords = builder.keywords; + this.count = builder.count; + this.cursor = builder.cursor; + } + + public static Builder builder() { + return new Builder(); + } + + public List getGroupType() { + return groupType; + } + + public void setGroupType(List groupType) { + this.groupType = groupType; + } + + public Integer getKeywordMatchType() { + return keywordMatchType; + } + + public void setKeywordMatchType(Integer keywordMatchType) { + this.keywordMatchType = keywordMatchType; + } + + public List getKeywords() { + return keywords; + } + + public void setKeywords(List keywords) { + this.keywords = keywords; + } + + public Integer getCount() { + return count; + } + + public void setCount(Integer count) { + this.count = count; + } + + public String getCursor() { + return cursor; + } + + public void setCursor(String cursor) { + this.cursor = cursor; + } + + public static final class Builder { + private List groupType; + private Integer keywordMatchType; + private List keywords; + private Integer count; + private String cursor; + + private Builder() { + } + + public GroupSearchRequest build() { + return new GroupSearchRequest(this); + } + + public Builder groupType(List groupType) { + this.groupType = groupType; + return this; + } + + public Builder keywordMatchType(Integer keywordMatchType) { + this.keywordMatchType = keywordMatchType; + return this; + } + + public Builder keywords(List keywords) { + this.keywords = keywords; + return this; + } + + public Builder count(Integer count) { + this.count = count; + return this; + } + + public Builder cursor(String cursor) { + this.cursor = cursor; + return this; + } + } +} diff --git a/src/main/java/io/github/doocs/im/model/request/SetVisibilityRequest.java b/src/main/java/io/github/doocs/im/model/request/SetVisibilityRequest.java new file mode 100644 index 0000000..5a4fabe --- /dev/null +++ b/src/main/java/io/github/doocs/im/model/request/SetVisibilityRequest.java @@ -0,0 +1,137 @@ +package io.github.doocs.im.model.request; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +import java.io.Serializable; + +/** + *

+ * 隐藏搜索对象-请求参数 + *

+ * + * @author MC.Yang + * @version V1.0 + **/ +@JsonInclude(JsonInclude.Include.NON_NULL) +public class SetVisibilityRequest extends GenericRequest implements Serializable { + private static final long serialVersionUID = -5968159529237231169L; + + /** + * 搜索对象类型: + * 1=用户搜索。 + * 2=群组搜索。 + * 3=群成员搜索。 + */ + @JsonProperty("SetType") + private Integer setType; + + /** + * 需要隐藏的用户 UserID,SetType为1和3时需要。 + */ + @JsonProperty("UserID") + private String userId; + + /** + * 需要隐藏的群组 GroupID,SetType为1和2时需要。 + */ + @JsonProperty("GroupID") + private String groupId; + + /** + * 默认为 false,true 表示隐藏对应搜索对象,false 表示显示对应搜索对象。 + */ + @JsonProperty("IsDisable") + private Boolean isDisable; + + public SetVisibilityRequest() { + } + + public SetVisibilityRequest(Integer setType) { + this.setType = setType; + } + + public SetVisibilityRequest(Integer setType, String userId, String groupId, Boolean isDisable) { + this.setType = setType; + this.userId = userId; + this.groupId = groupId; + this.isDisable = isDisable; + } + + private SetVisibilityRequest(Builder builder) { + this.setType = builder.setType; + this.userId = builder.userId; + this.groupId = builder.groupId; + this.isDisable = builder.isDisable; + } + + public static Builder builder() { + return new Builder(); + } + + public Integer getSetType() { + return setType; + } + + public void setSetType(Integer setType) { + this.setType = setType; + } + + public String getUserId() { + return userId; + } + + public void setUserId(String userId) { + this.userId = userId; + } + + public String getGroupId() { + return groupId; + } + + public void setGroupId(String groupId) { + this.groupId = groupId; + } + + public Boolean getIsDisable() { + return isDisable; + } + + public void setIsDisable(Boolean isDisable) { + this.isDisable = isDisable; + } + + public static final class Builder { + private Integer setType; + private String userId; + private String groupId; + private Boolean isDisable; + + private Builder() { + } + + public SetVisibilityRequest build() { + return new SetVisibilityRequest(this); + } + + public Builder setType(Integer setType) { + this.setType = setType; + return this; + } + + public Builder userId(String userId) { + this.userId = userId; + return this; + } + + public Builder groupId(String groupId) { + this.groupId = groupId; + return this; + } + + public Builder isDisable(Boolean isDisable) { + this.isDisable = isDisable; + return this; + } + } +} diff --git a/src/main/java/io/github/doocs/im/model/request/UserSearchRequest.java b/src/main/java/io/github/doocs/im/model/request/UserSearchRequest.java new file mode 100644 index 0000000..38af94b --- /dev/null +++ b/src/main/java/io/github/doocs/im/model/request/UserSearchRequest.java @@ -0,0 +1,204 @@ +package io.github.doocs.im.model.request; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +import java.io.Serializable; +import java.util.List; + +/** + *

+ * 用户搜索-请求参数 + *

+ * + * @author MC.Yang + * @version V1.0 + **/ +@JsonInclude(JsonInclude.Include.NON_NULL) +public class UserSearchRequest extends GenericRequest implements Serializable { + private static final long serialVersionUID = 5480624981347621262L; + + /** + * 过滤性别,为空表示未指定 + * {@link io.github.doocs.im.constant.GenderType} + */ + @JsonProperty("UserGenderType") + private String userGenderType; + + /** + * 过滤起始出生日期,该字段意义由用户决定,我们只保证为整型 + */ + @JsonProperty("UserBirthStart") + private Integer userBirthStart; + + /** + * 过滤结束出生日期,该字段要比 user_birth_start 大 + */ + @JsonProperty("UserBirthEnd") + private Integer userBirthEnd; + + /** + * 逻辑运算符。1:and 0:or 默认为 or + */ + @JsonProperty("KeywordMatchType") + private Integer keywordMatchType; + + /** + * 模糊搜索的 Keywords + */ + @JsonProperty("Keywords") + private List keywords; + + /** + * 一次请求最大记录数,最大100条,超过100条按100处理 + */ + @JsonProperty("Count") + private Integer count; + + /** + * 续拉参数,上个请求的 Response 中带回,首次请求为空 + */ + @JsonProperty("Cursor") + private String cursor; + + public UserSearchRequest() { + } + + public UserSearchRequest(List keywords, Integer count) { + this.keywords = keywords; + this.count = count; + } + + public UserSearchRequest(String userGenderType, Integer userBirthStart, Integer userBirthEnd, + Integer keywordMatchType, List keywords, Integer count, String cursor) { + this.userGenderType = userGenderType; + this.userBirthStart = userBirthStart; + this.userBirthEnd = userBirthEnd; + this.keywordMatchType = keywordMatchType; + this.keywords = keywords; + this.count = count; + this.cursor = cursor; + } + + private UserSearchRequest(Builder builder) { + this.userGenderType = builder.userGenderType; + this.userBirthStart = builder.userBirthStart; + this.userBirthEnd = builder.userBirthEnd; + this.keywordMatchType = builder.keywordMatchType; + this.keywords = builder.keywords; + this.count = builder.count; + this.cursor = builder.cursor; + } + + public static Builder builder() { + return new Builder(); + } + + public String getUserGenderType() { + return userGenderType; + } + + public void setUserGenderType(String userGenderType) { + this.userGenderType = userGenderType; + } + + public Integer getUserBirthStart() { + return userBirthStart; + } + + public void setUserBirthStart(Integer userBirthStart) { + this.userBirthStart = userBirthStart; + } + + public Integer getUserBirthEnd() { + return userBirthEnd; + } + + public void setUserBirthEnd(Integer userBirthEnd) { + this.userBirthEnd = userBirthEnd; + } + + public Integer getKeywordMatchType() { + return keywordMatchType; + } + + public void setKeywordMatchType(Integer keywordMatchType) { + this.keywordMatchType = keywordMatchType; + } + + public List getKeywords() { + return keywords; + } + + public void setKeywords(List keywords) { + this.keywords = keywords; + } + + public Integer getCount() { + return count; + } + + public void setCount(Integer count) { + this.count = count; + } + + public String getCursor() { + return cursor; + } + + public void setCursor(String cursor) { + this.cursor = cursor; + } + + public static final class Builder { + private String userGenderType; + private Integer userBirthStart; + private Integer userBirthEnd; + private Integer keywordMatchType; + private List keywords; + private Integer count; + private String cursor; + + private Builder() { + } + + public UserSearchRequest build() { + return new UserSearchRequest(this); + } + + public Builder userGenderType(String userGenderType) { + this.userGenderType = userGenderType; + return this; + } + + public Builder userBirthStart(Integer userBirthStart) { + this.userBirthStart = userBirthStart; + return this; + } + + public Builder userBirthEnd(Integer userBirthEnd) { + this.userBirthEnd = userBirthEnd; + return this; + } + + public Builder keywordMatchType(Integer keywordMatchType) { + this.keywordMatchType = keywordMatchType; + return this; + } + + public Builder keywords(List keywords) { + this.keywords = keywords; + return this; + } + + public Builder count(Integer count) { + this.count = count; + return this; + } + + public Builder cursor(String cursor) { + this.cursor = cursor; + return this; + } + } +} diff --git a/src/main/java/io/github/doocs/im/model/response/GetNoVisibilitySearchResult.java b/src/main/java/io/github/doocs/im/model/response/GetNoVisibilitySearchResult.java new file mode 100644 index 0000000..eaf7d86 --- /dev/null +++ b/src/main/java/io/github/doocs/im/model/response/GetNoVisibilitySearchResult.java @@ -0,0 +1,89 @@ +package io.github.doocs.im.model.response; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +import java.io.Serializable; +import java.util.List; + +/** + *

+ * 查询隐藏搜索对象-结果 + *

+ * + * @author MC.Yang + * @version V1.0 + **/ +@JsonInclude(JsonInclude.Include.NON_NULL) +public class GetNoVisibilitySearchResult extends GenericResult implements Serializable { + private static final long serialVersionUID = 2158713832423564373L; + + /** + * 搜索是否结束 + */ + @JsonProperty("IsFinish") + private Boolean isFinish; + + /** + * 命中的搜索结果个数 + */ + @JsonProperty("TotalCount") + private Integer totalCount; + + /** + * 命中的隐藏搜索对象 + */ + @JsonProperty("NoVisibleData") + private List noVisibleData; + + /** + * 续拉参数,下个请求的 Response 中带回 + */ + @JsonProperty("Cursor") + private Integer cursor; + + public Boolean getIsFinish() { + return isFinish; + } + + public void setIsFinish(Boolean isFinish) { + this.isFinish = isFinish; + } + + public Integer getTotalCount() { + return totalCount; + } + + public void setTotalCount(Integer totalCount) { + this.totalCount = totalCount; + } + + public List getNoVisibleData() { + return noVisibleData; + } + + public void setNoVisibleData(List noVisibleData) { + this.noVisibleData = noVisibleData; + } + + public Integer getCursor() { + return cursor; + } + + public void setCursor(Integer cursor) { + this.cursor = cursor; + } + + @Override + public String toString() { + return "GetNoVisibilitySearchResult{" + + "isFinish=" + isFinish + + ", totalCount=" + totalCount + + ", noVisibleData=" + noVisibleData + + ", cursor=" + cursor + + ", actionStatus='" + actionStatus + '\'' + + ", errorInfo='" + errorInfo + '\'' + + ", errorCode=" + errorCode + + '}'; + } +} diff --git a/src/main/java/io/github/doocs/im/model/response/GroupMemberItem.java b/src/main/java/io/github/doocs/im/model/response/GroupMemberItem.java new file mode 100644 index 0000000..4ff2664 --- /dev/null +++ b/src/main/java/io/github/doocs/im/model/response/GroupMemberItem.java @@ -0,0 +1,126 @@ +package io.github.doocs.im.model.response; + +import com.fasterxml.jackson.annotation.JsonProperty; + +import java.io.Serializable; + +/** + * 群成员搜索结果项 + * + * @author MC.Yang + * @since 2024/01/29 + */ +public class GroupMemberItem implements Serializable { + private static final long serialVersionUID = 7517968104472517297L; + + /** + * 群组类型 + */ + @JsonProperty("GroupType") + private String groupType; + + /** + * 群组 ID + */ + @JsonProperty("GroupID") + private String groupId; + + /** + * 群组名称 + */ + @JsonProperty("GroupName") + private String groupName; + + /** + * 群成员 UserID + */ + @JsonProperty("GroupMemberUserID") + private String groupMemberUserId; + + /** + * 群成员 TinyID + */ + @JsonProperty("GroupMemberTinyID") + private Long groupMemberTinyId; + + /** + * 群成员用户名 + */ + @JsonProperty("GroupMemberUserName") + private String groupMemberUserName; + + /** + * 群成员名片 + */ + @JsonProperty("GroupMemberNameCard") + private String groupMemberNameCard; + + public String getGroupType() { + return groupType; + } + + public void setGroupType(String groupType) { + this.groupType = groupType; + } + + public String getGroupId() { + return groupId; + } + + public void setGroupId(String groupId) { + this.groupId = groupId; + } + + public String getGroupName() { + return groupName; + } + + public void setGroupName(String groupName) { + this.groupName = groupName; + } + + public String getGroupMemberUserId() { + return groupMemberUserId; + } + + public void setGroupMemberUserId(String groupMemberUserId) { + this.groupMemberUserId = groupMemberUserId; + } + + public Long getGroupMemberTinyId() { + return groupMemberTinyId; + } + + public void setGroupMemberTinyId(Long groupMemberTinyId) { + this.groupMemberTinyId = groupMemberTinyId; + } + + public String getGroupMemberUserName() { + return groupMemberUserName; + } + + public void setGroupMemberUserName(String groupMemberUserName) { + this.groupMemberUserName = groupMemberUserName; + } + + public String getGroupMemberNameCard() { + return groupMemberNameCard; + } + + public void setGroupMemberNameCard(String groupMemberNameCard) { + this.groupMemberNameCard = groupMemberNameCard; + } + + @Override + public String toString() { + return "GroupMemberItem{" + + "groupType='" + groupType + '\'' + + ", groupId='" + groupId + '\'' + + ", groupName='" + groupName + '\'' + + ", groupMemberUserId='" + groupMemberUserId + '\'' + + ", groupMemberTinyId=" + groupMemberTinyId + + ", groupMemberUserName='" + groupMemberUserName + '\'' + + ", groupMemberNameCard='" + groupMemberNameCard + '\'' + + '}'; + } +} \ No newline at end of file diff --git a/src/main/java/io/github/doocs/im/model/response/GroupMemberSearchResult.java b/src/main/java/io/github/doocs/im/model/response/GroupMemberSearchResult.java new file mode 100644 index 0000000..37f898c --- /dev/null +++ b/src/main/java/io/github/doocs/im/model/response/GroupMemberSearchResult.java @@ -0,0 +1,87 @@ +package io.github.doocs.im.model.response; + +import com.fasterxml.jackson.annotation.JsonProperty; + +import java.io.Serializable; +import java.util.List; + +/** + *

+ * 群成员搜索-结果 + *

+ * + * @author MC.Yang + * @version V1.0 + **/ +public class GroupMemberSearchResult extends GenericResult implements Serializable { + private static final long serialVersionUID = 1884672813872948553L; + + /** + * 搜索是否结束 + */ + @JsonProperty("IsFinish") + private Boolean isFinish; + + /** + * 命中的搜索结果个数 + */ + @JsonProperty("TotalCount") + private Integer totalCount; + + /** + * 命中的用户数 + */ + @JsonProperty("GroupMembers") + private List groupMembers; + + /** + * 续拉参数,下个请求的 Response 中带回 + */ + @JsonProperty("Cursor") + private String cursor; + + public Boolean getIsFinish() { + return isFinish; + } + + public void setIsFinish(Boolean isFinish) { + this.isFinish = isFinish; + } + + public Integer getTotalCount() { + return totalCount; + } + + public void setTotalCount(Integer totalCount) { + this.totalCount = totalCount; + } + + public List getGroupMembers() { + return groupMembers; + } + + public void setGroupMembers(List groupMembers) { + this.groupMembers = groupMembers; + } + + public String getCursor() { + return cursor; + } + + public void setCursor(String cursor) { + this.cursor = cursor; + } + + @Override + public String toString() { + return "GroupMemberSearchResult{" + + "isFinish=" + isFinish + + ", totalCount=" + totalCount + + ", groupMembers=" + groupMembers + + ", cursor='" + cursor + '\'' + + ", actionStatus='" + actionStatus + '\'' + + ", errorInfo='" + errorInfo + '\'' + + ", errorCode=" + errorCode + + '}'; + } +} diff --git a/src/main/java/io/github/doocs/im/model/response/GroupSearchItem.java b/src/main/java/io/github/doocs/im/model/response/GroupSearchItem.java new file mode 100644 index 0000000..ec86b04 --- /dev/null +++ b/src/main/java/io/github/doocs/im/model/response/GroupSearchItem.java @@ -0,0 +1,175 @@ +package io.github.doocs.im.model.response; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +import java.io.Serializable; + +/** + * 群组搜索结果中的单个群组信息 + * + * @author MC.Yang + * @version V1.0 + */ +@JsonInclude(JsonInclude.Include.NON_NULL) +public class GroupSearchItem implements Serializable { + private static final long serialVersionUID = -42884255649710655L; + + /** + * 群组类型 + */ + @JsonProperty("GroupType") + private String groupType; + + /** + * 群组 ID + */ + @JsonProperty("GroupID") + private String groupId; + + /** + * 群组名称 + */ + @JsonProperty("GroupName") + private String groupName; + + /** + * 群组人数 + */ + @JsonProperty("GroupMemberNum") + private Integer groupMemberNum; + + /** + * 群组头像 + */ + @JsonProperty("GroupFaceUrl") + private String groupFaceUrl; + + /** + * 群组简介 + */ + @JsonProperty("GroupIntroduction") + private String groupIntroduction; + + /** + * 群主 UserID + */ + @JsonProperty("GroupOwnerUserID") + private String groupOwnerUserId; + + /** + * 群主 TinyID + */ + @JsonProperty("GroupOwnerTinyID") + private Integer groupOwnerTinyId; + + /** + * 群主昵称 + */ + @JsonProperty("GroupOwnerUserName") + private String groupOwnerUserName; + + public GroupSearchItem() { + } + + public GroupSearchItem(String groupType, String groupId, String groupName, Integer groupMemberNum, + String groupFaceUrl, String groupIntroduction, String groupOwnerUserId, + Integer groupOwnerTinyId, String groupOwnerUserName) { + this.groupType = groupType; + this.groupId = groupId; + this.groupName = groupName; + this.groupMemberNum = groupMemberNum; + this.groupFaceUrl = groupFaceUrl; + this.groupIntroduction = groupIntroduction; + this.groupOwnerUserId = groupOwnerUserId; + this.groupOwnerTinyId = groupOwnerTinyId; + this.groupOwnerUserName = groupOwnerUserName; + } + + public String getGroupType() { + return groupType; + } + + public void setGroupType(String groupType) { + this.groupType = groupType; + } + + public String getGroupId() { + return groupId; + } + + public void setGroupId(String groupId) { + this.groupId = groupId; + } + + public String getGroupName() { + return groupName; + } + + public void setGroupName(String groupName) { + this.groupName = groupName; + } + + public Integer getGroupMemberNum() { + return groupMemberNum; + } + + public void setGroupMemberNum(Integer groupMemberNum) { + this.groupMemberNum = groupMemberNum; + } + + public String getGroupFaceUrl() { + return groupFaceUrl; + } + + public void setGroupFaceUrl(String groupFaceUrl) { + this.groupFaceUrl = groupFaceUrl; + } + + public String getGroupIntroduction() { + return groupIntroduction; + } + + public void setGroupIntroduction(String groupIntroduction) { + this.groupIntroduction = groupIntroduction; + } + + public String getGroupOwnerUserId() { + return groupOwnerUserId; + } + + public void setGroupOwnerUserId(String groupOwnerUserId) { + this.groupOwnerUserId = groupOwnerUserId; + } + + public Integer getGroupOwnerTinyId() { + return groupOwnerTinyId; + } + + public void setGroupOwnerTinyId(Integer groupOwnerTinyId) { + this.groupOwnerTinyId = groupOwnerTinyId; + } + + public String getGroupOwnerUserName() { + return groupOwnerUserName; + } + + public void setGroupOwnerUserName(String groupOwnerUserName) { + this.groupOwnerUserName = groupOwnerUserName; + } + + @Override + public String toString() { + return "GroupSearchItem{" + + "groupType='" + groupType + '\'' + + ", groupId='" + groupId + '\'' + + ", groupName='" + groupName + '\'' + + ", groupMemberNum=" + groupMemberNum + + ", groupFaceUrl='" + groupFaceUrl + '\'' + + ", groupIntroduction='" + groupIntroduction + '\'' + + ", groupOwnerUserId='" + groupOwnerUserId + '\'' + + ", groupOwnerTinyId=" + groupOwnerTinyId + + ", groupOwnerUserName='" + groupOwnerUserName + '\'' + + '}'; + } +} \ No newline at end of file diff --git a/src/main/java/io/github/doocs/im/model/response/GroupSearchResult.java b/src/main/java/io/github/doocs/im/model/response/GroupSearchResult.java new file mode 100644 index 0000000..e9d782f --- /dev/null +++ b/src/main/java/io/github/doocs/im/model/response/GroupSearchResult.java @@ -0,0 +1,89 @@ +package io.github.doocs.im.model.response; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +import java.io.Serializable; +import java.util.List; + +/** + *

+ * 群组搜索-结果 + *

+ * + * @author MC.Yang + * @version V1.0 + **/ +@JsonInclude(JsonInclude.Include.NON_NULL) +public class GroupSearchResult extends GenericResult implements Serializable { + private static final long serialVersionUID = 615574387851889873L; + + /** + * 搜索是否结束 + */ + @JsonProperty("IsFinish") + private Boolean isFinish; + + /** + * 命中的搜索结果个数 + */ + @JsonProperty("TotalCount") + private Integer totalCount; + + /** + * 命中的群组数 + */ + @JsonProperty("Groups") + private List groups; + + /** + * 续拉参数,下个请求的 Response 中带回 + */ + @JsonProperty("Cursor") + private Integer cursor; + + public Boolean getIsFinish() { + return isFinish; + } + + public void setIsFinish(Boolean isFinish) { + this.isFinish = isFinish; + } + + public Integer getTotalCount() { + return totalCount; + } + + public void setTotalCount(Integer totalCount) { + this.totalCount = totalCount; + } + + public List getGroups() { + return groups; + } + + public void setGroups(List groups) { + this.groups = groups; + } + + public Integer getCursor() { + return cursor; + } + + public void setCursor(Integer cursor) { + this.cursor = cursor; + } + + @Override + public String toString() { + return "GroupSearchResult{" + + "isFinish=" + isFinish + + ", totalCount=" + totalCount + + ", groups=" + groups + + ", cursor=" + cursor + + ", actionStatus='" + actionStatus + '\'' + + ", errorInfo='" + errorInfo + '\'' + + ", errorCode=" + errorCode + + '}'; + } +} diff --git a/src/main/java/io/github/doocs/im/model/response/NoVisibleDataItem.java b/src/main/java/io/github/doocs/im/model/response/NoVisibleDataItem.java new file mode 100644 index 0000000..b3aaa7a --- /dev/null +++ b/src/main/java/io/github/doocs/im/model/response/NoVisibleDataItem.java @@ -0,0 +1,61 @@ +package io.github.doocs.im.model.response; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +import java.io.Serializable; + +/** + * 隐藏搜索对象数据 + * + * @author MC.Yang + * @version V1.0 + **/ +@JsonInclude(JsonInclude.Include.NON_NULL) +public class NoVisibleDataItem implements Serializable { + private static final long serialVersionUID = -842842556497106534L; + + /** + * 隐藏群成员/用户的 UserID,当 SetType 为2时,表示群成员的 UserID + */ + @JsonProperty("UserID") + private String userId; + + /** + * 隐藏群组 GroupID,当 SetType 为2时,表示群成员所属群组 GroupID + */ + @JsonProperty("GroupID") + private String groupId; + + public NoVisibleDataItem() { + } + + public NoVisibleDataItem(String userId, String groupId) { + this.userId = userId; + this.groupId = groupId; + } + + public String getUserId() { + return userId; + } + + public void setUserId(String userId) { + this.userId = userId; + } + + public String getGroupId() { + return groupId; + } + + public void setGroupId(String groupId) { + this.groupId = groupId; + } + + @Override + public String toString() { + return "NoVisibleData{" + + "userID='" + userId + '\'' + + ", groupID='" + groupId + '\'' + + '}'; + } +} \ No newline at end of file diff --git a/src/main/java/io/github/doocs/im/model/response/ProfileItemValue.java b/src/main/java/io/github/doocs/im/model/response/ProfileItemValue.java new file mode 100644 index 0000000..3ac649b --- /dev/null +++ b/src/main/java/io/github/doocs/im/model/response/ProfileItemValue.java @@ -0,0 +1,77 @@ +package io.github.doocs.im.model.response; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +import java.io.Serializable; + +/** + * 搜索结果中的资料字段值 + * + * @author MC.Yang + * @version V1.0 + **/ +@JsonInclude(JsonInclude.Include.NON_NULL) +public class ProfileItemValue implements Serializable { + private static final long serialVersionUID = -42884255649710653L; + + /** + * 资料字段名 + */ + @JsonProperty("Tag") + private String tag; + + /** + * 整型值 + */ + @JsonProperty("IntValue") + private Integer intValue; + + /** + * 字符串值 + */ + @JsonProperty("StrValue") + private String strValue; + + public ProfileItemValue() { + } + + public ProfileItemValue(String tag, Integer intValue, String strValue) { + this.tag = tag; + this.intValue = intValue; + this.strValue = strValue; + } + + public String getTag() { + return tag; + } + + public void setTag(String tag) { + this.tag = tag; + } + + public Integer getIntValue() { + return intValue; + } + + public void setIntValue(Integer intValue) { + this.intValue = intValue; + } + + public String getStrValue() { + return strValue; + } + + public void setStrValue(String strValue) { + this.strValue = strValue; + } + + @Override + public String toString() { + return "ProfileItemValue{" + + "tag='" + tag + '\'' + + ", intValue=" + intValue + + ", strValue='" + strValue + '\'' + + '}'; + } +} \ No newline at end of file diff --git a/src/main/java/io/github/doocs/im/model/response/RspMsgItem.java b/src/main/java/io/github/doocs/im/model/response/RspMsgItem.java index 5d062e7..a59f635 100644 --- a/src/main/java/io/github/doocs/im/model/response/RspMsgItem.java +++ b/src/main/java/io/github/doocs/im/model/response/RspMsgItem.java @@ -56,6 +56,12 @@ public class RspMsgItem implements Serializable { @JsonProperty("MsgKey") private String msgKey; + /** + * 消息自定义数据(云端保存,会发送到对端,程序卸载重装后还能拉取到) + */ + @JsonProperty("CloudCustomData") + private String cloudCustomData; + /** * 消息序列号,用于标记该条消息,值越小发送的越早,数据范围 [0,4294967295] */ @@ -147,6 +153,14 @@ public void setMsgKey(String msgKey) { this.msgKey = msgKey; } + public String getCloudCustomData() { + return cloudCustomData; + } + + public void setCloudCustomData(String cloudCustomData) { + this.cloudCustomData = cloudCustomData; + } + @Override public String toString() { return "RspMsgItem{" + @@ -157,6 +171,7 @@ public String toString() { ", msgPriority=" + msgPriority + ", msgRandom=" + msgRandom + ", msgKey='" + msgKey + '\'' + + ", cloudCustomData='" + cloudCustomData + '\'' + ", msgSeq=" + msgSeq + ", msgTimeStamp=" + msgTimeStamp + '}'; diff --git a/src/main/java/io/github/doocs/im/model/response/SetVisibilitySearchResult.java b/src/main/java/io/github/doocs/im/model/response/SetVisibilitySearchResult.java new file mode 100644 index 0000000..cfc9e55 --- /dev/null +++ b/src/main/java/io/github/doocs/im/model/response/SetVisibilitySearchResult.java @@ -0,0 +1,15 @@ +package io.github.doocs.im.model.response; + +import java.io.Serializable; + +/** + *

+ * 隐藏搜索对象-结果 + *

+ * + * @author MC.Yang + * @version V1.0 + **/ +public class SetVisibilitySearchResult extends GenericResult implements Serializable { + private static final long serialVersionUID = -4429134075732633581L; +} diff --git a/src/main/java/io/github/doocs/im/model/response/UserProfileResultItem.java b/src/main/java/io/github/doocs/im/model/response/UserProfileResultItem.java new file mode 100644 index 0000000..b1142a9 --- /dev/null +++ b/src/main/java/io/github/doocs/im/model/response/UserProfileResultItem.java @@ -0,0 +1,62 @@ +package io.github.doocs.im.model.response; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +import java.io.Serializable; +import java.util.List; + +/** + * 用户搜索结果中的单个用户信息 + * + * @author MC.Yang + * @version V1.0 + **/ +@JsonInclude(JsonInclude.Include.NON_NULL) +public class UserProfileResultItem implements Serializable { + private static final long serialVersionUID = -42884255649710654L; + + /** + * 命中的用户 UserID + */ + @JsonProperty("UserID") + private String userId; + + /** + * 命中的用户所有标准资料字段 + */ + @JsonProperty("ProfileItems") + private List profileItems; + + public UserProfileResultItem() { + } + + public UserProfileResultItem(String userId, List profileItems) { + this.userId = userId; + this.profileItems = profileItems; + } + + public String getUserId() { + return userId; + } + + public void setUserId(String userId) { + this.userId = userId; + } + + public List getProfileItems() { + return profileItems; + } + + public void setProfileItems(List profileItems) { + this.profileItems = profileItems; + } + + @Override + public String toString() { + return "UserProfileResultItem{" + + "userId='" + userId + '\'' + + ", profileItems=" + profileItems + + '}'; + } +} \ No newline at end of file diff --git a/src/main/java/io/github/doocs/im/model/response/UserSearchResult.java b/src/main/java/io/github/doocs/im/model/response/UserSearchResult.java new file mode 100644 index 0000000..a25a691 --- /dev/null +++ b/src/main/java/io/github/doocs/im/model/response/UserSearchResult.java @@ -0,0 +1,89 @@ +package io.github.doocs.im.model.response; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +import java.io.Serializable; +import java.util.List; + +/** + *

+ * 用户搜索-结果 + *

+ * + * @author MC.Yang + * @version V1.0 + **/ +@JsonInclude(JsonInclude.Include.NON_NULL) +public class UserSearchResult extends GenericResult implements Serializable { + private static final long serialVersionUID = 42884255649710653L; + + /** + * 搜索是否结束 + */ + @JsonProperty("IsFinish") + private Boolean isFinish; + + /** + * 命中的搜索结果个数 + */ + @JsonProperty("TotalCount") + private Integer totalCount; + + /** + * 命中的用户数 + */ + @JsonProperty("Users") + private List users; + + /** + * 续拉参数,下个请求的 Response 中带回 + */ + @JsonProperty("Cursor") + private Integer cursor; + + public Boolean getIsFinish() { + return isFinish; + } + + public void setIsFinish(Boolean isFinish) { + this.isFinish = isFinish; + } + + public Integer getTotalCount() { + return totalCount; + } + + public void setTotalCount(Integer totalCount) { + this.totalCount = totalCount; + } + + public List getUsers() { + return users; + } + + public void setUsers(List users) { + this.users = users; + } + + public Integer getCursor() { + return cursor; + } + + public void setCursor(Integer cursor) { + this.cursor = cursor; + } + + @Override + public String toString() { + return "UserSearchResult{" + + "isFinish=" + isFinish + + ", totalCount=" + totalCount + + ", users=" + users + + ", cursor=" + cursor + + ", actionStatus='" + actionStatus + '\'' + + ", errorInfo='" + errorInfo + '\'' + + ", errorCode=" + errorCode + + '}'; + } +} diff --git a/src/test/java/io/github/doocs/im/core/CloudSearchTest.java b/src/test/java/io/github/doocs/im/core/CloudSearchTest.java new file mode 100644 index 0000000..e36558d --- /dev/null +++ b/src/test/java/io/github/doocs/im/core/CloudSearchTest.java @@ -0,0 +1,98 @@ +package io.github.doocs.im.core; + +import io.github.doocs.im.ClientFactory; +import io.github.doocs.im.ImClient; +import io.github.doocs.im.constant.ActionStatus; +import io.github.doocs.im.constant.GenderType; +import io.github.doocs.im.model.request.*; +import io.github.doocs.im.model.response.*; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; + +import java.io.IOException; +import java.util.Collections; +import java.util.List; + +/** + *

+ * 云搜索测试类 {@link io.github.doocs.im.core.CloudSearch} + *

+ * + * @author MC.Yang + * @version V1.0 + **/ +public class CloudSearchTest { + + private static ImClient client; + + @BeforeAll + static void setup() { + client = ClientFactory.getInstance(); + Assertions.assertNotNull(client, "client is null"); + } + + @Test + void testUserSearch() throws IOException { + List keywords = Collections.singletonList("test1"); + UserSearchRequest request = UserSearchRequest.builder() + .count(1) + .userGenderType(GenderType.MALE) + .keywordMatchType(1) + .keywords(keywords) + .build(); + UserSearchResult result = client.cloudSearch.userSearch(request); + System.out.println(result); + Assertions.assertEquals(ActionStatus.OK, result.getActionStatus()); + } + + @Test + void testGroupSearch() throws IOException { + GroupSearchRequest request = GroupSearchRequest.builder() + .count(100) + .groupType(Collections.singletonList("Public")) + .keywordMatchType(1) + .keywords(Collections.singletonList("test")) + .build(); + GroupSearchResult result = client.cloudSearch.groupSearch(request); + System.out.println(result); + Assertions.assertEquals(ActionStatus.OK, result.getActionStatus()); + } + + @Test + void testGroupMemberSearch() throws IOException { + GroupMemberSearchRequest request = GroupMemberSearchRequest.builder() + .count(1) + .groupType(Collections.singletonList("Public")) + .keywordMatchType(1) + .keywords(Collections.singletonList("test")) + .build(); + GroupMemberSearchResult result = client.cloudSearch.groupMemberSearch(request); + System.out.println(result); + Assertions.assertEquals(ActionStatus.OK, result.getActionStatus()); + } + + @Test + void testSetVisibility() throws IOException { + SetVisibilityRequest request = SetVisibilityRequest.builder() + .setType(1) + .userId("test") + .isDisable(true) + .build(); + SetVisibilitySearchResult result = client.cloudSearch.setVisibility(request); + System.out.println(result); + Assertions.assertEquals(ActionStatus.OK, result.getActionStatus()); + } + + @Test + void testGetNoVisibility() throws IOException { + GetNoVisibilityRequest request = GetNoVisibilityRequest.builder() + .setType(1) + .count(1) + .build(); + GetNoVisibilitySearchResult result = client.cloudSearch.getNoVisibility(request); + System.out.println(result); + Assertions.assertEquals(ActionStatus.OK, result.getActionStatus()); + } + +}