优化页面、修复BUG
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package models
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"time"
|
||||
|
||||
"gorm.io/gorm"
|
||||
@@ -76,6 +77,8 @@ type PostHistory struct {
|
||||
Version int `json:"version" gorm:"column:version"`
|
||||
Title string `json:"title" gorm:"column:title"`
|
||||
CategoryID uint `json:"categoryId" gorm:"column:category_id"`
|
||||
ColumnID *uint `json:"columnId,omitempty" gorm:"column:column_id"`
|
||||
TagIDs string `json:"tagIds,omitempty" gorm:"column:tag_ids;type:json"`
|
||||
Excerpt string `json:"excerpt" gorm:"column:excerpt"`
|
||||
Content string `json:"content" gorm:"column:content;type:text"`
|
||||
IsPublished int `json:"isPublished" gorm:"column:is_published"`
|
||||
@@ -84,6 +87,18 @@ type PostHistory struct {
|
||||
CreatedAt int64 `json:"createdAt" gorm:"column:created_at"`
|
||||
}
|
||||
|
||||
// GetTagIDList parses stored tag_ids JSON into a slice of uint IDs.
|
||||
func (ph *PostHistory) GetTagIDList() []uint {
|
||||
if ph.TagIDs == "" {
|
||||
return nil
|
||||
}
|
||||
var ids []uint
|
||||
if err := json.Unmarshal([]byte(ph.TagIDs), &ids); err != nil {
|
||||
return nil
|
||||
}
|
||||
return ids
|
||||
}
|
||||
|
||||
// TableName 指定表名
|
||||
func (PostHistory) TableName() string {
|
||||
return "post_history"
|
||||
@@ -108,10 +123,29 @@ type PostHistoryResponse struct {
|
||||
Version int `json:"version"`
|
||||
Title string `json:"title"`
|
||||
CategoryID uint `json:"categoryId"`
|
||||
CategoryName string `json:"categoryName"`
|
||||
CategoryName string `json:"categoryName,omitempty"`
|
||||
ColumnID *uint `json:"columnId,omitempty"`
|
||||
TagIDs []uint `json:"tagIds,omitempty"`
|
||||
Excerpt string `json:"excerpt,omitempty"`
|
||||
Content string `json:"content,omitempty"`
|
||||
Date string `json:"date"`
|
||||
IsPublished int `json:"isPublished"`
|
||||
ModifiedBy uint `json:"modifiedBy"`
|
||||
ModifiedAt string `json:"modifiedAt"`
|
||||
CreatedAt string `json:"createdAt"`
|
||||
}
|
||||
|
||||
// PostHistoryFieldDiff 字段对比结果
|
||||
type PostHistoryFieldDiff struct {
|
||||
From string `json:"from"`
|
||||
To string `json:"to"`
|
||||
Changed bool `json:"changed"`
|
||||
Diff string `json:"diff,omitempty"`
|
||||
}
|
||||
|
||||
// PostHistoryDiffResponse 版本对比响应
|
||||
type PostHistoryDiffResponse struct {
|
||||
FromVersion int `json:"fromVersion"`
|
||||
ToVersion int `json:"toVersion"`
|
||||
Fields map[string]PostHistoryFieldDiff `json:"fields"`
|
||||
}
|
||||
|
||||
@@ -9,11 +9,12 @@ import (
|
||||
// UserAccessLog 用户访问日志模型
|
||||
type UserAccessLog struct {
|
||||
ID uint `json:"id" gorm:"primaryKey;column:id"`
|
||||
UserID uint `json:"user_id" gorm:"column:user_id;index"` // 用户ID(未登录用户为0)
|
||||
UserIP string `json:"user_ip" gorm:"column:user_ip;index"` // 用户IP地址
|
||||
UserLocation string `json:"user_location" gorm:"column:user_location"` // 用户归属地
|
||||
ArticleID uint `json:"article_id" gorm:"column:article_id;index"` // 访问的文章ID
|
||||
AccessTime int64 `json:"access_time" gorm:"column:access_time"` // 访问时间
|
||||
UserID uint `json:"user_id" gorm:"column:user_id;index"` // 用户ID(未登录用户为0)
|
||||
UserIP string `json:"user_ip" gorm:"column:user_ip;index"` // 用户IP地址
|
||||
UserLocation string `json:"user_location" gorm:"column:user_location"` // 用户归属地
|
||||
ArticleID uint `json:"article_id" gorm:"column:article_id;index"` // 访问的文章ID
|
||||
VisitorKey string `json:"visitor_key" gorm:"column:visitor_key;size:64"` // 匿名访客标识
|
||||
AccessTime int64 `json:"access_time" gorm:"column:access_time"` // 访问时间
|
||||
DeletedAt int64 `json:"deleted_at" gorm:"column:deleted_at;default:0"`
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user