backend/pkg/chat/domain/repository/message.go

42 lines
1.1 KiB
Go
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package repository
import (
"backend/pkg/chat/domain/entity"
"context"
)
// MessageRepository 定義訊息相關的資料存取介面
type MessageRepository interface {
// Insert 插入訊息
Insert(ctx context.Context, msg *entity.Message) error
// ListMessages 查詢訊息列表(分頁)
ListMessages(ctx context.Context, param ListMessagesReq) ([]entity.Message, error)
// Count 計算符合條件的訊息總數
Count(ctx context.Context, RoomID string) (int64, error)
// CheckAndInsertDedup 檢查並插入去重記錄,如果已存在則返回 true表示重複
CheckAndInsertDedup(ctx context.Context, param CheckDupReq) (bool, error)
}
type SendMessageReq struct {
RoomID string
UID string
Content string
ClientMsgID string
}
type ListMessagesReq struct {
RoomID string
BucketDay string
PageSize int
// LastTS 用於 cursor-based pagination獲取 ts < LastTS 的訊息
// 如果為 0則獲取最新的訊息
LastTS int64
}
type CheckDupReq struct {
RoomID string
UID string
BucketSec int64
ContentMD5 string
}