Skip to content

Commit 51c004d

Browse files
committed
feat: add officialAccount api
1 parent 5d1845b commit 51c004d

16 files changed

+801
-76
lines changed

pom.xml

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -157,22 +157,22 @@
157157
<groupId>org.apache.maven.plugins</groupId>
158158
<artifactId>maven-jar-plugin</artifactId>
159159
<version>3.0.2</version>
160-
<configuration>
161-
<excludes>
162-
<exclude>**/app.properties</exclude>
163-
</excludes>
164-
</configuration>
160+
<!-- <configuration>-->
161+
<!-- <excludes>-->
162+
<!-- <exclude>**/app.properties</exclude>-->
163+
<!-- </excludes>-->
164+
<!-- </configuration>-->
165165
</plugin>
166166
</plugins>
167-
<resources>
168-
<resource>
169-
<directory>src/main/resources</directory>
170-
<filtering>true</filtering>
171-
<excludes>
172-
<exclude>app.properties</exclude>
173-
</excludes>
174-
</resource>
175-
</resources>
167+
<!-- <resources>-->
168+
<!-- <resource>-->
169+
<!-- <directory>src/main/resources</directory>-->
170+
<!-- <filtering>true</filtering>-->
171+
<!-- <excludes>-->
172+
<!-- <exclude>app.properties</exclude>-->
173+
<!-- </excludes>-->
174+
<!-- </resource>-->
175+
<!-- </resources>-->
176176
</build>
177177

178178
<profiles>

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

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ public class Message {
2020
public static final String SERVICE_NAME = "openim";
2121

2222
public static final String SERVICE_NAME_MSG_EXT = "openim_msg_ext_http_svc";
23+
public static final String SERVICE_NAME_GROUP = "group_open_http_svc";
2324

2425
/**
2526
* 单聊消息相关命令字
@@ -34,6 +35,8 @@ public class Message {
3435
public static final String MODIFY_C2C_MSG_COMMAND = "modify_c2c_msg";
3536
public static final String GET_KEY_VALUES_COMMAND = "get_key_values";
3637
public static final String SET_KEY_VALUES_COMMAND = "set_key_values";
38+
public static final String DELETE_C2C_MSG_RAMBLE_COMMAND = "delete_c2c_msg_ramble";
39+
public static final String CLEAR_GROUP_MSG_COMMAND = "clear_group_msg";
3740

3841
private final ImClient imClient;
3942

@@ -210,4 +213,38 @@ public SetKeyValuesResult setKeyValues(SetKeyValuesRequest setKeyValuesRequest,
210213
String url = imClient.getUrl(SERVICE_NAME_MSG_EXT, SET_KEY_VALUES_COMMAND, random);
211214
return HttpUtil.post(url, setKeyValuesRequest, SetKeyValuesResult.class, imClient.getConfig());
212215
}
216+
217+
/**
218+
* 单向删除单聊历史消息
219+
*
220+
* @param deleteC2cMsgRambleRequest 请求参数
221+
* @return 结果
222+
* @throws IOException 异常
223+
*/
224+
public DeleteC2cMsgRambleResult deleteC2cMsgRamble(DeleteC2cMsgRambleRequest deleteC2cMsgRambleRequest) throws IOException {
225+
String url = imClient.getUrl(SERVICE_NAME, DELETE_C2C_MSG_RAMBLE_COMMAND);
226+
return HttpUtil.post(url, deleteC2cMsgRambleRequest, DeleteC2cMsgRambleResult.class, imClient.getConfig());
227+
}
228+
229+
public DeleteC2cMsgRambleResult deleteC2cMsgRamble(DeleteC2cMsgRambleRequest deleteC2cMsgRambleRequest, long random) throws IOException {
230+
String url = imClient.getUrl(SERVICE_NAME, DELETE_C2C_MSG_RAMBLE_COMMAND, random);
231+
return HttpUtil.post(url, deleteC2cMsgRambleRequest, DeleteC2cMsgRambleResult.class, imClient.getConfig());
232+
}
233+
234+
/**
235+
* 清空群聊历史消息
236+
*
237+
* @param clearGroupMsgRequest 请求参数
238+
* @return 结果
239+
* @throws IOException 异常
240+
*/
241+
public ClearGroupMsgResult clearGroupMsg(ClearGroupMsgRequest clearGroupMsgRequest) throws IOException {
242+
String url = imClient.getUrl(SERVICE_NAME_GROUP, CLEAR_GROUP_MSG_COMMAND);
243+
return HttpUtil.post(url, clearGroupMsgRequest, ClearGroupMsgResult.class, imClient.getConfig());
244+
}
245+
246+
public ClearGroupMsgResult clearGroupMsg(ClearGroupMsgRequest clearGroupMsgRequest, long random) throws IOException {
247+
String url = imClient.getUrl(SERVICE_NAME_GROUP, CLEAR_GROUP_MSG_COMMAND, random);
248+
return HttpUtil.post(url, clearGroupMsgRequest, ClearGroupMsgResult.class, imClient.getConfig());
249+
}
213250
}

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

