52 lines
2.6 KiB
Go
52 lines
2.6 KiB
Go
package repository
|
||
|
||
import (
|
||
"backend/pkg/chat/domain/entity"
|
||
"context"
|
||
)
|
||
|
||
type RoomRepository interface {
|
||
Room
|
||
Member
|
||
User
|
||
}
|
||
|
||
// ListRoomsReq 查詢聊天室列表的請求參數
|
||
type ListRoomsReq struct {
|
||
Status string // 聊天室狀態(active, archived 等)
|
||
PageSize int // 每頁大小
|
||
LastID string // 用於 cursor-based pagination
|
||
}
|
||
|
||
// CountRoomsReq 統計聊天室的請求參數
|
||
type CountRoomsReq struct {
|
||
Status string // 可選的狀態篩選
|
||
}
|
||
|
||
type Room interface {
|
||
Create(ctx context.Context, room *entity.Room) error // Create 創建聊天室
|
||
RoomGet(ctx context.Context, roomID string) (*entity.Room, error) // Get 獲取聊天室資訊
|
||
RoomUpdate(ctx context.Context, room *entity.Room) error // Update 更新聊天室資訊
|
||
RoomDelete(ctx context.Context, roomID string) error // Delete 刪除聊天室(同時需要刪除相關的成員和訊息)
|
||
RoomList(ctx context.Context, param ListRoomsReq) ([]entity.Room, error) // List 查詢聊天室列表(支援分頁和篩選)
|
||
RoomCount(ctx context.Context, param CountRoomsReq) (int64, error) // Count 統計聊天室總數
|
||
RoomExists(ctx context.Context, roomID string) (bool, error) // Exists 檢查聊天室是否存在
|
||
RoomGetByID(ctx context.Context, roomIDs []string) ([]entity.Room, error) // 取得 Room by id
|
||
}
|
||
|
||
type Member interface {
|
||
Insert(ctx context.Context, member *entity.RoomMember) error // Insert 添加成員到聊天室
|
||
Get(ctx context.Context, roomID, uid string) (*entity.RoomMember, error) // Get 獲取特定成員資訊
|
||
AllMembers(ctx context.Context, roomID string) ([]entity.RoomMember, error) // AllMembers 查詢聊天室所有成員
|
||
UpdateRole(ctx context.Context, member *entity.RoomMember) error // UpdateRole 更新成員資訊(例如更新角色)
|
||
DeleteMember(ctx context.Context, roomID, uid string) error // DeleteMember 刪除特定成員(某人退出聊天室)
|
||
DeleteRoom(ctx context.Context, roomID string) error // DeleteRoom 刪除整個聊天室的所有成員
|
||
Count(ctx context.Context, roomID string) (int64, error) // Count 計算聊天室成員數量
|
||
}
|
||
|
||
type User interface {
|
||
GetUserRooms(ctx context.Context, uid string) ([]entity.UserRoom, error) // GetUserRooms 查詢用戶所在的所有聊天室
|
||
CountUserRooms(ctx context.Context, uid string) (int64, error) // CountUserRooms 統計用戶所在的聊天室數量
|
||
IsUserInRoom(ctx context.Context, uid, roomID string) (bool, error) // IsUserInRoom 檢查用戶是否在某個聊天室中
|
||
}
|