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 dcd222e..6d76159 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 0000000..f09f446 --- /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 0000000..6db2aa3 --- /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 0000000..f21d429 --- /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 0000000..112a5f2 --- /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 0000000..f31bf0e --- /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 0000000..dd2f5f5 --- /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 0000000..cf29563 --- /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 0000000..5b39982 --- /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 0000000..bd5a338 --- /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 0000000..987ff18 --- /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 0000000..d8d2a4e --- /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 0000000..154c50f --- /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 0000000..1ba313e --- /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 0000000..13fc086 --- /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 00e4ed7..49b177a 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()); + } }