Skip to content

Commit

Permalink
feat: add group api
Browse files Browse the repository at this point in the history
* 添加获取指定群成员详细资料 api
* 升级至 v0.4.10
  • Loading branch information
yanglbme committed Dec 3, 2024
1 parent 534b24d commit 05c4cab
Show file tree
Hide file tree
Showing 13 changed files with 263 additions and 11 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ If you're using Maven, just add the following dependency in `pom.xml`.
<dependency>
<groupId>io.github.doocs</groupId>
<artifactId>im-server-sdk-java</artifactId>
<version>0.4.09</version>
<version>0.4.10</version>
</dependency>
```

Expand Down
2 changes: 1 addition & 1 deletion README_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ https://doocs.github.io/qcloud-im-server-sdk-java
<dependency>
<groupId>io.github.doocs</groupId>
<artifactId>im-server-sdk-java</artifactId>
<version>0.4.09</version>
<version>0.4.10</version>
</dependency>
```

Expand Down
2 changes: 1 addition & 1 deletion docs/guide/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# 介绍

本文档基于腾讯云 IM Server SDK Java <Badge type="tip" text="v0.4.09" vertical="top" /> 编写。
本文档基于腾讯云 IM Server SDK Java <Badge type="tip" text="v0.4.10" vertical="top" /> 编写。

## 前提条件

Expand Down
31 changes: 30 additions & 1 deletion docs/guide/group.md
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,35 @@ GetGroupMemberInfoRequest request = GetGroupMemberInfoRequest.builder()
GetGroupMemberInfoResult result = client.group.getGroupMemberInfo(request);
```

## 获取指定群成员详细资料

App 管理员可根据群组 ID 与群内指定成员 UserID 列表等参数获取指定群组成员的资料。

::: tip
适用的群组类型

| 群组类型 ID | 是否支持此 REST API |
| ----------------- | ---------------------------------------- |
| Private | 支持,同新版本中的 Work(好友工作群) |
| Public | 支持 |
| ChatRoom | 支持,同新版本中的 Meeting(临时会议群) |
| AVChatRoom | 不支持 |
| Community(社群) | 支持 |

即时通信 IM 内置上述群组类型,详情介绍请参见 [群组系统](https://cloud.tencent.com/document/product/269/1502)
:::

使用示例:

```java
GetSpecifiedGroupMemberInfoRequest request = GetSpecifiedGroupMemberInfoRequest.builder()
.groupId("MyFirstGroup")
.memberInfoFilter(Collections.singletonList("bingo"))
.build();

GetSpecifiedGroupMemberInfoResult result = client.group.getSpecifiedGroupMemberInfo(request);
```

## 修改群基础资料

App 管理员可以通过该接口修改指定群组的基础信息。
Expand Down Expand Up @@ -1471,4 +1500,4 @@ CheckMembersRequest request = CheckMembersRequest.builder()
.build();

CheckMembersResult result = client.group.checkMembers(request);
```
```
4 changes: 2 additions & 2 deletions docs/guide/quickstart.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@
<dependency>
<groupId>io.github.doocs</groupId>
<artifactId>im-server-sdk-java</artifactId>
<version>0.4.09</version>
<version>0.4.10</version>
</dependency>
```

### Gradle

```gradle
implementation group: 'io.github.doocs', name: 'im-server-sdk-java', version: '0.4.09'
implementation group: 'io.github.doocs', name: 'im-server-sdk-java', version: '0.4.10'
```

