67 lines
3.8 KiB
Go
67 lines
3.8 KiB
Go
|
|
package model
|
|||
|
|
|
|||
|
|
import (
|
|||
|
|
"github.com/gogf/gf/v2/os/gtime"
|
|||
|
|
)
|
|||
|
|
|
|||
|
|
// Article 文章模型
|
|||
|
|
type Article struct {
|
|||
|
|
Id int `json:"id" dc:"主键"`
|
|||
|
|
Title string `json:"title" dc:"标题"`
|
|||
|
|
Slug string `json:"slug" dc:"URL别名"`
|
|||
|
|
Summary string `json:"summary" dc:"摘要"`
|
|||
|
|
Content string `json:"content" dc:"内容(Markdown)"`
|
|||
|
|
HtmlContent string `json:"html_content" dc:"HTML内容"`
|
|||
|
|
CoverImage string `json:"cover_image" dc:"封面图片"`
|
|||
|
|
CategoryId int `json:"category_id" dc:"分类ID"`
|
|||
|
|
Tags interface{} `json:"tags" dc:"标签"`
|
|||
|
|
AuthorId int `json:"author_id" dc:"作者ID"`
|
|||
|
|
ViewCount int `json:"view_count" dc:"浏览次数"`
|
|||
|
|
LikeCount int `json:"like_count" dc:"点赞次数"`
|
|||
|
|
CommentCount int `json:"comment_count" dc:"评论次数"`
|
|||
|
|
IsPublished int `json:"is_published" dc:"是否发布 0:草稿 1:已发布"`
|
|||
|
|
IsFeatured int `json:"is_featured" dc:"是否推荐 0:否 1:是"`
|
|||
|
|
IsTop int `json:"is_top" dc:"是否置顶 0:否 1:是"`
|
|||
|
|
SeoTitle string `json:"seo_title" dc:"SEO标题"`
|
|||
|
|
SeoDescription string `json:"seo_description" dc:"SEO描述"`
|
|||
|
|
SeoKeywords string `json:"seo_keywords" dc:"SEO关键词"`
|
|||
|
|
PublishedAt *gtime.Time `json:"published_at" dc:"发布时间"`
|
|||
|
|
CreatedAt *gtime.Time `json:"created_at" dc:"创建时间"`
|
|||
|
|
UpdatedAt *gtime.Time `json:"updated_at" dc:"更新时间"`
|
|||
|
|
DeletedAt int `json:"deleted_at" dc:"删除时间"`
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// CreateArticleRequest 创建文章请求
|
|||
|
|
type CreateArticleRequest struct {
|
|||
|
|
Title string `json:"title" v:"required|length:1,255#标题不能为空|标题长度不能超过255字符" dc:"标题"`
|
|||
|
|
Slug string `json:"slug" v:"length:0,255#URL别名长度不能超过255字符" dc:"URL别名"`
|
|||
|
|
Summary string `json:"summary" dc:"摘要"`
|
|||
|
|
Content string `json:"content" v:"required#内容不能为空" dc:"内容(Markdown)"`
|
|||
|
|
CoverImage string `json:"cover_image" dc:"封面图片"`
|
|||
|
|
CategoryId int `json:"category_id" dc:"分类ID"`
|
|||
|
|
Tags []string `json:"tags" dc:"标签"`
|
|||
|
|
AuthorId int `json:"author_id" dc:"作者ID"`
|
|||
|
|
IsPublished int `json:"is_published" dc:"是否发布"`
|
|||
|
|
IsFeatured int `json:"is_featured" dc:"是否推荐"`
|
|||
|
|
IsTop int `json:"is_top" dc:"是否置顶"`
|
|||
|
|
SeoTitle string `json:"seo_title" dc:"SEO标题"`
|
|||
|
|
SeoDescription string `json:"seo_description" dc:"SEO描述"`
|
|||
|
|
SeoKeywords string `json:"seo_keywords" dc:"SEO关键词"`
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// UpdateArticleRequest 更新文章请求
|
|||
|
|
type UpdateArticleRequest struct {
|
|||
|
|
Title string `json:"title" v:"required|length:1,255#标题不能为空|标题长度不能超过255字符" dc:"标题"`
|
|||
|
|
Slug string `json:"slug" v:"required|length:1,255#URL别名不能为空|URL别名长度不能超过255字符" dc:"URL别名"`
|
|||
|
|
Summary string `json:"summary" v:"required#摘要不能为空" dc:"摘要"`
|
|||
|
|
Content string `json:"content" v:"required#内容不能为空" dc:"内容"`
|
|||
|
|
CoverImage string `json:"cover_image" dc:"封面图片"`
|
|||
|
|
CategoryId int `json:"category_id" dc:"分类ID"`
|
|||
|
|
Tags []string `json:"tags" dc:"标签"`
|
|||
|
|
IsPublished int `json:"is_published" v:"in:0,1#发布状态只能为0或1" dc:"是否发布"`
|
|||
|
|
IsFeatured int `json:"is_featured" v:"in:0,1#推荐状态只能为0或1" dc:"是否推荐"`
|
|||
|
|
IsTop int `json:"is_top" v:"in:0,1#置顶状态只能为0或1" dc:"是否置顶"`
|
|||
|
|
SeoTitle string `json:"seo_title" dc:"SEO标题"`
|
|||
|
|
SeoDescription string `json:"seo_description" dc:"SEO描述"`
|
|||
|
|
SeoKeywords string `json:"seo_keywords" dc:"SEO关键词"`
|
|||
|
|
}
|