- Model/Repo/Service/Controller 全栈实现 - CRUD + ListActive(生效时间范围过滤) - 管理后台独立页面 /admin/announcements(列表+弹窗CRUD) - 前台首页 Hero 下方公告栏(info/success/warning/error 四色) - Moderator+ 权限可管理公告
18 lines
675 B
Go
18 lines
675 B
Go
package model
|
|
|
|
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"`
|
|
}
|