Files
VLoop/backend/internal/video/comment_entity.go

32 lines
1.0 KiB
Go
Raw Normal View History

2025-12-16 18:51:50 +08:00
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"`
2025-12-16 18:51:50 +08:00
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:"-"`
2025-12-16 18:51:50 +08:00
}
type PublishCommentRequest struct {
VideoID uint `json:"video_id"`
Content string `json:"content"`
// RequestID 由客户端为一次发送动作生成,重试时复用;为空则服务端生成。
RequestID string `json:"request_id"`
2025-12-16 18:51:50 +08:00
}
type DeleteCommentRequest struct {
CommentID uint `json:"comment_id"`
}
type GetAllCommentsRequest struct {
VideoID uint `json:"video_id"`
}