46 lines
1.0 KiB
Go
46 lines
1.0 KiB
Go
|
package blog
|
||
|
|
||
|
import (
|
||
|
"time"
|
||
|
|
||
|
"gitlab.com/go-course-project/go17/vblog/utils"
|
||
|
)
|
||
|
|
||
|
type BlogSet struct {
|
||
|
Total int32 `json:"total"`
|
||
|
Items []*Blog `json:"items"`
|
||
|
}
|
||
|
|
||
|
type Blog struct {
|
||
|
// 存放到数据里的对象的远数据信息
|
||
|
utils.ResourceMeta
|
||
|
// 创建是的具体信息
|
||
|
CreateBlogRequest
|
||
|
// 文章状态
|
||
|
Status
|
||
|
}
|
||
|
|
||
|
func (t *Blog) TableName() string {
|
||
|
return "blogs"
|
||
|
}
|
||
|
|
||
|
type CreateBlogRequest struct {
|
||
|
// 标题
|
||
|
Title string `json:"title" gorm:"column:title;type:varchar(200)"`
|
||
|
// 摘要
|
||
|
Summary string `json:"summary" gorm:"column:summary;type:text"`
|
||
|
// 内容
|
||
|
Content string `json:"content" gorm:"column:content;type:text"`
|
||
|
// 分类
|
||
|
Category string `json:"category" gorm:"column:category;type:text"`
|
||
|
// 标签
|
||
|
Tags map[string]string `json:"tags" gorm:"column:tags;serializer:json"`
|
||
|
}
|
||
|
|
||
|
type Status struct {
|
||
|
// 0: 草稿, 1: 已发布, 2: 审核 ...
|
||
|
Stage STAGE `json:"stage" gorm:"column:stage;type:tinyint(1)"`
|
||
|
// 状态变化的时间, 拿发布时间
|
||
|
ChangeAt *time.Time `json:"change_at" gorm:"column:change_at"`
|
||
|
}
|