42 lines
1.1 KiB
Go
42 lines
1.1 KiB
Go
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
|
||
}
|