content page

This commit is contained in:
Daniel Noulet 2026-09-19 15:11:12 +02:00
parent fd2877da9e
commit 36b2c56987
14 changed files with 590 additions and 20 deletions

View file

@ -21,10 +21,28 @@ type ContentModel struct {
Body string `gorm:"not null"`
Status string `gorm:"not null;default:'draft'"`
Published bool `gorm:"not null;default:false"`
CategoryID uint
Category CategoryModel `gorm:"foreignKey:CategoryID"`
Badges []BadgeModel `gorm:"many2many:content_badges;joinForeignKey:ContentID;joinReferences:BadgeID"`
CreatedAt, UpdatedAt time.Time
CreatedBy, UpdatedBy uint
}
type CategoryModel struct {
ID uint `gorm:"primaryKey"`
Slug string `gorm:"uniqueIndex;not null"`
Name string `gorm:"not null"`
}
func (CategoryModel) TableName() string { return "categories" }
type BadgeModel struct {
ID uint `gorm:"primaryKey"`
Name string `gorm:"uniqueIndex;not null"`
}
func (BadgeModel) TableName() string { return "badges" }
func (ContentModel) TableName() string { return "content" }
type ContentHistoryModel struct {