47 lines
1.8 KiB
Go
47 lines
1.8 KiB
Go
package model
|
|
|
|
import (
|
|
"admin/internal/db"
|
|
"admin/internal/model/dto"
|
|
"time"
|
|
)
|
|
|
|
func init() {
|
|
db.RegisterTableModels(Notice{})
|
|
}
|
|
|
|
type Notice struct {
|
|
ID int `gorm:"primarykey" readonly:"true"`
|
|
ProjectId int `gorm:"index:idx_project_id"`
|
|
//ServerIDs []string `gorm:"type:json;serializer:json" name:"公告生效服务器" desc:"为空表示所有服" choices:"GetChoiceServers"`
|
|
Mod string `name:"公告分栏标题" desc:"显示到公告弹窗左边的分栏标题" required:"true"` // 左边分栏标题
|
|
Title string `name:"公告标题" desc:"显示到公告内容区里的标题" required:"true" big_column:"true"` // 公告内容上面的标题
|
|
Content string `name:"公告内容" desc:"仅支持<color=#xxx></color>颜色标签和\\n换行标签" type:"text" required:"true" big_column:"true"` // 公告内容
|
|
//StartAt time.Time `name:"开始时间" required:"true"`
|
|
//EndAt time.Time `name:"结束时间" required:"true"`
|
|
Status bool `name:"是否启用" desc:"启用的公告才会导出到cdn被客户端显示" type:"tagStatus" choices:"GetStatusChoices" required:"true"`
|
|
SortWeight int `name:"排序" desc:"越大越靠前"`
|
|
|
|
CreatedAt time.Time `readonly:"true"`
|
|
UpdatedAt time.Time `readonly:"true"`
|
|
}
|
|
|
|
func (lm *Notice) TableName() string {
|
|
return "notice"
|
|
}
|
|
|
|
func (m *Notice) GetId() int {
|
|
return m.ID
|
|
}
|
|
|
|
func (m *Notice) GetChoiceServers(project *Project) []*dto.CommonDtoFieldChoice {
|
|
return getChoiceServers(project)
|
|
}
|
|
|
|
func (m *Notice) GetStatusChoices(project *Project) []*dto.CommonDtoFieldChoice {
|
|
return []*dto.CommonDtoFieldChoice{
|
|
{Desc: "禁用", Value: false, Type: 3}, // type: 0:plain 1:primary 2:success 3:info 4:warning 5:danger
|
|
{Desc: "启用", Value: true, Type: 2},
|
|
}
|
|
}
|