tercul-backend/internal/models/interaction.go
Damir Mukimov fa336cacf3
wip
2025-09-01 00:43:59 +02:00

80 lines
2.8 KiB
Go

package models
import (
"time"
)
// Comment represents a user comment on a work or translation
type Comment struct {
BaseModel
Text string `gorm:"type:text;not null"`
UserID uint
User *User `gorm:"foreignKey:UserID"`
WorkID *uint
Work *Work `gorm:"foreignKey:WorkID"`
TranslationID *uint
Translation *Translation `gorm:"foreignKey:TranslationID"`
LineNumber *int `gorm:"index"`
TextBlockID *uint
TextBlock *TextBlock `gorm:"foreignKey:TextBlockID"`
ParentID *uint
Parent *Comment `gorm:"foreignKey:ParentID"`
Children []*Comment `gorm:"foreignKey:ParentID"`
Likes []*Like `gorm:"foreignKey:CommentID"`
}
// Like represents a user like on a work, translation, or comment
type Like struct {
BaseModel
UserID uint `gorm:"index;uniqueIndex:uniq_like_user_target"`
User *User `gorm:"foreignKey:UserID"`
WorkID *uint `gorm:"index;uniqueIndex:uniq_like_user_target"`
Work *Work `gorm:"foreignKey:WorkID"`
TranslationID *uint `gorm:"index;uniqueIndex:uniq_like_user_target"`
Translation *Translation `gorm:"foreignKey:TranslationID"`
CommentID *uint `gorm:"index;uniqueIndex:uniq_like_user_target"`
Comment *Comment `gorm:"foreignKey:CommentID"`
}
// Bookmark represents a user bookmark of a work
type Bookmark struct {
BaseModel
Name string `gorm:"size:100"`
UserID uint `gorm:"index;uniqueIndex:uniq_bookmark_user_work"`
User *User `gorm:"foreignKey:UserID"`
WorkID uint `gorm:"index;uniqueIndex:uniq_bookmark_user_work"`
Work *Work `gorm:"foreignKey:WorkID"`
Notes string `gorm:"type:text"`
LastReadAt *time.Time
Progress int `gorm:"default:0"` // Percentage of completion
}
// Collection represents a user-created collection of works
type Collection struct {
TranslatableModel
Name string `gorm:"size:100;not null"`
Description string `gorm:"type:text"`
UserID uint
User *User `gorm:"foreignKey:UserID"`
Works []*Work `gorm:"many2many:collection_works"`
IsPublic bool `gorm:"default:true"`
CoverImageURL string `gorm:"size:255"`
}
// Contribution represents a user contribution (work or translation)
type Contribution struct {
BaseModel
Name string `gorm:"size:100;not null"`
Status string `gorm:"size:20;default:'draft'"` // draft, submitted, reviewing, approved, rejected
UserID uint
User *User `gorm:"foreignKey:UserID"`
WorkID *uint
Work *Work `gorm:"foreignKey:WorkID"`
TranslationID *uint
Translation *Translation `gorm:"foreignKey:TranslationID"`
ReviewerID *uint
Reviewer *User `gorm:"foreignKey:ReviewerID"`
ReviewedAt *time.Time
Feedback string `gorm:"type:text"`
}