Add CollectionResource model and update collection handling methods

This commit is contained in:
2025-08-03 13:06:43 +08:00
parent 0c841f2723
commit 0e69d787e3
4 changed files with 33 additions and 26 deletions

View File

@@ -4,14 +4,13 @@ import "gorm.io/gorm"
type Collection struct {
gorm.Model
Title string `gorm:"not null"`
Article string `gorm:"not null"`
UserID uint `gorm:"not null"`
User User `gorm:"foreignKey:UserID;references:ID"`
ResourcesCount int `gorm:"default:0"`
Images []Image `gorm:"many2many:collection_images;"`
Resources []Resource `gorm:"many2many:collection_resources;"`
Public bool `gorm:"default:false"` // 新增公开/私有字段
Title string `gorm:"not null"`
Article string `gorm:"not null"`
UserID uint `gorm:"not null"`
User User `gorm:"foreignKey:UserID;references:ID"`
ResourcesCount int `gorm:"default:0"`
Images []Image `gorm:"many2many:collection_images;"`
Public bool `gorm:"default:false"` // 新增公开/私有字段
}
type CollectionView struct {

View File

@@ -0,0 +1,9 @@
package model
import "time"
type CollectionResource struct {
CollectionID uint `gorm:"primaryKey"`
ResourceID uint `gorm:"primaryKey"`
CreatedAt time.Time
}