Files
nl-blogs/server/models/post.go
2026-01-16 17:03:34 +08:00

62 lines
2.1 KiB
Go

package models
// Post 博客文章模型
type Post struct {
ID uint `json:"id"`
OriginalID string `json:"originalId,omitempty"` // For backward compatibility
Title string `json:"title"`
CategoryID uint `json:"categoryId"`
Category *Category `json:"category,omitempty"` // For join query result
Excerpt string `json:"excerpt"`
Content string `json:"content"`
ReadCount uint `json:"readCount"`
IsPublished int `json:"isPublished"` // 0: draft, 1: published
Tags []Tag `json:"tags"`
CreatedAt int64 `json:"createdAt"`
UpdatedAt int64 `json:"updatedAt"`
DeletedAt int64 `json:"deletedAt"`
}
// PostResponse 博客文章响应模型
type PostResponse struct {
ID uint `json:"id"`
Title string `json:"title"`
CategoryID uint `json:"categoryId"`
CategoryName string `json:"categoryName"`
CategorySlug string `json:"categorySlug"`
Date string `json:"date"`
Excerpt string `json:"excerpt,omitempty"`
Content string `json:"content,omitempty"`
Tags []Tag `json:"tags,omitempty"`
}
// PostHistory 文章历史记录模型
type PostHistory struct {
ID uint `json:"id"`
PostID uint `json:"postId"`
Version int `json:"version"`
Title string `json:"title"`
CategoryID uint `json:"categoryId"`
Excerpt string `json:"excerpt"`
Content string `json:"content"`
IsPublished int `json:"isPublished"`
ModifiedBy uint `json:"modifiedBy"`
ModifiedAt int64 `json:"modifiedAt"`
CreatedAt int64 `json:"createdAt"`
}
// PostHistoryResponse 文章历史记录响应模型
type PostHistoryResponse struct {
ID uint `json:"id"`
PostID uint `json:"postId"`
Version int `json:"version"`
Title string `json:"title"`
CategoryID uint `json:"categoryId"`
CategoryName string `json:"categoryName"`
Date string `json:"date"`
IsPublished int `json:"isPublished"`
ModifiedBy uint `json:"modifiedBy"`
ModifiedAt string `json:"modifiedAt"`
CreatedAt string `json:"createdAt"`
}