liyong
112 分钟以前 8f5be003e52fdbf034d1955216143bd184ebbdb4
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
package cn.iocoder.yudao.module.im.service.conversation;
 
import cn.iocoder.yudao.module.im.dal.dataobject.conversation.ImConversationReadDO;
 
import java.util.Collection;
import java.util.List;
import java.util.Map;
 
/**
 * IM 会话读位置 Service 接口
 *
 * @author 芋道源码
 */
public interface ImConversationReadService {
 
    /**
     * 更新用户在某会话的最大已读位置(单调递增,乱序 / 并发上报不会回退)
     *
     * @param userId           用户编号
     * @param conversationType 会话类型
     * @param conversationId   会话编号
     * @param readMessageId    已读到的最大消息编号
     * @return 读位置是否前进;true 时调用方才需要下发已读 / 回执事件
     */
    boolean updateConversationReadPosition(Long userId, Integer conversationType, Long conversationId, Long readMessageId);
 
    /**
     * 获取用户在某会话的最大已读位置
     *
     * @param userId           用户编号
     * @param conversationType 会话类型
     * @param conversationId   会话编号
     * @return 最大已读消息编号;不存在则返回 null
     */
    Long getConversationReadMessageId(Long userId, Integer conversationType, Long conversationId);
 
    /**
     * 获取某会话内所有用户的读位置(用于群回执人数聚合)
     *
     * @param conversationType 会话类型
     * @param conversationId   会话编号
     * @return userId → 最大已读消息编号
     */
    Map<Long, Long> getUserReadMessageIdMap(Integer conversationType, Long conversationId);
 
    /**
     * 批量获取某用户在多个会话的读位置(用于频道批量读位置、重连后按活跃会话补偿)
     *
     * @param userId           用户编号
     * @param conversationType 会话类型
     * @param conversationIds  会话编号集合
     * @return conversationId → 最大已读消息编号
     */
    Map<Long, Long> getConversationReadMessageIdMap(Long userId, Integer conversationType, Collection<Long> conversationIds);
 
    /**
     * 增量拉取当前用户的会话读位置(重连 / 离线补偿:按 update_time + id 游标)
     *
     * @param userId         用户编号
     * @param lastUpdateTime 上次拉取到的最新更新时间(毫秒时间戳);首次拉取传 null
     * @param lastId         上次拉取到的最后一条记录 id;首次拉取传 null
     * @param limit          单次拉取条数
     * @return 会话读位置列表,按更新时间、id 正序
     */
    List<ImConversationReadDO> pullConversationReadList(Long userId, Long lastUpdateTime, Long lastId, Integer limit);
 
}