BUG修复,返回结构统一
This commit is contained in:
13
server/models/category.go
Normal file
13
server/models/category.go
Normal file
@@ -0,0 +1,13 @@
|
||||
package models
|
||||
|
||||
// Category 分类模型
|
||||
type Category struct {
|
||||
ID uint `json:"id"`
|
||||
Name string `json:"name"`
|
||||
Slug string `json:"slug"`
|
||||
Description string `json:"description"`
|
||||
SortOrder uint `json:"sortOrder"`
|
||||
CreatedAt int64 `json:"createdAt"`
|
||||
UpdatedAt int64 `json:"updatedAt"`
|
||||
DeletedAt int64 `json:"deletedAt"`
|
||||
}
|
||||
22
server/models/column.go
Normal file
22
server/models/column.go
Normal file
@@ -0,0 +1,22 @@
|
||||
package models
|
||||
|
||||
// Column 专栏模型
|
||||
type Column struct {
|
||||
ID uint `json:"id"`
|
||||
Name string `json:"name"`
|
||||
Description string `json:"description"`
|
||||
Cover string `json:"cover"`
|
||||
IsActive int `json:"isActive"`
|
||||
SortOrder uint `json:"sortOrder"`
|
||||
CreatedAt int64 `json:"createdAt"`
|
||||
UpdatedAt int64 `json:"updatedAt"`
|
||||
DeletedAt int64 `json:"deletedAt"`
|
||||
}
|
||||
|
||||
// ColumnPost 专栏文章关联模型
|
||||
type ColumnPost struct {
|
||||
ColumnID uint `json:"columnId"`
|
||||
PostID uint `json:"postId"`
|
||||
SortOrder uint `json:"sortOrder"`
|
||||
CreatedAt int64 `json:"createdAt"`
|
||||
}
|
||||
@@ -2,56 +2,41 @@ package models
|
||||
|
||||
// Post 博客文章模型
|
||||
type Post struct {
|
||||
ID uint `json:"id"`
|
||||
OriginalID string `json:"originalId,omitempty"` // For backward compatibility
|
||||
Title string `json:"title"`
|
||||
Category string `json:"category"`
|
||||
// Date Removed from DB
|
||||
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"`
|
||||
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"`
|
||||
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 int64 `json:"createdAt"`
|
||||
UpdatedAt int64 `json:"updatedAt"`
|
||||
DeletedAt int64 `json:"deletedAt"`
|
||||
}
|
||||
|
||||
// PostTag 文章标签关联模型
|
||||
type PostTag struct {
|
||||
PostID string `json:"postId"`
|
||||
TagID uint `json:"tagId"`
|
||||
CreatedAt int64 `json:"createdAt"`
|
||||
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"`
|
||||
Category string `json:"category"`
|
||||
// Date Removed
|
||||
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"`
|
||||
@@ -62,14 +47,15 @@ type PostHistory struct {
|
||||
|
||||
// PostHistoryResponse 文章历史记录响应模型
|
||||
type PostHistoryResponse struct {
|
||||
ID uint `json:"id"`
|
||||
PostID uint `json:"postId"`
|
||||
Version int `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"`
|
||||
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"`
|
||||
}
|
||||
|
||||
18
server/models/tag.go
Normal file
18
server/models/tag.go
Normal file
@@ -0,0 +1,18 @@
|
||||
package models
|
||||
|
||||
// Tag 标签模型
|
||||
type Tag struct {
|
||||
ID uint `json:"id"`
|
||||
Name string `json:"name"`
|
||||
Slug string `json:"slug"`
|
||||
CreatedAt int64 `json:"createdAt"`
|
||||
UpdatedAt int64 `json:"updatedAt"`
|
||||
DeletedAt int64 `json:"deletedAt"`
|
||||
}
|
||||
|
||||
// PostTag 文章标签关联模型
|
||||
type PostTag struct {
|
||||
PostID string `json:"postId"`
|
||||
TagID uint `json:"tagId"`
|
||||
CreatedAt int64 `json:"createdAt"`
|
||||
}
|
||||
@@ -5,6 +5,7 @@ type User struct {
|
||||
ID uint `json:"id"`
|
||||
Username string `json:"username"`
|
||||
Email string `json:"email"`
|
||||
Password string `json:"password,omitempty" gorm:"-"` // Virtual field for input
|
||||
PasswordHash string `json:"-"`
|
||||
RoleID uint `json:"roleId"`
|
||||
Role string `json:"role"` // 保持兼容,或者作为Role Name
|
||||
|
||||
Reference in New Issue
Block a user