2024-12-01 16:05:07 +08:00
|
|
|
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"`
|
|
|
|
// 分类
|
2024-12-01 17:17:51 +08:00
|
|
|
Category string `json:"category" gorm:"column:category;type:varchar(200);index"`
|
2024-12-01 16:05:07 +08:00
|
|
|
// 标签
|
|
|
|
Tags map[string]string `json:"tags" gorm:"column:tags;serializer:json"`
|
|
|
|
}
|
|
|
|
|
|
|
|
type Status struct {
|
2024-12-01 17:17:51 +08:00
|
|
|
StatusSpec
|
2024-12-01 16:05:07 +08:00
|
|
|
// 状态变化的时间, 拿发布时间
|
|
|
|
ChangeAt *time.Time `json:"change_at" gorm:"column:change_at"`
|
|
|
|
}
|
2024-12-01 17:17:51 +08:00
|
|
|
|
|
|
|
type StatusSpec struct {
|
|
|
|
// 0: 草稿, 1: 已发布, 2: 审核 ...
|
|
|
|
Stage STAGE `json:"stage" gorm:"column:stage;type:tinyint(1);index"`
|
|
|
|
}
|