mirror of
https://github.com/SamyRai/tercul-backend.git
synced 2025-12-27 00:31:35 +00:00
43 lines
1.6 KiB
Go
43 lines
1.6 KiB
Go
package models
|
|
|
|
// BookWork represents the many-to-many relationship between books and works
|
|
type BookWork struct {
|
|
BaseModel
|
|
BookID uint `gorm:"index;uniqueIndex:uniq_book_work"`
|
|
Book *Book `gorm:"foreignKey:BookID"`
|
|
WorkID uint `gorm:"index;uniqueIndex:uniq_book_work"`
|
|
Work *Work `gorm:"foreignKey:WorkID"`
|
|
Order int `gorm:"default:0"` // For ordering works in books
|
|
}
|
|
|
|
// AuthorCountry represents the many-to-many relationship between authors and countries
|
|
type AuthorCountry struct {
|
|
BaseModel
|
|
AuthorID uint `gorm:"index;uniqueIndex:uniq_author_country"`
|
|
Author *Author `gorm:"foreignKey:AuthorID"`
|
|
CountryID uint `gorm:"index;uniqueIndex:uniq_author_country"`
|
|
Country *Country `gorm:"foreignKey:CountryID"`
|
|
}
|
|
|
|
// WorkAuthor represents authorship with role and order for a work
|
|
type WorkAuthor struct {
|
|
BaseModel
|
|
WorkID uint `gorm:"index;uniqueIndex:uniq_work_author_role"`
|
|
Work *Work `gorm:"foreignKey:WorkID"`
|
|
AuthorID uint `gorm:"index;uniqueIndex:uniq_work_author_role"`
|
|
Author *Author `gorm:"foreignKey:AuthorID"`
|
|
Role string `gorm:"size:50;default:'author';uniqueIndex:uniq_work_author_role"`
|
|
Ordinal int `gorm:"default:0"`
|
|
}
|
|
|
|
// BookAuthor represents book-level contributor role and order
|
|
type BookAuthor struct {
|
|
BaseModel
|
|
BookID uint `gorm:"index;uniqueIndex:uniq_book_author_role"`
|
|
Book *Book `gorm:"foreignKey:BookID"`
|
|
AuthorID uint `gorm:"index;uniqueIndex:uniq_book_author_role"`
|
|
Author *Author `gorm:"foreignKey:AuthorID"`
|
|
Role string `gorm:"size:50;default:'author';uniqueIndex:uniq_book_author_role"`
|
|
Ordinal int `gorm:"default:0"`
|
|
}
|