文章和文件建立关联

This commit is contained in:
2026-08-19 17:39:23 +08:00
parent f1a6c5abaa
commit 4a9ac54963
13 changed files with 256 additions and 28 deletions
+1
View File
@@ -86,6 +86,7 @@ type Post struct {
CategoryID uint `gorm:"index" json:"category_id"` // 增加索引
Category Category `gorm:"foreignKey:CategoryID" json:"category"`
Tags []Tag `gorm:"many2many:post_tags;" json:"tags"`
Files []File `gorm:"many2many:post_files;" json:"files,omitempty"` // 关联文件
Views int `gorm:"default:0" json:"views"`
Status string `gorm:"index;size:20;default:'draft'" json:"status"` // 增加索引
IsTop bool `gorm:"default:false" json:"is_top"`