37 lines
1.1 KiB
Go
37 lines
1.1 KiB
Go
package video
|
||
|
||
import (
|
||
"context"
|
||
)
|
||
|
||
// Mention 是一条待写入的提及通知。
|
||
type Mention struct {
|
||
RecipientID uint
|
||
SenderID uint
|
||
TargetID uint
|
||
Content string
|
||
DedupeKey string
|
||
}
|
||
|
||
type CommentStore interface {
|
||
// CreateIdempotentWithPopularity 在同一事务内插入评论并给热度加 delta。
|
||
// created=false 表示该意图已落库,调用方不得再加热度。
|
||
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)
|
||
}
|
||
|
||
// nilIfEmpty 供可空唯一列使用:空串会互撞,NULL 才是"没有这个键"。
|
||
func nilIfEmpty(s string) *string {
|
||
if s == "" {
|
||
return nil
|
||
}
|
||
return &s
|
||
}
|