perf(chat): 分页客服会话并拆分统计查询
This commit is contained in:
@@ -60,8 +60,7 @@ func (r *Repository) FindConversation(ctx context.Context, principal Principal,
|
||||
var unreadCount int64
|
||||
if err := db.Table("chat_messages AS cm").
|
||||
Where("cm.conversation_id = ?", conversation.ID).
|
||||
Where("cm.sender_type <> ?", "system").
|
||||
Where("NOT (cm.sender_type = ? AND cm.sender_id = ?)", "admin", principal.ID).
|
||||
Where("(cm.admin_attention_type <> ? OR cm.sender_type = ?)", "", "user").
|
||||
Where("cm.id > ?", state.LastReadMessageID).
|
||||
Count(&unreadCount).Error; err != nil {
|
||||
return nil, err
|
||||
|
||||
Reference in New Issue
Block a user