mirror of
https://github.com/SamyRai/tercul-backend.git
synced 2025-12-27 00:31:35 +00:00
41 lines
1.3 KiB
Go
41 lines
1.3 KiB
Go
package models
|
|
|
|
// Tag represents a tag for categorizing works
|
|
type Tag struct {
|
|
BaseModel
|
|
Name string `gorm:"size:100;not null;uniqueIndex"`
|
|
Description string `gorm:"type:text"`
|
|
Works []*Work `gorm:"many2many:work_tags"`
|
|
Slug string `gorm:"size:255;index"`
|
|
}
|
|
|
|
// Category represents a category for organizing works
|
|
type Category struct {
|
|
BaseModel
|
|
Name string `gorm:"size:100;not null;uniqueIndex"`
|
|
Description string `gorm:"type:text"`
|
|
ParentID *uint
|
|
Parent *Category `gorm:"foreignKey:ParentID"`
|
|
Children []*Category `gorm:"foreignKey:ParentID"`
|
|
Works []*Work `gorm:"many2many:work_categories"`
|
|
Path string `gorm:"size:1024;index"`
|
|
Slug string `gorm:"size:255;index"`
|
|
}
|
|
|
|
// Series represents a literary series
|
|
type Series struct {
|
|
BaseModel
|
|
Name string `gorm:"size:255;not null;uniqueIndex"`
|
|
Description string `gorm:"type:text"`
|
|
}
|
|
|
|
// WorkSeries is a join capturing a work's position in a series
|
|
type WorkSeries struct {
|
|
BaseModel
|
|
WorkID uint `gorm:"index;uniqueIndex:uniq_work_series"`
|
|
Work *Work `gorm:"foreignKey:WorkID"`
|
|
SeriesID uint `gorm:"index;uniqueIndex:uniq_work_series"`
|
|
Series *Series `gorm:"foreignKey:SeriesID"`
|
|
NumberInSeries int `gorm:"default:0"`
|
|
}
|