### 下载 JAR
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "qcloud-im-server-sdk-java",
"version": "0.4.09",
"version": "0.4.10",
"description": "腾讯云 IM 服务端 SDK API 文档 Java 版",
"main": "index.js",
"scripts": {
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>io.github.doocs</groupId>
<artifactId>im-server-sdk-java</artifactId>
<version>0.4.09</version>
<version>0.4.10</version>
<packaging>jar</packaging>

<name>qcloud-im-server-sdk-java</name>
Expand Down
18 changes: 18 additions & 0 deletions src/main/java/io/github/doocs/im/core/Group.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ public class Group {
public static final String CREATE_GROUP_COMMAND = "create_group";
public static final String GET_GROUP_INFO_COMMAND = "get_group_info";
public static final String GET_GROUP_MEMBER_INFO_COMMAND = "get_group_member_info";
public static final String GET_SPECIFIED_GROUP_MEMBER_INFO_COMMAND = "get_specified_group_member_info";
public static final String MODIFY_GROUP_BASE_INFO_COMMAND = "modify_group_base_info";
public static final String ADD_GROUP_MEMBER_COMMAND = "add_group_member";
public static final String DELETE_GROUP_MEMBER_COMMAND = "delete_group_member";
Expand Down Expand Up @@ -154,6 +155,23 @@ public GetGroupMemberInfoResult getGroupMemberInfo(GetGroupMemberInfoRequest get
return HttpUtil.post(url, getGroupMemberInfoRequest, GetGroupMemberInfoResult.class, imClient.getConfig());
}

/**
* 获取指定群成员详细资料
*
* @param getSpecifiedGroupMemberInfoRequest 请求参数
* @return 结果
* @throws IOException 异常
*/
public GetSpecifiedGroupMemberInfoResult getSpecifiedGroupMemberInfo(GetSpecifiedGroupMemberInfoRequest getSpecifiedGroupMemberInfoRequest) throws IOException {
String url = imClient.getUrl(SERVICE_NAME, GET_SPECIFIED_GROUP_MEMBER_INFO_COMMAND);
return HttpUtil.post(url, getSpecifiedGroupMemberInfoRequest, GetSpecifiedGroupMemberInfoResult.class, imClient.getConfig());
}

public GetSpecifiedGroupMemberInfoResult getSpecifiedGroupMemberInfo(GetSpecifiedGroupMemberInfoRequest getSpecifiedGroupMemberInfoRequest, long random) throws IOException {
String url = imClient.getUrl(SERVICE_NAME, GET_SPECIFIED_GROUP_MEMBER_INFO_COMMAND, random);
return HttpUtil.post(url, getSpecifiedGroupMemberInfoRequest, GetSpecifiedGroupMemberInfoResult.class, imClient.getConfig());
}

/**
* 修改群基础资料
*
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,143 @@
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 bingo
* @since 2024/12/02 08:04
*/
@JsonInclude(JsonInclude.Include.NON_NULL)
public class GetSpecifiedGroupMemberInfoRequest extends GenericRequest implements Serializable {
private static final long serialVersionUID = -1588717038990106029L;

@JsonProperty("GroupId")
private String groupId;

@JsonProperty("Member_List_Account")
private List<String> memberListAccount;

@JsonProperty("MemberInfoFilter")
private List<String> memberInfoFilter;

@JsonProperty("MemberRoleFilter")
private List<String> memberRoleFilter;

@JsonProperty("AppDefinedDataFilter_GroupMember")
private List<String> appDefinedDataFilterGroupMember;

public GetSpecifiedGroupMemberInfoRequest() {
}

public GetSpecifiedGroupMemberInfoRequest(String groupId, List<String> memberListAccount) {
this.groupId = groupId;
this.memberListAccount = memberListAccount;
}

public GetSpecifiedGroupMemberInfoRequest(String groupId, List<String> memberListAccount,
List<String> memberInfoFilter, List<String> memberRoleFilter,
List<String> appDefinedDataFilterGroupMember) {
this.groupId = groupId;
this.memberListAccount = memberListAccount;
this.memberInfoFilter = memberInfoFilter;
this.memberRoleFilter = memberRoleFilter;
this.appDefinedDataFilterGroupMember = appDefinedDataFilterGroupMember;
}

public String getGroupId() {
return groupId;
}

public void setGroupId(String groupId) {
this.groupId = groupId;
}

public List<String> getMemberListAccount() {
return memberListAccount;
}

public void setMemberListAccount(List<String> memberListAccount) {
this.memberListAccount = memberListAccount;
}

public List<String> getMemberInfoFilter() {
return memberInfoFilter;
}

public void setMemberInfoFilter(List<String> memberInfoFilter) {
this.memberInfoFilter = memberInfoFilter;
}

public List<String> getMemberRoleFilter() {
return memberRoleFilter;
}

public void setMemberRoleFilter(List<String> memberRoleFilter) {
this.memberRoleFilter = memberRoleFilter;
}

public List<String> getAppDefinedDataFilterGroupMember() {
return appDefinedDataFilterGroupMember;
}

public void setAppDefinedDataFilterGroupMember(List<String> appDefinedDataFilterGroupMember) {
this.appDefinedDataFilterGroupMember = appDefinedDataFilterGroupMember;
}

private GetSpecifiedGroupMemberInfoRequest(Builder builder) {
this.groupId = builder.groupId;
this.memberListAccount = builder.memberListAccount;
this.memberInfoFilter = builder.memberInfoFilter;
this.memberRoleFilter = builder.memberRoleFilter;
this.appDefinedDataFilterGroupMember = builder.appDefinedDataFilterGroupMember;
}

public static Builder builder() {
return new Builder();
}

public static final class Builder {
private String groupId;
private List<String> memberListAccount;
private List<String> memberInfoFilter;
private List<String> memberRoleFilter;
private List<String> appDefinedDataFilterGroupMember;

private Builder() {
}

public GetSpecifiedGroupMemberInfoRequest build() {
return new GetSpecifiedGroupMemberInfoRequest(this);
}

public Builder groupId(String groupId) {
this.groupId = groupId;
return this;
}

public Builder memberListAccount(List<String> memberListAccount) {
this.memberListAccount = memberListAccount;
return this;
}

public Builder memberInfoFilter(List<String> memberInfoFilter) {
this.memberInfoFilter = memberInfoFilter;
return this;
}

public Builder memberRoleFilter(List<String> memberRoleFilter) {
this.memberRoleFilter = memberRoleFilter;
return this;
}

public Builder appDefinedDataFilterGroupMember(List<String> appDefinedDataFilterGroupMember) {
this.appDefinedDataFilterGroupMember = appDefinedDataFilterGroupMember;
return this;
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
package io.github.doocs.im.model.response;

import com.fasterxml.jackson.annotation.JsonProperty;
import io.github.doocs.im.model.group.MemberProfile;

import java.io.Serializable;
import java.util.List;

/**
* 获取群成员详细资料-结果
*
* @author bingo
* @since 2024/12/02 08:18
*/
public class GetSpecifiedGroupMemberInfoResult extends GenericResult implements Serializable {
private static final long serialVersionUID = -5466167278504273597L;

@JsonProperty("GroupId")
private String groupId;

@JsonProperty("MemberList")
private List<MemberProfile> memberList;

public String getGroupId() {
return groupId;
}

public void setGroupId(String groupId) {
this.groupId = groupId;
}

public List<MemberProfile> getMemberList() {
return memberList;
}

public void setMemberList(List<MemberProfile> memberList) {
this.memberList = memberList;
}

@Override
public String toString() {
return "GetSpecifiedGroupMemberInfoResult{" +
"groupId='" + groupId + '\'' +
", memberList=" + memberList +
", actionStatus='" + actionStatus + '\'' +
", errorInfo='" + errorInfo + '\'' +
", errorCode=" + errorCode +
'}';
}
}
2 changes: 1 addition & 1 deletion src/main/resources/version.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
version=0.4.09
version=0.4.10
12 changes: 12 additions & 0 deletions src/test/java/io/github/doocs/im/core/GroupTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,18 @@ void testGetGroupMemberInfo() throws IOException {
Assertions.assertEquals(ErrorCode.SUCCESS.getCode(), result.getErrorCode());
}

@Test
void testGetSpecifiedGroupMemberInfo() throws IOException {
GetSpecifiedGroupMemberInfoRequest request = GetSpecifiedGroupMemberInfoRequest.builder()
.groupId("MyFirstGroup")
.memberInfoFilter(Collections.singletonList("bingo"))
.build();

GetSpecifiedGroupMemberInfoResult result = client.group.getSpecifiedGroupMemberInfo(request);
System.out.println(result);
Assertions.assertEquals(ErrorCode.SUCCESS.getCode(), result.getErrorCode());
}

@Test
void testModifyGroupBaseInfo() throws IOException {
ModifyGroupBaseInfoRequest request = ModifyGroupBaseInfoRequest.builder()
Expand Down

0 comments on commit 05c4cab

Please sign in to comment.