Files
nl-blogs/server/models/post.go
2026-01-15 13:51:44 +08:00

76 lines
2.1 KiB
Go

package models
import (
"time"
)
// Post 博客文章模型
type Post struct {
ID string `json:"id"`
Title string `json:"title"`
Category string `json:"category"`
Date time.Time `json:"date"`
Excerpt string `json:"excerpt"`
Content string `json:"content"`
ReadCount uint `json:"readCount"`
IsPublished int `json:"isPublished"`
CreatedAt time.Time `json:"createdAt"`
UpdatedAt time.Time `json:"updatedAt"`
}
// PostResponse 博客文章响应模型
type PostResponse struct {
ID string `json:"id"`
Title string `json:"title"`
Category string `json:"category"`
Date string `json:"date"`
Excerpt string `json:"excerpt,omitempty"`
Content string `json:"content,omitempty"`
}
// Tag 标签模型
type Tag struct {
ID uint `json:"id"`
Name string `json:"name"`
Slug string `json:"slug"`
CreatedAt time.Time `json:"createdAt"`
UpdatedAt time.Time `json:"updatedAt"`
}
// PostTag 文章标签关联模型
type PostTag struct {
PostID string `json:"postId"`
TagID uint `json:"tagId"`
CreatedAt time.Time `json:"createdAt"`
}
// PostHistory 文章历史记录模型
type PostHistory struct {
ID uint `json:"id"`
PostID string `json:"postId"`
Version uint `json:"version"`
Title string `json:"title"`
Category string `json:"category"`
Date time.Time `json:"date"`
Excerpt string `json:"excerpt"`
Content string `json:"content"`
IsPublished int `json:"isPublished"`
ModifiedBy uint `json:"modifiedBy"`
ModifiedAt time.Time `json:"modifiedAt"`
CreatedAt time.Time `json:"createdAt"`
}
// PostHistoryResponse 文章历史记录响应模型
type PostHistoryResponse struct {
ID uint `json:"id"`
PostID string `json:"postId"`
Version uint `json:"version"`
Title string `json:"title"`
Category string `json:"category"`
Date string `json:"date"`
IsPublished int `json:"isPublished"`
ModifiedBy uint `json:"modifiedBy"`
ModifiedAt string `json:"modifiedAt"`
CreatedAt string `json:"createdAt"`
}