Skip to content

Commit a9307f4

Browse files
committed
feat: add new group api
* 设置/取消直播群管理员 * 获取直播群管理员列表 * 查询用户是否在直播群内
1 parent 36a7e94 commit a9307f4

File tree

9 files changed

+602
-3
lines changed

9 files changed

+602
-3
lines changed

src/main/java/io/github/doocs/im/core/Group.java

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,9 @@ public class Group {
7474
public static final String GET_GROUP_COUNTER_COMMAND = "get_group_counter";
7575
public static final String UPDATE_GROUP_COUNTER_COMMAND = "update_group_counter";
7676
public static final String DELETE_GROUP_COUNTER_COMMAND = "delete_group_counter";
77+
public static final String MODIFY_ADMIN_COMMAND = "modify_admin";
78+
public static final String GET_ADMIN_LIST_COMMAND = "get_admin_list";
79+
public static final String CHECK_MEMBERS_COMMAND = "check_members";
7780

7881

7982
private final ImClient imClient;
@@ -881,4 +884,55 @@ public DeleteGroupCounterResult deleteGroupCounter(DeleteGroupCounterRequest del
881884
String url = imClient.getUrl(SERVICE_NAME, DELETE_GROUP_COUNTER_COMMAND, random);
882885
return HttpUtil.post(url, deleteGroupCounterRequest, DeleteGroupCounterResult.class, imClient.getConfig());
883886
}
887+
888+
/**
889+
* 设置/取消直播群管理员
890+
*
891+
* @param modifyAdminRequest 请求参数
892+
* @return 结果
893+
* @throws IOException 异常
894+
*/
895+
public ModifyAdminResult modifyAdmin(ModifyAdminRequest modifyAdminRequest) throws IOException {
896+
String url = imClient.getUrl(SERVICE_NAME_CHATROOM, MODIFY_ADMIN_COMMAND);
897+
return HttpUtil.post(url, modifyAdminRequest, ModifyAdminResult.class, imClient.getConfig());
898+
}
899+
900+
public ModifyAdminResult modifyAdmin(ModifyAdminRequest modifyAdminRequest, long random) throws IOException {
901+
String url = imClient.getUrl(SERVICE_NAME_CHATROOM, MODIFY_ADMIN_COMMAND, random);
902+
return HttpUtil.post(url, modifyAdminRequest, ModifyAdminResult.class, imClient.getConfig());
903+
}
904+
905+
/**
906+
* 获取直播群管理员列表
907+
*
908+
* @param getAdminListRequest 请求参数
909+
* @return 结果
910+
* @throws IOException 异常
911+
*/
912+
public GetAdminListResult getAdminList(GetAdminListRequest getAdminListRequest) throws IOException {
913+
String url = imClient.getUrl(SERVICE_NAME_CHATROOM, GET_ADMIN_LIST_COMMAND);
914+
return HttpUtil.post(url, getAdminListRequest, GetAdminListResult.class, imClient.getConfig());
915+
}
916+
917+
public GetAdminListResult getAdminList(GetAdminListRequest getAdminListRequest, long random) throws IOException {
918+
String url = imClient.getUrl(SERVICE_NAME_CHATROOM, GET_ADMIN_LIST_COMMAND, random);
919+
return HttpUtil.post(url, getAdminListRequest, GetAdminListResult.class, imClient.getConfig());
920+
}
921+
922+
/**
923+
* 查询用户是否在直播群内
924+
*
925+
* @param checkMembersRequest 请求参数
926+
* @return 结果
927+
* @throws IOException 异常
928+
*/
929+
public CheckMembersResult checkMembers(CheckMembersRequest checkMembersRequest) throws IOException {
930+
String url = imClient.getUrl(SERVICE_NAME_CHATROOM, CHECK_MEMBERS_COMMAND);
931+
return HttpUtil.post(url, checkMembersRequest, CheckMembersResult.class, imClient.getConfig());
932+
}
933+
934+
public CheckMembersResult checkMembers(CheckMembersRequest checkMembersRequest, long random) throws IOException {
935+
String url = imClient.getUrl(SERVICE_NAME_CHATROOM, CHECK_MEMBERS_COMMAND, random);
936+
return HttpUtil.post(url, checkMembersRequest, CheckMembersResult.class, imClient.getConfig());
937+
}
884938
}
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
package io.github.doocs.im.model.request;
2+
3+
import com.fasterxml.jackson.annotation.JsonInclude;
4+
import com.fasterxml.jackson.annotation.JsonProperty;
5+
6+
import java.io.Serializable;
7+
import java.util.List;
8+
9+
/**
10+
* 查询用户是否在直播群内-请求参数
11+
*
12+
* @author bingo
13+
* @since 2024/1/9 11:36
14+
*/
15+
@JsonInclude(JsonInclude.Include.NON_NULL)
16+
public class CheckMembersRequest extends GenericRequest implements Serializable {
17+
private static final long serialVersionUID = 1773060365482346969L;
18+
19+
@JsonProperty("GroupId")
20+
private String groupId;
21+
22+
@JsonProperty("Member_Account")
23+
private List<String> memberAccount;
24+
25+
public CheckMembersRequest() {
26+
}
27+
28+
public CheckMembersRequest(String groupId, List<String> memberAccount) {
29+
this.groupId = groupId;
30+
this.memberAccount = memberAccount;
31+
}
32+
33+
private CheckMembersRequest(Builder builder) {
34+
this.groupId = builder.groupId;
35+
this.memberAccount = builder.memberAccount;
36+
}
37+
38+
public static Builder builder() {
39+
return new Builder();
40+
}
41+
42+
public String getGroupId() {
43+
return groupId;
44+
}
45+
46+
public void setGroupId(String groupId) {
47+
this.groupId = groupId;
48+
}
49+
50+
public List<String> getMemberAccount() {
51+
return memberAccount;
52+
}
53+
54+
public void setMemberAccount(List<String> memberAccount) {
55+
this.memberAccount = memberAccount;
56+
}
57+
58+
59+
public static final class Builder {
60+
private String groupId;
61+
private List<String> memberAccount;
62+
63+
private Builder() {
64+
}
65+
66+
public CheckMembersRequest build() {
67+
return new CheckMembersRequest(this);
68+
}
69+
70+
public Builder groupId(String groupId) {
71+
this.groupId = groupId;
72+
return this;
73+
}
74+
75+
public Builder memberAccount(List<String> memberAccount) {
76+
this.memberAccount = memberAccount;
77+
return this;
78+
}
79+
}
80+
}
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
package io.github.doocs.im.model.request;
2+
3+
import com.fasterxml.jackson.annotation.JsonInclude;
4+
import com.fasterxml.jackson.annotation.JsonProperty;
5+
6+
import java.io.Serializable;
7+
8+
/**
9+
* 获取直播群管理员列表-请求参数
10+
*
11+
* @author bingo
12+
* @since 2024/1/9 11:36
13+
*/
14+
@JsonInclude(JsonInclude.Include.NON_NULL)
15+
public class GetAdminListRequest extends GenericRequest implements Serializable {
16+
private static final long serialVersionUID = -4674343475066620157L;
17+
18+
@JsonProperty("GroupId")
19+
private String groupId;
20+
21+
public GetAdminListRequest() {
22+
}
23+
24+
public GetAdminListRequest(String groupId) {
25+
this.groupId = groupId;
26+
}
27+
28+
private GetAdminListRequest(Builder builder) {
29+
this.groupId = builder.groupId;
30+
}
31+
32+
public static Builder builder() {
33+
return new Builder();
34+
}
35+
36+
public String getGroupId() {
37+
return groupId;
38+
}
39+
40+
public void setGroupId(String groupId) {
41+
this.groupId = groupId;
42+
}
43+
44+
45+
public static final class Builder {
46+
private String groupId;
47+
48+
private Builder() {
49+
}
50+
51+
public GetAdminListRequest build() {
52+
return new GetAdminListRequest(this);
53+
}
54+
55+
public Builder groupId(String groupId) {
56+
this.groupId = groupId;
57+
return this;
58+
}
59+
}
60+
}
Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
package io.github.doocs.im.model.request;
2+
3+
import com.fasterxml.jackson.annotation.JsonInclude;
4+
import com.fasterxml.jackson.annotation.JsonProperty;
5+
6+
import java.io.Serializable;
7+
import java.util.List;
8+
9+
/**
10+
* 设置/取消直播群管理员-请求参数
11+
*
12+
* @author bingo
13+
* @since 2024/1/9 17:14
14+
*/
15+
@JsonInclude(JsonInclude.Include.NON_NULL)
16+
public class ModifyAdminRequest extends GenericRequest implements Serializable {
17+
private static final long serialVersionUID = 5585650728372773365L;
18+
19+
/**
20+
* 操作的群 ID
21+
*/
22+
@JsonProperty("GroupId")
23+
private String groupId;
24+
25+
/**
26+
* 1: 设置管理员
27+
* 2: 取消设置管理员
28+
*/
29+
@JsonProperty("CommandType")
30+
private Integer commandType;
31+
32+
/**
33+
* 要修改的管理员 UserID 列表,一个直播群最多可以设置5个管理员
34+
*/
35+
@JsonProperty("Admin_Account")
36+
private List<String> adminAccount;
37+
38+
public ModifyAdminRequest() {
39+
}
40+
41+
public ModifyAdminRequest(String groupId, Integer commandType, List<String> adminAccount) {
42+
this.groupId = groupId;
43+
this.commandType = commandType;
44+
this.adminAccount = adminAccount;
45+
}
46+
47+
private ModifyAdminRequest(Builder builder) {
48+
this.groupId = builder.groupId;
49+
this.commandType = builder.commandType;
50+
this.adminAccount = builder.adminAccount;
51+
}
52+
53+
public static Builder builder() {
54+
return new Builder();
55+
}
56+
57+
public String getGroupId() {
58+
return groupId;
59+
}
60+
61+
public void setGroupId(String groupId) {
62+
this.groupId = groupId;
63+
}
64+
65+
public Integer getCommandType() {
66+
return commandType;
67+
}
68+
69+
public void setCommandType(Integer commandType) {
70+
this.commandType = commandType;
71+
}
72+
73+
public List<String> getAdminAccount() {
74+
return adminAccount;
75+
}
76+
77+
public void setAdminAccount(List<String> adminAccount) {
78+
this.adminAccount = adminAccount;
79+
}
80+
81+
82+
public static final class Builder {
83+
private String groupId;
84+
private Integer commandType;
85+
private List<String> adminAccount;
86+
87+
private Builder() {
88+
}
89+
90+
public ModifyAdminRequest build() {
91+
return new ModifyAdminRequest(this);
92+
}
93+
94+
public Builder groupId(String groupId) {
95+
this.groupId = groupId;
96+
return this;
97+
}
98+
99+
public Builder commandType(Integer commandType) {
100+
this.commandType = commandType;
101+
return this;
102+
}
103+
104+
public Builder adminAccount(List<String> adminAccount) {
105+
this.adminAccount = adminAccount;
106+
return this;
107+
}
108+
}
109+
}
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
package io.github.doocs.im.model.response;
2+
3+
import com.fasterxml.jackson.annotation.JsonProperty;
4+
5+
import java.io.Serializable;
6+
7+
/**
8+
* @author bingo
9+
* @since 2024/1/9 11:36
10+
*/
11+
public class AdminResultItem implements Serializable {
12+
private static final long serialVersionUID = 6608743524050558356L;
13+
14+
@JsonProperty("Admin_Account")
15+
private String adminAccount;
16+
17+
@JsonProperty("Avatar")
18+
private String avatar;
19+
20+
@JsonProperty("NickName")
21+
private String nickname;
22+
23+
public String getAdminAccount() {
24+
return adminAccount;
25+
}
26+
27+
public void setAdminAccount(String adminAccount) {
28+
this.adminAccount = adminAccount;
29+
}
30+
31+
public String getAvatar() {
32+
return avatar;
33+
}
34+
35+
public void setAvatar(String avatar) {
36+
this.avatar = avatar;
37+
}
38+
39+
public String getNickname() {
40+
return nickname;
41+
}
42+
43+
public void setNickname(String nickname) {
44+
this.nickname = nickname;
45+
}
46+
47+
@Override
48+
public String toString() {
49+
return "AdminResultItem{" +
50+
"adminAccount='" + adminAccount + '\'' +
51+
", avatar='" + avatar + '\'' +
52+
", nickname='" + nickname + '\'' +
53+
'}';
54+
}
55+
}

0 commit comments

Comments
 (0)