refactor: 统一 BaseModel 嵌入,修复 primaryKey 大小写不一致
Some checks failed
CI / Lint + Build (push) Has been cancelled
Some checks failed
CI / Lint + Build (push) Has been cancelled
变更模型: - Post: 嵌入 BaseModel,移除手动 ID/CreatedAt/UpdatedAt/DeletedAt - Comment: 嵌入 BaseModel,保留 is_deleted 自定义软删除 - Announcement: 嵌入 BaseModel - Category: 嵌入 BaseModel - Folder + FolderItem: 嵌入 BaseModel - CommunityFund: primaryKey → primarykey (统一小写)
This commit is contained in:
@ -1,17 +1,14 @@
|
||||
package model
|
||||
|
||||
import "time"
|
||||
|
||||
// Category 文章分类(两级树形结构)
|
||||
type Category struct {
|
||||
ID uint `gorm:"primarykey" json:"id"`
|
||||
Name string `gorm:"type:varchar(50);not null" json:"name"`
|
||||
Slug string `gorm:"type:varchar(50);not null;uniqueIndex" json:"slug"`
|
||||
Description string `gorm:"type:varchar(200);default:''" json:"description,omitempty"`
|
||||
ParentID *uint `gorm:"index" json:"parent_id,omitempty"`
|
||||
Sort int `gorm:"default:0" json:"sort"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
UpdatedAt time.Time `json:"updated_at"`
|
||||
BaseModel
|
||||
|
||||
Name string `gorm:"type:varchar(50);not null" json:"name"`
|
||||
Slug string `gorm:"type:varchar(50);not null;uniqueIndex" json:"slug"`
|
||||
Description string `gorm:"type:varchar(200);default:''" json:"description,omitempty"`
|
||||
ParentID *uint `gorm:"index" json:"parent_id,omitempty"`
|
||||
Sort int `gorm:"default:0" json:"sort"`
|
||||
|
||||
// 非 DB 字段(树形填充)
|
||||
Children []Category `gorm:"-" json:"children,omitempty"`
|
||||
|
||||
Reference in New Issue
Block a user