Files
CamTalk/backend/internal/store/session.go

48 lines
1.2 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 store
import (
"context"
"errors"
"time"
)
var (
// ErrSessionNotFound 会话不存在。
ErrSessionNotFound = errors.New("session not found")
)
// SessionRepository 会话持久化接口。
type SessionRepository interface {
// Save 创建或更新会话UPSERT
Save(ctx context.Context, s SessionRecord) error
// FindByID 根据 ID 查询会话。
FindByID(ctx context.Context, id string) (*SessionRecord, error)
// FindByUser 查询用户的会话列表(分页,按 updated_at 降序)。
// 返回 (列表, 总数, error)。
FindByUser(ctx context.Context, userID string, page, size int) ([]SessionRecord, int, error)
// UpdateTitle 更新会话标题。
UpdateTitle(ctx context.Context, id string, title string) error
// UpdateConfig 更新会话配置。
UpdateConfig(ctx context.Context, id string, configJSON []byte) error
// Touch 刷新 updated_at。
Touch(ctx context.Context, id string) error
// Delete 删除会话。
Delete(ctx context.Context, id string) error
}
// SessionRecord 持久化会话模型store 层)。
type SessionRecord struct {
ID string
UserID string
Title string
Config []byte // JSON 编码的 SessionConfig
CreatedAt time.Time
UpdatedAt time.Time
}