Lines changed: 44 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,8 @@
11
package io.github.doocs.im.core;
22

33
import io.github.doocs.im.ImClient;
4-
import io.github.doocs.im.model.request.CreateOfficialAccountRequest;
5-
import io.github.doocs.im.model.request.DestroyOfficialAccountRequest;
6-
import io.github.doocs.im.model.request.GetOfficialAccountInfoRequest;
7-
import io.github.doocs.im.model.request.GetSubscriberInfoRequest;
8-
import io.github.doocs.im.model.request.ModifyOfficialAccountBaseInfoRequest;
9-
import io.github.doocs.im.model.request.SendOfficialAccountMsgRequest;
10-
import io.github.doocs.im.model.response.CreateOfficialAccountResult;
11-
import io.github.doocs.im.model.response.DestroyOfficialAccountResult;
12-
import io.github.doocs.im.model.response.GetOfficialAccountInfoResult;
13-
import io.github.doocs.im.model.response.GetSubscriberInfoResult;
14-
import io.github.doocs.im.model.response.ModifyOfficialAccountBaseInfoResult;
15-
import io.github.doocs.im.model.response.SendOfficialAccountMsgResult;
4+
import io.github.doocs.im.model.request.*;
5+
import io.github.doocs.im.model.response.*;
166
import io.github.doocs.im.util.HttpUtil;
177

