package video import "time" type Comment struct { ID uint `gorm:"primaryKey" json:"id"` Username string `gorm:"index" json:"username"` VideoID uint `gorm:"index" json:"video_id"` AuthorID uint `gorm:"index;uniqueIndex:uk_comments_author_key,priority:1" json:"author_id"` Content string `gorm:"type:text" json:"content"` CreatedAt time.Time `gorm:"autoCreateTime" json:"created_at"` // IdempotencyKey 必须是 *string:空串会互撞唯一索引,NULL 不会。 IdempotencyKey *string `gorm:"column:idempotency_key;type:varchar(64);uniqueIndex:uk_comments_author_key,priority:2" json:"-"` } type PublishCommentRequest struct { VideoID uint `json:"video_id"` Content string `json:"content"` // RequestID 由客户端为一次发送动作生成,重试时复用;为空则服务端生成。 RequestID string `json:"request_id"` } type DeleteCommentRequest struct { CommentID uint `json:"comment_id"` } type GetAllCommentsRequest struct { VideoID uint `json:"video_id"` }