refactor: 统一 BaseModel 嵌入,修复 primaryKey 大小写不一致
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:
2026-06-22 03:09:19 +08:00
parent 2449a27eb5
commit c3c7390498
6 changed files with 52 additions and 70 deletions

View File

@ -4,14 +4,13 @@ import "time"
// Announcement 公告
type Announcement struct {
ID uint `gorm:"primarykey" json:"id"`
Title string `gorm:"type:varchar(200);not null" json:"title"`
Content string `gorm:"type:text;not null" json:"content"`
Type string `gorm:"type:varchar(20);default:info" json:"type"` // info / warning / success / error
IsActive bool `gorm:"default:true" json:"is_active"`
StartAt *time.Time `json:"start_at,omitempty"`
EndAt *time.Time `json:"end_at,omitempty"`
Sort int `gorm:"default:0" json:"sort"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
BaseModel
Title string `gorm:"type:varchar(200);not null" json:"title"`
Content string `gorm:"type:text;not null" json:"content"`
Type string `gorm:"type:varchar(20);default:info" json:"type"` // info / warning / success / error
IsActive bool `gorm:"default:true" json:"is_active"`
StartAt *time.Time `json:"start_at,omitempty"`
EndAt *time.Time `json:"end_at,omitempty"`
Sort int `gorm:"default:0" json:"sort"`
}