2026-10-30 13:21:09 +08:00
|
|
|
|
package video
|
|
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
|
"context"
|
|
|
|
|
|
)
|
|
|
|
|
|
|
2026-10-31 00:03:53 +08:00
|
|
|
|
// Mention 是一条待写入的提及通知。
|
2026-10-30 13:21:09 +08:00
|
|
|
|
type Mention struct {
|
|
|
|
|
|
RecipientID uint
|
|
|
|
|
|
SenderID uint
|
|
|
|
|
|
TargetID uint
|
|
|
|
|
|
Content string
|
|
|
|
|
|
DedupeKey string
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
type CommentStore interface {
|
2026-10-31 00:03:53 +08:00
|
|
|
|
// CreateIdempotentWithPopularity 在同一事务内插入评论并给热度加 delta。
|
|
|
|
|
|
// created=false 表示该意图已落库,调用方不得再加热度。
|
2026-10-30 13:21:09 +08:00
|
|
|
|
CreateIdempotentWithPopularity(ctx context.Context, c *Comment, delta int64) (created bool, err error)
|
|
|
|
|
|
|
|
|
|
|
|
GetByID(ctx context.Context, id uint) (*Comment, error)
|
|
|
|
|
|
DeleteComment(ctx context.Context, comment *Comment) error
|
|
|
|
|
|
DeleteByID(ctx context.Context, id uint) (deleted bool, err error)
|
|
|
|
|
|
GetAllComments(ctx context.Context, videoID uint) ([]Comment, error)
|
|
|
|
|
|
|
|
|
|
|
|
CreateMentions(ctx context.Context, mentions []Mention) error
|
|
|
|
|
|
FindAccountIDs(ctx context.Context, usernames []string) (map[string]uint, error)
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-10-31 00:03:53 +08:00
|
|
|
|
// nilIfEmpty 供可空唯一列使用:空串会互撞,NULL 才是"没有这个键"。
|
2026-10-30 13:21:09 +08:00
|
|
|
|
func nilIfEmpty(s string) *string {
|
|
|
|
|
|
if s == "" {
|
|
|
|
|
|
return nil
|
|
|
|
|
|
}
|
|
|
|
|
|
return &s
|
|
|
|
|
|
}
|