From e88060459d2afd2707d13837508180187621c4ae Mon Sep 17 00:00:00 2001 From: ooail <1184010001@qq.com> Date: Mon, 15 Dec 2025 17:19:26 +0800 Subject: [PATCH 1/2] =?UTF-8?q?feat(group):=20=E6=B7=BB=E5=8A=A0=E7=BE=A4?= =?UTF-8?q?=E6=88=90=E5=91=98=E5=9C=A8=E7=BA=BF=E7=8A=B6=E6=80=81=E5=AD=97?= =?UTF-8?q?=E6=AE=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 在 MemberProfile 类中新增 onlineStatus 字段 - 更新构造函数以支持在线状态参数 - 添加在线状态的 getter 和 setter 方法 - 在 Builder 模式中增加 onlineStatus 方法 - 更新 toString 方法以包含在线状态信息 --- .../doocs/im/model/group/MemberProfile.java | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/src/main/java/io/github/doocs/im/model/group/MemberProfile.java b/src/main/java/io/github/doocs/im/model/group/MemberProfile.java index 69013f4a..cfa34093 100644 --- a/src/main/java/io/github/doocs/im/model/group/MemberProfile.java +++ b/src/main/java/io/github/doocs/im/model/group/MemberProfile.java @@ -62,6 +62,12 @@ public class MemberProfile implements Serializable { @JsonProperty("NameCard") private String nameCard; + /** + * 在线状态 + */ + @JsonProperty("OnlineStatus") + private String onlineStatus; + /** * 返回的群成员自定义字段信息 */ @@ -73,6 +79,7 @@ public MemberProfile() { public MemberProfile(String memberAccount, String role, Integer joinTime, Long msgSeq, String msgFlag, Integer lastSendMsgTime, Long muteUntil, String nameCard, + String onlineStatus, List appMemberDefinedData) { this.memberAccount = memberAccount; this.role = role; @@ -82,6 +89,7 @@ public MemberProfile(String memberAccount, String role, Integer joinTime, Long m this.lastSendMsgTime = lastSendMsgTime; this.muteUntil = muteUntil; this.nameCard = nameCard; + this.onlineStatus = onlineStatus; this.appMemberDefinedData = appMemberDefinedData; } @@ -165,6 +173,14 @@ public void setNameCard(String nameCard) { this.nameCard = nameCard; } + public String getOnlineStatus() { + return onlineStatus; + } + + public void setOnlineStatus(String onlineStatus) { + this.onlineStatus = onlineStatus; + } + public List getAppMemberDefinedData() { return appMemberDefinedData; } @@ -186,6 +202,7 @@ public static final class Builder { private Integer lastSendMsgTime; private Long muteUntil; private String nameCard; + private String onlineStatus; private List appMemberDefinedData; private Builder() { @@ -235,6 +252,11 @@ public Builder nameCard(String nameCard) { return this; } + public Builder onlineStatus(String onlineStatus) { + this.onlineStatus = onlineStatus; + return this; + } + public Builder appMemberDefinedData(List appMemberDefinedData) { this.appMemberDefinedData = appMemberDefinedData; return this; @@ -252,6 +274,7 @@ public String toString() { ", lastSendMsgTime=" + lastSendMsgTime + ", muteUntil=" + muteUntil + ", nameCard='" + nameCard + '\'' + + ", onlineStatus='" + onlineStatus + '\'' + ", appMemberDefinedData=" + appMemberDefinedData + '}'; } From ce486b6415a8a5a81ef896ed7b6efc0a106f827c Mon Sep 17 00:00:00 2001 From: ooail <1184010001@qq.com> Date: Tue, 16 Dec 2025 13:38:34 +0800 Subject: [PATCH 2/2] =?UTF-8?q?feat(sns):=20=E6=96=B0=E5=A2=9E=E7=94=A8?= =?UTF-8?q?=E6=88=B7=E5=85=B3=E6=B3=A8=E7=9B=B8=E5=85=B3=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 新增关注用户接口及其实现 - 新增取消关注用户接口及其实现 - 新增拉取关注、粉丝与互关列表接口及其实现 - 新增检查关注关系接口及其实现 - 新增获取用户关注、粉丝与互关数接口及其实现 - 添加相关请求和响应模型类 - 在Sns类中定义新的服务名和命令字常量 - 添加对应的单元测试方法 --- .../java/io/github/doocs/im/core/Sns.java | 92 ++++++++++++ .../im/model/request/FollowAddRequest.java | 89 ++++++++++++ .../im/model/request/FollowCheckRequest.java | 88 ++++++++++++ .../im/model/request/FollowDeleteRequest.java | 88 ++++++++++++ .../model/request/FollowGetInfoRequest.java | 88 ++++++++++++ .../im/model/request/FollowGetRequest.java | 134 ++++++++++++++++++ .../im/model/request/FollowRequestItem.java | 62 ++++++++ .../im/model/response/FollowAddResult.java | 57 ++++++++ .../im/model/response/FollowCheckResult.java | 57 ++++++++ .../model/response/FollowCheckResultItem.java | 45 ++++++ .../im/model/response/FollowDeleteResult.java | 57 ++++++++ .../model/response/FollowGetInfoResult.java | 57 ++++++++ .../im/model/response/FollowGetResult.java | 57 ++++++++ .../model/response/FollowInfoResultItem.java | 72 ++++++++++ .../im/model/response/FollowResultItem.java | 70 +++++++++ .../java/io/github/doocs/im/core/SnsTest.java | 60 ++++++++ 16 files changed, 1173 insertions(+) create mode 100644 src/main/java/io/github/doocs/im/model/request/FollowAddRequest.java create mode 100644 src/main/java/io/github/doocs/im/model/request/FollowCheckRequest.java create mode 100644 src/main/java/io/github/doocs/im/model/request/FollowDeleteRequest.java create mode 100644 src/main/java/io/github/doocs/im/model/request/FollowGetInfoRequest.java create mode 100644 src/main/java/io/github/doocs/im/model/request/FollowGetRequest.java create mode 100644 src/main/java/io/github/doocs/im/model/request/FollowRequestItem.java create mode 100644 src/main/java/io/github/doocs/im/model/response/FollowAddResult.java create mode 100644 src/main/java/io/github/doocs/im/model/response/FollowCheckResult.java create mode 100644 src/main/java/io/github/doocs/im/model/response/FollowCheckResultItem.java create mode 100644 src/main/java/io/github/doocs/im/model/response/FollowDeleteResult.java create mode 100644 src/main/java/io/github/doocs/im/model/response/FollowGetInfoResult.java create mode 100644 src/main/java/io/github/doocs/im/model/response/FollowGetResult.java create mode 100644 src/main/java/io/github/doocs/im/model/response/FollowInfoResultItem.java create mode 100644 src/main/java/io/github/doocs/im/model/response/FollowResultItem.java diff --git a/src/main/java/io/github/doocs/im/core/Sns.java b/src/main/java/io/github/doocs/im/core/Sns.java index dcd222ef..6d76159d 100644 --- a/src/main/java/io/github/doocs/im/core/Sns.java +++ b/src/main/java/io/github/doocs/im/core/Sns.java @@ -18,6 +18,7 @@ public class Sns { * 关系链管理服务名 */ public static final String SERVICE_NAME = "sns"; + public static final String SERVICE_NAME_FOLLOW = "follow"; /** * 关系链管理相关命令字 @@ -37,6 +38,11 @@ public class Sns { public static final String GROUP_ADD_COMMAND = "group_add"; public static final String GROUP_DELETE_COMMAND = "group_delete"; public static final String GROUP_GET_COMMAND = "group_get"; + public static final String FOLLOW_ADD_COMMAND = "follow_add"; + public static final String FOLLOW_DELETE_COMMAND = "follow_delete"; + public static final String FOLLOW_GET_COMMAND = "follow_get"; + public static final String FOLLOW_CHECK_COMMAND = "follow_check"; + public static final String FOLLOW_GET_INFO_COMMAND = "follow_get_info"; private final ImClient imClient; @@ -298,4 +304,90 @@ public GroupGetResult groupGet(GroupGetRequest groupGetRequest, long random) thr String url = imClient.getUrl(SERVICE_NAME, GROUP_GET_COMMAND, random); return HttpUtil.post(url, groupGetRequest, GroupGetResult.class, imClient.getConfig()); } + + /** + * 关注用户 + * + * @param followAddRequest 关注用户请求参数 + * @return 关注用户结果 + * @throws IOException 关注用户异常 + */ + public FollowAddResult followAdd(FollowAddRequest followAddRequest) throws IOException { + String url = imClient.getUrl(SERVICE_NAME_FOLLOW, FOLLOW_ADD_COMMAND); + return HttpUtil.post(url, followAddRequest, FollowAddResult.class, imClient.getConfig()); + } + + public FollowAddResult followAdd(FollowAddRequest followAddRequest, long random) throws IOException { + String url = imClient.getUrl(SERVICE_NAME_FOLLOW, FOLLOW_ADD_COMMAND, random); + return HttpUtil.post(url, followAddRequest, FollowAddResult.class, imClient.getConfig()); + } + + /** + * 取消关注用户 + * + * @param followDeleteRequest 取消关注用户请求参数 + * @return 取消关注用户结果 + * @throws IOException 取消关注用户异常 + */ + public FollowDeleteResult followDelete(FollowDeleteRequest followDeleteRequest) throws IOException { + String url = imClient.getUrl(SERVICE_NAME_FOLLOW, FOLLOW_DELETE_COMMAND); + return HttpUtil.post(url, followDeleteRequest, FollowDeleteResult.class, imClient.getConfig()); + } + + public FollowDeleteResult followDelete(FollowDeleteRequest followDeleteRequest, long random) throws IOException { + String url = imClient.getUrl(SERVICE_NAME_FOLLOW, FOLLOW_DELETE_COMMAND, random); + return HttpUtil.post(url, followDeleteRequest, FollowDeleteResult.class, imClient.getConfig()); + } + + /** + * 拉取关注、粉丝与互关列表 + * + * @param followGetRequest 拉取关注请求参数 + * @return 拉取关注结果 + * @throws IOException 拉取关注异常 + */ + public FollowGetResult followGet(FollowGetRequest followGetRequest) throws IOException { + String url = imClient.getUrl(SERVICE_NAME_FOLLOW, FOLLOW_GET_COMMAND); + return HttpUtil.post(url, followGetRequest, FollowGetResult.class, imClient.getConfig()); + } + + public FollowGetResult followGet(FollowGetRequest followGetRequest, long random) throws IOException { + String url = imClient.getUrl(SERVICE_NAME_FOLLOW, FOLLOW_GET_COMMAND, random); + return HttpUtil.post(url, followGetRequest, FollowGetResult.class, imClient.getConfig()); + } + + /** + * 检查关注关系 + * + * @param followCheckRequest 检查关注关系请求参数 + * @return 检查关注关系结果 + * @throws IOException 检查关注关系异常 + */ + public FollowCheckResult followCheck(FollowCheckRequest followCheckRequest) throws IOException { + String url = imClient.getUrl(SERVICE_NAME_FOLLOW, FOLLOW_CHECK_COMMAND); + return HttpUtil.post(url, followCheckRequest, FollowCheckResult.class, imClient.getConfig()); + } + + public FollowCheckResult followCheck(FollowCheckRequest followCheckRequest, long random) throws IOException { + String url = imClient.getUrl(SERVICE_NAME_FOLLOW, FOLLOW_CHECK_COMMAND, random); + return HttpUtil.post(url, followCheckRequest, FollowCheckResult.class, imClient.getConfig()); + } + + /** + * 获取用户的关注、粉丝与互关数 + * + * @param followGetInfoRequest 获取用户的关注、粉丝与互关数请求参数 + * @return 获取用户的关注、粉丝与互关数结果 + * @throws IOException 拉取关注异常 + */ + public FollowGetInfoResult followGetInfo(FollowGetInfoRequest followGetInfoRequest) throws IOException { + String url = imClient.getUrl(SERVICE_NAME_FOLLOW, FOLLOW_GET_INFO_COMMAND); + return HttpUtil.post(url, followGetInfoRequest, FollowGetInfoResult.class, imClient.getConfig()); + } + + public FollowGetInfoResult followGetInfo(FollowGetInfoRequest followGetInfoRequest, long random) throws IOException { + String url = imClient.getUrl(SERVICE_NAME_FOLLOW, FOLLOW_GET_INFO_COMMAND, random); + return HttpUtil.post(url, followGetInfoRequest, FollowGetInfoResult.class, imClient.getConfig()); + } + } diff --git a/src/main/java/io/github/doocs/im/model/request/FollowAddRequest.java b/src/main/java/io/github/doocs/im/model/request/FollowAddRequest.java new file mode 100644 index 00000000..f09f446f --- /dev/null +++ b/src/main/java/io/github/doocs/im/model/request/FollowAddRequest.java @@ -0,0 +1,89 @@ +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 FollowAddRequest extends GenericRequest implements Serializable { + private static final long serialVersionUID = -4998729848603268465L; + + /** + * 发起关注操作的用户的 UserID + */ + @JsonProperty("From_Account") + private String fromAccount; + + /** + * 关注结构体对象 + */ + @JsonProperty("FollowItem") + List followItemList; + + public FollowAddRequest() { + } + + public FollowAddRequest(String fromAccount, List followItemList) { + this.fromAccount = fromAccount; + this.followItemList = followItemList; + } + + private FollowAddRequest(Builder builder) { + this.fromAccount = builder.fromAccount; + this.followItemList = builder.followItemList; + } + + public static Builder builder() { + return new Builder(); + } + + public String getFromAccount() { + return fromAccount; + } + + public void setFromAccount(String fromAccount) { + this.fromAccount = fromAccount; + } + + public List getFollowItemList() { + return followItemList; + } + + public void setFollowItemList(List followRequestItemList) { + this.followItemList = followRequestItemList; + } + + public static final class Builder { + private String fromAccount; + private List followItemList; + + private Builder() { + } + + public FollowAddRequest build() { + return new FollowAddRequest(this); + } + + public Builder fromAccount(String fromAccount) { + this.fromAccount = fromAccount; + return this; + } + + public Builder followItemList(List followRequestItemList) { + this.followItemList = followRequestItemList; + return this; + } + + } + +} diff --git a/src/main/java/io/github/doocs/im/model/request/FollowCheckRequest.java b/src/main/java/io/github/doocs/im/model/request/FollowCheckRequest.java new file mode 100644 index 00000000..6db2aa3a --- /dev/null +++ b/src/main/java/io/github/doocs/im/model/request/FollowCheckRequest.java @@ -0,0 +1,88 @@ +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 FollowCheckRequest extends GenericRequest implements Serializable { + private static final long serialVersionUID = -1540312147327812439L; + + /** + * 请求检查该用户与 To_Account 之间的关注关系 + */ + @JsonProperty("From_Account") + private String fromAccount; + + /** + * 待检查的用户列表,单次请求的 To_Account 数不得超过100 + */ + @JsonProperty("To_Account") + private List toAccount; + + public FollowCheckRequest() { + } + + public FollowCheckRequest(String fromAccount, List toAccount) { + this.fromAccount = fromAccount; + this.toAccount = toAccount; + } + + private FollowCheckRequest(FollowCheckRequest.Builder builder) { + this.fromAccount = builder.fromAccount; + this.toAccount = builder.toAccount; + } + + public static FollowCheckRequest.Builder builder() { + return new FollowCheckRequest.Builder(); + } + + public String getFromAccount() { + return fromAccount; + } + + public void setFromAccount(String fromAccount) { + this.fromAccount = fromAccount; + } + + public List getToAccount() { + return toAccount; + } + + public void setToAccount(List toAccount) { + this.toAccount = toAccount; + } + + + public static final class Builder { + private String fromAccount; + private List toAccount; + + private Builder() { + } + + public FollowCheckRequest build() { + return new FollowCheckRequest(this); + } + + public FollowCheckRequest.Builder fromAccount(String fromAccount) { + this.fromAccount = fromAccount; + return this; + } + + public FollowCheckRequest.Builder toAccount(List toAccount) { + this.toAccount = toAccount; + return this; + } + } +} diff --git a/src/main/java/io/github/doocs/im/model/request/FollowDeleteRequest.java b/src/main/java/io/github/doocs/im/model/request/FollowDeleteRequest.java new file mode 100644 index 00000000..f21d429e --- /dev/null +++ b/src/main/java/io/github/doocs/im/model/request/FollowDeleteRequest.java @@ -0,0 +1,88 @@ +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 FollowDeleteRequest extends GenericRequest implements Serializable { + private static final long serialVersionUID = -6307672357208946936L; + + /** + * 发起取关操作的用户的 UserID + */ + @JsonProperty("From_Account") + private String fromAccount; + + /** + * 待取关的用户的 UserID,单次请求的 To_Account 数不得超过20 + */ + @JsonProperty("To_Account") + private List toAccount; + + public FollowDeleteRequest() { + } + + public FollowDeleteRequest(String fromAccount, List toAccount) { + this.fromAccount = fromAccount; + this.toAccount = toAccount; + } + + private FollowDeleteRequest(FollowDeleteRequest.Builder builder) { + this.fromAccount = builder.fromAccount; + this.toAccount = builder.toAccount; + } + + public static FollowDeleteRequest.Builder builder() { + return new FollowDeleteRequest.Builder(); + } + + public String getFromAccount() { + return fromAccount; + } + + public void setFromAccount(String fromAccount) { + this.fromAccount = fromAccount; + } + + public List getToAccount() { + return toAccount; + } + + public void setToAccount(List toAccount) { + this.toAccount = toAccount; + } + + + public static final class Builder { + private String fromAccount; + private List toAccount; + + private Builder() { + } + + public FollowDeleteRequest build() { + return new FollowDeleteRequest(this); + } + + public FollowDeleteRequest.Builder fromAccount(String fromAccount) { + this.fromAccount = fromAccount; + return this; + } + + public FollowDeleteRequest.Builder toAccount(List toAccount) { + this.toAccount = toAccount; + return this; + } + } +} diff --git a/src/main/java/io/github/doocs/im/model/request/FollowGetInfoRequest.java b/src/main/java/io/github/doocs/im/model/request/FollowGetInfoRequest.java new file mode 100644 index 00000000..112a5f29 --- /dev/null +++ b/src/main/java/io/github/doocs/im/model/request/FollowGetInfoRequest.java @@ -0,0 +1,88 @@ +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 FollowGetInfoRequest extends GenericRequest implements Serializable { + private static final long serialVersionUID = 198471997889646572L; + + /** + * 发起拉取操作的用户的 UserID + */ + @JsonProperty("From_Account") + private String fromAccount; + + /** + * 待拉取计数的用户的 UserID,单次请求的 To_Account 数不得超过20 + */ + @JsonProperty("To_Account") + private List toAccount; + + public FollowGetInfoRequest() { + } + + public FollowGetInfoRequest(String fromAccount, List toAccount) { + this.fromAccount = fromAccount; + this.toAccount = toAccount; + } + + private FollowGetInfoRequest(FollowGetInfoRequest.Builder builder) { + this.fromAccount = builder.fromAccount; + this.toAccount = builder.toAccount; + } + + public static FollowGetInfoRequest.Builder builder() { + return new FollowGetInfoRequest.Builder(); + } + + public String getFromAccount() { + return fromAccount; + } + + public void setFromAccount(String fromAccount) { + this.fromAccount = fromAccount; + } + + public List getToAccount() { + return toAccount; + } + + public void setToAccount(List toAccount) { + this.toAccount = toAccount; + } + + + public static final class Builder { + private String fromAccount; + private List toAccount; + + private Builder() { + } + + public FollowGetInfoRequest build() { + return new FollowGetInfoRequest(this); + } + + public FollowGetInfoRequest.Builder fromAccount(String fromAccount) { + this.fromAccount = fromAccount; + return this; + } + + public FollowGetInfoRequest.Builder toAccount(List toAccount) { + this.toAccount = toAccount; + return this; + } + } +} diff --git a/src/main/java/io/github/doocs/im/model/request/FollowGetRequest.java b/src/main/java/io/github/doocs/im/model/request/FollowGetRequest.java new file mode 100644 index 00000000..f31bf0ed --- /dev/null +++ b/src/main/java/io/github/doocs/im/model/request/FollowGetRequest.java @@ -0,0 +1,134 @@ +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 FollowGetRequest extends GenericRequest implements Serializable { + private static final long serialVersionUID = 1259725175653532351L; + + /** + * 用户的 UserID + */ + @JsonProperty("From_Account") + private String fromAccount; + + /** + * 待拉取的类型: + * 1 - 粉丝 + * 2 - 关注 + * 3 - 互关 + */ + @JsonProperty("FollowType") + private Integer followType; + + /** + * 分页的起始位置:首页为空,续拉请求填上一页回包返回的 NextCursor 字段 + */ + @JsonProperty("StartCursor") + private String startCursor; + + /** + * 拉取的数量:默认每页返回100条数据,最多支持1000条数据 + */ + @JsonProperty("WantNum") + private Integer wantNum; + + public FollowGetRequest() { + } + + public FollowGetRequest(String fromAccount, Integer followType, String startCursor, Integer wantNum) { + this.fromAccount = fromAccount; + this.followType = followType; + this.startCursor = startCursor; + this.wantNum = wantNum; + } + + private FollowGetRequest(FollowGetRequest.Builder builder) { + this.fromAccount = builder.fromAccount; + this.followType = builder.followType; + this.startCursor = builder.startCursor; + this.wantNum = builder.wantNum; + } + + public static FollowGetRequest.Builder builder() { + return new FollowGetRequest.Builder(); + } + + public String getFromAccount() { + return fromAccount; + } + + public void setFromAccount(String fromAccount) { + this.fromAccount = fromAccount; + } + + public Integer getFollowType() { + return followType; + } + + public void setFollowType(Integer followType) { + this.followType = followType; + } + + public String getStartCursor() { + return startCursor; + } + + public void setStartCursor(String startCursor) { + this.startCursor = startCursor; + } + + public Integer getWantNum() { + return wantNum; + } + + public void setWantNum(Integer wantNum) { + this.wantNum = wantNum; + } + + public static final class Builder { + private String fromAccount; + private Integer followType; + private String startCursor; + private Integer wantNum; + + private Builder() { + } + + public FollowGetRequest build() { + return new FollowGetRequest(this); + } + + public FollowGetRequest.Builder fromAccount(String fromAccount) { + this.fromAccount = fromAccount; + return this; + } + + public FollowGetRequest.Builder followType(Integer followType) { + this.followType = followType; + return this; + } + + public FollowGetRequest.Builder startCursor(String startCursor) { + this.startCursor = startCursor; + return this; + } + + public FollowGetRequest.Builder wantNum(Integer wantNum) { + this.wantNum = wantNum; + return this; + } + + } +} diff --git a/src/main/java/io/github/doocs/im/model/request/FollowRequestItem.java b/src/main/java/io/github/doocs/im/model/request/FollowRequestItem.java new file mode 100644 index 00000000..dd2f5f52 --- /dev/null +++ b/src/main/java/io/github/doocs/im/model/request/FollowRequestItem.java @@ -0,0 +1,62 @@ +package io.github.doocs.im.model.request; + +import com.fasterxml.jackson.annotation.JsonProperty; + +import java.io.Serializable; + +/** + *

+ * 关注请求结构体对象 + *

+ * + * @author MC.Yang + * @version V1.0 + **/ +public class FollowRequestItem implements Serializable { + private static final long serialVersionUID = -9020322405344913908L; + + /** + * 待关注的用户的 UserID,单次请求的 To_Account 数不得超过20 + */ + @JsonProperty("To_Account") + private String toAccount; + + public FollowRequestItem() { + } + + public FollowRequestItem(String toAccount) { + this.toAccount = toAccount; + } + + private FollowRequestItem(FollowRequestItem.Builder builder) { + this.toAccount = builder.toAccount; + } + + public static FollowRequestItem.Builder builder() { + return new FollowRequestItem.Builder(); + } + + public String getToAccount() { + return toAccount; + } + + public void setToAccount(String toAccount) { + this.toAccount = toAccount; + } + + public static final class Builder { + private String toAccount; + + private Builder() { + } + + public FollowRequestItem build() { + return new FollowRequestItem(this); + } + + public FollowRequestItem.Builder toAccount(String toAccount) { + this.toAccount = toAccount; + return this; + } + } +} diff --git a/src/main/java/io/github/doocs/im/model/response/FollowAddResult.java b/src/main/java/io/github/doocs/im/model/response/FollowAddResult.java new file mode 100644 index 00000000..cf295631 --- /dev/null +++ b/src/main/java/io/github/doocs/im/model/response/FollowAddResult.java @@ -0,0 +1,57 @@ +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 FollowAddResult extends GenericResult implements Serializable { + private static final long serialVersionUID = -8463119745041284748L; + + /** + * 批量关注的结果对象数组 + */ + @JsonProperty("ResultItem") + private List resultItemList; + + /** + * 详细的客户端展示信息 + */ + @JsonProperty("ErrorDisplay") + private String errorDisplay; + + public List getResultItemList() { + return resultItemList; + } + + public void setResultItemList(List resultItemList) { + this.resultItemList = resultItemList; + } + + public String getErrorDisplay() { + return errorDisplay; + } + + public void setErrorDisplay(String errorDisplay) { + this.errorDisplay = errorDisplay; + } + + @Override + public String toString() { + return "FriendAddResult{" + + "resultItemList=" + resultItemList + + ", errorDisplay='" + errorDisplay + '\'' + + ", actionStatus='" + actionStatus + '\'' + + ", errorInfo='" + errorInfo + '\'' + + ", errorCode=" + errorCode + + '}'; + } +} diff --git a/src/main/java/io/github/doocs/im/model/response/FollowCheckResult.java b/src/main/java/io/github/doocs/im/model/response/FollowCheckResult.java new file mode 100644 index 00000000..5b399828 --- /dev/null +++ b/src/main/java/io/github/doocs/im/model/response/FollowCheckResult.java @@ -0,0 +1,57 @@ +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 FollowCheckResult extends GenericResult implements Serializable { + private static final long serialVersionUID = 950703576946301497L; + + /** + * 校验结果对象数组 + */ + @JsonProperty("ResultItem") + private List resultItemList; + + /** + * 详细的客户端展示信息 + */ + @JsonProperty("ErrorDisplay") + private String errorDisplay; + + public List getResultItemList() { + return resultItemList; + } + + public void setResultItemList(List resultItemList) { + this.resultItemList = resultItemList; + } + + public String getErrorDisplay() { + return errorDisplay; + } + + public void setErrorDisplay(String errorDisplay) { + this.errorDisplay = errorDisplay; + } + + @Override + public String toString() { + return "FollowCheckResult{" + + "resultItemList=" + resultItemList + + ", errorDisplay='" + errorDisplay + '\'' + + ", actionStatus='" + actionStatus + '\'' + + ", errorInfo='" + errorInfo + '\'' + + ", errorCode=" + errorCode + + '}'; + } +} diff --git a/src/main/java/io/github/doocs/im/model/response/FollowCheckResultItem.java b/src/main/java/io/github/doocs/im/model/response/FollowCheckResultItem.java new file mode 100644 index 00000000..bd5a3387 --- /dev/null +++ b/src/main/java/io/github/doocs/im/model/response/FollowCheckResultItem.java @@ -0,0 +1,45 @@ +package io.github.doocs.im.model.response; + +import com.fasterxml.jackson.annotation.JsonProperty; + +import java.io.Serializable; + +/** + *

+ * 校验结果对象 + *

+ * + * @author MC.Yang + * @version V1.0 + **/ +public class FollowCheckResultItem extends ResultItem implements Serializable { + private static final long serialVersionUID = -6833184498334647596L; + + /** + * 校验成功时 To_Account 与 From_Account 之间的关注关系: + * 0 - From_Account 没有关注 To_Account,To_Account 也没有关注 From_Account。 + * 1 - From_Account 没有关注 To_Account,To_Account 关注了 From_Account。 + * 2 - From_Account 关注了 To_Account,To_Account 没有关注 From_Account。 + * 3 - From_Account 关注了 To_Account,To_Account 也关注了 From_Account。 + */ + @JsonProperty("FollowType") + private Integer followType; + + public Integer getFollowType() { + return followType; + } + + public void setFollowType(Integer followType) { + this.followType = followType; + } + + @Override + public String toString() { + return "FollowCheckResultItem{" + + "toAccount='" + getToAccount() + '\'' + + ", resultCode=" + getResultCode() + + ", resultInfo='" + getResultInfo() + '\'' + + ", followType=" + followType + + '}'; + } +} diff --git a/src/main/java/io/github/doocs/im/model/response/FollowDeleteResult.java b/src/main/java/io/github/doocs/im/model/response/FollowDeleteResult.java new file mode 100644 index 00000000..987ff188 --- /dev/null +++ b/src/main/java/io/github/doocs/im/model/response/FollowDeleteResult.java @@ -0,0 +1,57 @@ +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 FollowDeleteResult extends GenericResult implements Serializable { + private static final long serialVersionUID = 3253549117573601073L; + + /** + * 批量取关的结果对象数组 + */ + @JsonProperty("ResultItem") + private List resultItemList; + + /** + * 详细的客户端展示信息 + */ + @JsonProperty("ErrorDisplay") + private String errorDisplay; + + public List getResultItemList() { + return resultItemList; + } + + public void setResultItemList(List resultItemList) { + this.resultItemList = resultItemList; + } + + public String getErrorDisplay() { + return errorDisplay; + } + + public void setErrorDisplay(String errorDisplay) { + this.errorDisplay = errorDisplay; + } + + @Override + public String toString() { + return "FriendAddResult{" + + "resultItemList=" + resultItemList + + ", errorDisplay='" + errorDisplay + '\'' + + ", actionStatus='" + actionStatus + '\'' + + ", errorInfo='" + errorInfo + '\'' + + ", errorCode=" + errorCode + + '}'; + } +} diff --git a/src/main/java/io/github/doocs/im/model/response/FollowGetInfoResult.java b/src/main/java/io/github/doocs/im/model/response/FollowGetInfoResult.java new file mode 100644 index 00000000..d8d2a4e3 --- /dev/null +++ b/src/main/java/io/github/doocs/im/model/response/FollowGetInfoResult.java @@ -0,0 +1,57 @@ +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 FollowGetInfoResult extends GenericResult implements Serializable { + private static final long serialVersionUID = 6489950260163429701L; + + /** + * 拉取的结果对象数组 + */ + @JsonProperty("FollowInfo") + private List followInfoList; + + /** + * 详细的客户端展示信息 + */ + @JsonProperty("ErrorDisplay") + private String errorDisplay; + + public List getFollowInfoList() { + return followInfoList; + } + + public void setFollowInfoList(List followInfoList) { + this.followInfoList = followInfoList; + } + + public String getErrorDisplay() { + return errorDisplay; + } + + public void setErrorDisplay(String errorDisplay) { + this.errorDisplay = errorDisplay; + } + + @Override + public String toString() { + return "FollowGetInfoResult{" + + "followInfoList=" + followInfoList + + ", errorDisplay='" + errorDisplay + '\'' + + ", actionStatus='" + actionStatus + '\'' + + ", errorInfo='" + errorInfo + '\'' + + ", errorCode=" + errorCode + + '}'; + } +} diff --git a/src/main/java/io/github/doocs/im/model/response/FollowGetResult.java b/src/main/java/io/github/doocs/im/model/response/FollowGetResult.java new file mode 100644 index 00000000..154c50fe --- /dev/null +++ b/src/main/java/io/github/doocs/im/model/response/FollowGetResult.java @@ -0,0 +1,57 @@ +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 FollowGetResult extends GenericResult implements Serializable { + private static final long serialVersionUID = -374927471394227839L; + + /** + * 粉丝/关注/互关列表 + */ + @JsonProperty("FollowItem") + private List followItemList; + + /** + * 下一页的起始位置,为空时表示已拉到全量数据 + */ + @JsonProperty("NextCursor") + private String nextCursor; + + public List getFollowItemList() { + return followItemList; + } + + public void setFollowItemList(List followItemList) { + this.followItemList = followItemList; + } + + public String getNextCursor() { + return nextCursor; + } + + public void setNextCursor(String nextCursor) { + this.nextCursor = nextCursor; + } + + @Override + public String toString() { + return "FollowGetResult{" + + "followItemList=" + followItemList + + ", nextCursor='" + nextCursor + '\'' + + ", actionStatus='" + actionStatus + '\'' + + ", errorInfo='" + errorInfo + '\'' + + ", errorCode=" + errorCode + + '}'; + } +} diff --git a/src/main/java/io/github/doocs/im/model/response/FollowInfoResultItem.java b/src/main/java/io/github/doocs/im/model/response/FollowInfoResultItem.java new file mode 100644 index 00000000..1ba313e4 --- /dev/null +++ b/src/main/java/io/github/doocs/im/model/response/FollowInfoResultItem.java @@ -0,0 +1,72 @@ +package io.github.doocs.im.model.response; + +import com.fasterxml.jackson.annotation.JsonProperty; + +import java.io.Serializable; + +/** + *

+ * 拉取的结果对象 + *

+ * + * @author MC.Yang + * @version V1.0 + **/ +public class FollowInfoResultItem extends ResultItem implements Serializable { + private static final long serialVersionUID = 6150410504453879405L; + + /** + * To_Account 的粉丝数 + */ + @JsonProperty("FollowerCount") + private Integer followerCount; + + /** + * To_Account 的关注数 + */ + @JsonProperty("FollowingCount") + private Integer followingCount; + + /** + * To_Account 的互关数 + */ + @JsonProperty("MutualFollowingCount") + private Integer mutualFollowingCount; + + public Integer getFollowerCount() { + return followerCount; + } + + public void setFollowerCount(Integer followerCount) { + this.followerCount = followerCount; + } + + public Integer getFollowingCount() { + return followingCount; + } + + public void setFollowingCount(Integer followingCount) { + this.followingCount = followingCount; + } + + public Integer getMutualFollowingCount() { + return mutualFollowingCount; + } + + public void setMutualFollowingCount(Integer mutualFollowingCount) { + this.mutualFollowingCount = mutualFollowingCount; + } + + @Override + public String toString() { + return "FollowInfoResultItem{" + + "followerCount=" + followerCount + + ", followingCount=" + followingCount + + ", mutualFollowingCount=" + mutualFollowingCount + + ", toAccount='" + getToAccount() + '\'' + + ", resultCode=" + getResultCode() + + ", resultInfo='" + getResultInfo() + '\'' + + '}'; + } + +} diff --git a/src/main/java/io/github/doocs/im/model/response/FollowResultItem.java b/src/main/java/io/github/doocs/im/model/response/FollowResultItem.java new file mode 100644 index 00000000..13fc0861 --- /dev/null +++ b/src/main/java/io/github/doocs/im/model/response/FollowResultItem.java @@ -0,0 +1,70 @@ +package io.github.doocs.im.model.response; + +import com.fasterxml.jackson.annotation.JsonProperty; +import io.github.doocs.im.model.request.ProfileItem; + +import java.io.Serializable; +import java.util.List; + +/** + *

+ * 粉丝/关注/互关列表 + *

+ * + * @author MC.Yang + * @version V1.0 + **/ +public class FollowResultItem implements Serializable { + private static final long serialVersionUID = -3806086675364942543L; + + /** + * 粉丝/关注/互关的用户的 UserID + */ + @JsonProperty("To_Account") + private String toAccount; + + /** + * 关注时间 + */ + @JsonProperty("FollowTime") + private Integer followTime; + + /** + * 用户资料 + */ + @JsonProperty("ProfileItem") + private List profileItemList; + + public String getToAccount() { + return toAccount; + } + + public void setToAccount(String toAccount) { + this.toAccount = toAccount; + } + + public Integer getFollowTime() { + return followTime; + } + + public void setFollowTime(Integer followTime) { + this.followTime = followTime; + } + + public List getProfileItemList() { + return profileItemList; + } + + public void setProfileItemList(List profileItemList) { + this.profileItemList = profileItemList; + } + + @Override + public String toString() { + return "FollowResultItem{" + + "toAccount='" + toAccount + '\'' + + ", followTime=" + followTime + + ", profileItemList=" + profileItemList + + '}'; + } +} diff --git a/src/test/java/io/github/doocs/im/core/SnsTest.java b/src/test/java/io/github/doocs/im/core/SnsTest.java index 00e4ed7f..49b177a3 100644 --- a/src/test/java/io/github/doocs/im/core/SnsTest.java +++ b/src/test/java/io/github/doocs/im/core/SnsTest.java @@ -254,4 +254,64 @@ void testGroupGet() throws IOException { System.out.println(result); Assertions.assertEquals(ActionStatus.OK, result.getActionStatus()); } + + @Test + void testFollowAdd() throws IOException { + 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); + System.out.println(result); + Assertions.assertEquals(ActionStatus.OK, result.getActionStatus()); + } + + @Test + void testFollowDelete() throws IOException { + List toAccount = Collections.singletonList("test2"); + FollowDeleteRequest request = FollowDeleteRequest.builder() + .fromAccount("test1") + .toAccount(toAccount) + .build(); + FollowDeleteResult result = client.sns.followDelete(request); + System.out.println(result); + Assertions.assertEquals(ActionStatus.OK, result.getActionStatus()); + } + + @Test + void testFollowGet() throws IOException { + FollowGetRequest request = FollowGetRequest.builder() + .fromAccount("test2") + .followType(1) + .build(); + FollowGetResult result = client.sns.followGet(request); + System.out.println(result); + Assertions.assertEquals(ActionStatus.OK, result.getActionStatus()); + } + + @Test + void testFollowCheck() throws IOException { + List toAccount = Collections.singletonList("test2"); + FollowCheckRequest request = FollowCheckRequest.builder() + .fromAccount("test1") + .toAccount(toAccount) + .build(); + FollowCheckResult result = client.sns.followCheck(request); + System.out.println(result); + Assertions.assertEquals(ActionStatus.OK, result.getActionStatus()); + } + + @Test + void testFollowGetInfo() throws IOException { + List toAccount = Collections.singletonList("test2"); + FollowGetInfoRequest request = FollowGetInfoRequest.builder() + .fromAccount("test1") + .toAccount(toAccount) + .build(); + FollowGetInfoResult result = client.sns.followGetInfo(request); + System.out.println(result); + Assertions.assertEquals(ActionStatus.OK, result.getActionStatus()); + } }