188
import java.io.IOException;
@@ -36,8 +26,10 @@ public class OfficialAccount {
3626
public static final String DESTROY_OFFICIAL_ACCOUNT = "destroy_official_account";
3727
public static final String MODIFY_OFFICIAL_ACCOUNT_BASE_INFO = "modify_official_account_base_info";
3828
public static final String SEND_OFFICIAL_ACCOUNT_MSG_COMMAND = "send_official_account_msg";
39-
public static final String GET_OFFICIAL_ACCOUNT_INFO = "get_official_account_info";
40-
public static final String GET_SUBSCRIBER_INFO = "get_subscriber_info";
29+
public static final String GET_OFFICIAL_ACCOUNT_INFO_COMMAND = "get_official_account_info";
30+
public static final String GET_SUBSCRIBER_INFO_COMMAND = "get_subscriber_info";
31+
public static final String OFFICIAL_ACCOUNT_MSG_RECALL_COMMAND = "official_account_msg_recall";
32+
public static final String OFFICIAL_ACCOUNT_MSG_GET_SIMPLE_COMMAND = "official_account_msg_get_simple";
4133

4234
private final ImClient imClient;
4335

@@ -121,12 +113,12 @@ public SendOfficialAccountMsgResult sendOfficialAccountMsg(SendOfficialAccountMs
121113
* @throws IOException 异常
122114
*/
123115
public GetOfficialAccountInfoResult getOfficialAccountInfo(GetOfficialAccountInfoRequest getOfficialAccountInfoRequest) throws IOException {
124-
String url = imClient.getUrl(SERVICE_NAME, GET_OFFICIAL_ACCOUNT_INFO);
116+
String url = imClient.getUrl(SERVICE_NAME, GET_OFFICIAL_ACCOUNT_INFO_COMMAND);
125117
return HttpUtil.post(url, getOfficialAccountInfoRequest, GetOfficialAccountInfoResult.class, imClient.getConfig());
126118
}
127119

128120
public GetOfficialAccountInfoResult getOfficialAccountInfo(GetOfficialAccountInfoRequest getOfficialAccountInfoRequest, long random) throws IOException {
129-
String url = imClient.getUrl(SERVICE_NAME, GET_OFFICIAL_ACCOUNT_INFO, random);
121+
String url = imClient.getUrl(SERVICE_NAME, GET_OFFICIAL_ACCOUNT_INFO_COMMAND, random);
130122
return HttpUtil.post(url, getOfficialAccountInfoRequest, GetOfficialAccountInfoResult.class, imClient.getConfig());
131123
}
132124

@@ -138,12 +130,46 @@ public GetOfficialAccountInfoResult getOfficialAccountInfo(GetOfficialAccountInf
138130
* @throws IOException 异常
139131
*/
140132
public GetSubscriberInfoResult getSubscriberInfo(GetSubscriberInfoRequest getSubscriberInfoRequest) throws IOException {
141-
String url = imClient.getUrl(SERVICE_NAME, GET_SUBSCRIBER_INFO);
133+
String url = imClient.getUrl(SERVICE_NAME, GET_SUBSCRIBER_INFO_COMMAND);
142134
return HttpUtil.post(url, getSubscriberInfoRequest, GetSubscriberInfoResult.class, imClient.getConfig());
143135
}
144136

145137
public GetSubscriberInfoResult getSubscriberInfo(GetSubscriberInfoRequest getSubscriberInfoRequest, long random) throws IOException {
146-
String url = imClient.getUrl(SERVICE_NAME, GET_SUBSCRIBER_INFO, random);
138+
String url = imClient.getUrl(SERVICE_NAME, GET_SUBSCRIBER_INFO_COMMAND, random);
147139
return HttpUtil.post(url, getSubscriberInfoRequest, GetSubscriberInfoResult.class, imClient.getConfig());
148140
}
141+
142+
/**
143+
* 撤回公众号消息
144+
*
145+
* @param officialAccountMsgRecallRequest 请求参数
146+
* @return 结果
147+
* @throws IOException 异常
148+
*/
149+
public OfficialAccountMsgRecallResult msgRecall(OfficialAccountMsgRecallRequest officialAccountMsgRecallRequest) throws IOException {
150+
String url = imClient.getUrl(SERVICE_NAME, OFFICIAL_ACCOUNT_MSG_RECALL_COMMAND);
151+
return HttpUtil.post(url, officialAccountMsgRecallRequest, OfficialAccountMsgRecallResult.class, imClient.getConfig());
152+
}
153+
154+
public OfficialAccountMsgRecallResult msgRecall(OfficialAccountMsgRecallRequest officialAccountMsgRecallRequest, long random) throws IOException {
155+
String url = imClient.getUrl(SERVICE_NAME, OFFICIAL_ACCOUNT_MSG_RECALL_COMMAND, random);
156+
return HttpUtil.post(url, officialAccountMsgRecallRequest, OfficialAccountMsgRecallResult.class, imClient.getConfig());
157+
}
158+
159+
/**
160+
* 拉取公众号用户历史消息
161+
*
162+
* @param officialAccountMsgGetSimpleRequest 请求参数
163+
* @return 结果
164+
* @throws IOException 异常
165+
*/
166+
public OfficialAccountMsgGetSimpleResult msgGetSimple(OfficialAccountMsgGetSimpleRequest officialAccountMsgGetSimpleRequest) throws IOException {
167+
String url = imClient.getUrl(SERVICE_NAME, OFFICIAL_ACCOUNT_MSG_GET_SIMPLE_COMMAND);
168+
return HttpUtil.post(url, officialAccountMsgGetSimpleRequest, OfficialAccountMsgGetSimpleResult.class, imClient.getConfig());
169+
}
170+
171+
public OfficialAccountMsgGetSimpleResult msgGetSimple(OfficialAccountMsgGetSimpleRequest officialAccountMsgGetSimpleRequest, long random) throws IOException {
172+
String url = imClient.getUrl(SERVICE_NAME, OFFICIAL_ACCOUNT_MSG_GET_SIMPLE_COMMAND, random);
173+
return HttpUtil.post(url, officialAccountMsgGetSimpleRequest, OfficialAccountMsgGetSimpleResult.class, imClient.getConfig());
174+
}
149175
}

src/main/java/io/github/doocs/im/model/request/AdminGetRoamMsgRequest.java

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,18 @@
1414
@JsonInclude(JsonInclude.Include.NON_NULL)
1515
public class AdminGetRoamMsgRequest extends GenericRequest implements Serializable {
1616
private static final long serialVersionUID = -1979505757549864474L;
17+
1718
/**
18-
* 会话其中一方的 UserID,若已指定发送消息方账号,则为消息发送方
19+
* 会话其中一方的 UserID,以该 UserID 的角度去查询消息。同一个会话,分别以会话双方的角度去查询消息,结果可能会不一样,请参考本接口的接口说明
1920
*/
20-
@JsonProperty("From_Account")
21-
private String fromAccount;
21+
@JsonProperty("Operator_Account")
22+
private String operatorAccount;
2223

2324
/**
24-
* 会话其中一方的 UserID
25+
* 会话的另一方 UserID
2526
*/
26-
@JsonProperty("To_Account")
27-
private String toAccount;
27+
@JsonProperty("Peer_Account")
28+
private String peerAccount;
2829

2930
/**
3031
* 请求的消息条数
@@ -53,27 +54,26 @@ public class AdminGetRoamMsgRequest extends GenericRequest implements Serializab
5354
public AdminGetRoamMsgRequest() {
5455
}
5556

56-
public AdminGetRoamMsgRequest(String fromAccount, String toAccount, Integer maxCnt, Integer minTime, Integer maxTime) {
57-
this.fromAccount = fromAccount;
58-
this.toAccount = toAccount;
57+
public AdminGetRoamMsgRequest(String operatorAccount, String peerAccount, Integer maxCnt, Integer minTime, Integer maxTime) {
58+
this.operatorAccount = operatorAccount;
59+
this.peerAccount = peerAccount;
5960
this.maxCnt = maxCnt;
6061
this.minTime = minTime;
6162
this.maxTime = maxTime;
6263
}
6364

64-
public AdminGetRoamMsgRequest(String fromAccount, String toAccount, Integer maxCnt, Integer minTime,
65-
Integer maxTime, String lastMsgKey) {
66-
this.fromAccount = fromAccount;
67-
this.toAccount = toAccount;
65+
public AdminGetRoamMsgRequest(String operatorAccount, String peerAccount, Integer maxCnt, Integer minTime, Integer maxTime, String lastMsgKey) {
66+
this.operatorAccount = operatorAccount;
67+
this.peerAccount = peerAccount;
6868
this.maxCnt = maxCnt;
6969
this.minTime = minTime;
7070
this.maxTime = maxTime;
7171
this.lastMsgKey = lastMsgKey;
7272
}
7373

7474
private AdminGetRoamMsgRequest(Builder builder) {
75-
this.fromAccount = builder.fromAccount;
76-
this.toAccount = builder.toAccount;
75+
this.operatorAccount = builder.operatorAccount;
76+
this.peerAccount = builder.peerAccount;
7777
this.maxCnt = builder.maxCnt;
7878
this.minTime = builder.minTime;
7979
this.maxTime = builder.maxTime;
@@ -84,20 +84,20 @@ public static Builder builder() {
8484
return new Builder();
8585
}
8686

87-
public String getFromAccount() {
88-
return fromAccount;
87+
public String getOperatorAccount() {
88+
return operatorAccount;
8989
}
9090

91-
public void setFromAccount(String fromAccount) {
92-
this.fromAccount = fromAccount;
91+
public void setOperatorAccount(String operatorAccount) {
92+
this.operatorAccount = operatorAccount;
9393
}
9494

95-
public String getToAccount() {
96-
return toAccount;
95+
public String getPeerAccount() {
96+
return peerAccount;
9797
}
9898

99-
public void setToAccount(String toAccount) {
100-
this.toAccount = toAccount;
99+
public void setPeerAccount(String peerAccount) {
100+
this.peerAccount = peerAccount;
101101
}
102102

103103
public Integer getMaxCnt() {
@@ -134,8 +134,8 @@ public void setLastMsgKey(String lastMsgKey) {
134134

135135

136136
public static final class Builder {
137-
private String fromAccount;
138-
private String toAccount;
137+
private String operatorAccount;
138+
private String peerAccount;
139139
private Integer maxCnt;
140140
private Integer minTime;
141141
private Integer maxTime;
@@ -148,13 +148,13 @@ public AdminGetRoamMsgRequest build() {
148148
return new AdminGetRoamMsgRequest(this);
149149
}
150150

151-
public Builder fromAccount(String fromAccount) {
152-
this.fromAccount = fromAccount;
151+
public Builder operatorAccount(String operatorAccount) {
152+
this.operatorAccount = operatorAccount;
153153
return this;
154154
}
155155

156-
public Builder toAccount(String toAccount) {
157-
this.toAccount = toAccount;
156+
public Builder peerAccount(String peerAccount) {
157+
this.peerAccount = peerAccount;
158158
return this;
159159
}
160160

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
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/10 10:25
13+
*/
14+
@JsonInclude(JsonInclude.Include.NON_NULL)
15+
public class ClearGroupMsgRequest extends GenericRequest implements Serializable {
16+
private static final long serialVersionUID = 1822917977659354031L;
17+
@JsonProperty("GroupId")
18+
private String groupId;
19+
20+
@JsonProperty("MsgSeq")
21+
private Long msgSeq;
22+
23+
public ClearGroupMsgRequest() {
24+
}
25+
26+
public ClearGroupMsgRequest(String groupId) {
27+
this.groupId = groupId;
28+
}
29+
30+
public ClearGroupMsgRequest(String groupId, Long msgSeq) {
31+
this.groupId = groupId;
32+
this.msgSeq = msgSeq;
33+
}
34+
35+
private ClearGroupMsgRequest(Builder builder) {
36+
this.groupId = builder.groupId;
37+
this.msgSeq = builder.msgSeq;
38+
}
39+
40+
public static Builder builder() {
41+
return new Builder();
42+
}
43+
44+
public String getGroupId() {
45+
return groupId;
46+
}
47+
48+
public void setGroupId(String groupId) {
49+
this.groupId = groupId;
50+
}
51+
52+
public Long getMsgSeq() {
53+
return msgSeq;
54+
}
55+
56+
public void setMsgSeq(Long msgSeq) {
57+
this.msgSeq = msgSeq;
58+
}
59+
60+
61+
public static final class Builder {
62+
private String groupId;
63+
private Long msgSeq;
64+
65+
private Builder() {
66+
}
67+
68+
public ClearGroupMsgRequest build() {
69+
return new ClearGroupMsgRequest(this);
70+
}
71+
72+
public Builder groupId(String groupId) {
73+
this.groupId = groupId;
74+
return this;
75+
}
76+
77+
public Builder msgSeq(Long msgSeq) {
78+
this.msgSeq = msgSeq;
79+
return this;
80+
}
81+
}
82+
}

0 commit comments

Comments
 (0)