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,16 @@
|
||||
package model
|
||||
|
||||
import "time"
|
||||
// time imported by common.go
|
||||
|
||||
// Folder 收藏夹
|
||||
type Folder struct {
|
||||
ID uint `gorm:"primarykey" json:"id"`
|
||||
UserID uint `gorm:"index;not null" json:"user_id"`
|
||||
Name string `gorm:"type:varchar(50);not null" json:"name"`
|
||||
Description string `gorm:"type:varchar(200);default:''" json:"description"`
|
||||
IsPublic bool `gorm:"default:false" json:"is_public"`
|
||||
IsDefault bool `gorm:"default:false" json:"is_default"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
UpdatedAt time.Time `json:"updated_at"`
|
||||
BaseModel
|
||||
|
||||
UserID uint `gorm:"index;not null" json:"user_id"`
|
||||
Name string `gorm:"type:varchar(50);not null" json:"name"`
|
||||
Description string `gorm:"type:varchar(200);default:''" json:"description"`
|
||||
IsPublic bool `gorm:"default:false" json:"is_public"`
|
||||
IsDefault bool `gorm:"default:false" json:"is_default"`
|
||||
|
||||
// 联表查询填充(非数据库字段)
|
||||
ItemCount int64 `gorm:"-:migration;<-:false;column:item_count" json:"item_count,omitempty"`
|
||||
@ -19,11 +18,11 @@ type Folder struct {
|
||||
|
||||
// FolderItem 收藏记录
|
||||
type FolderItem struct {
|
||||
ID uint `gorm:"primarykey" json:"id"`
|
||||
FolderID uint `gorm:"index;not null" json:"folder_id"`
|
||||
PostID uint `gorm:"index;not null" json:"post_id"`
|
||||
UserID uint `gorm:"index;not null" json:"user_id"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
BaseModel
|
||||
|
||||
FolderID uint `gorm:"index;not null" json:"folder_id"`
|
||||
PostID uint `gorm:"index;not null" json:"post_id"`
|
||||
UserID uint `gorm:"index;not null" json:"user_id"`
|
||||
|
||||
// 联表查询填充
|
||||
PostTitle string `gorm:"-:migration;<-:false;column:post_title" json:"post_title,omitempty"`
|
||||
|
||||
Reference in New Issue
Block a user