feat: 文章属性 — Post Model 扩展 + 置顶系统

- Post 新增 7 字段:Visibility/PostType/ReprintSource/Declaration/ReprintProhibited/PinType/PinnedAt
- 公开列表过滤 private 文章(管理员可见全部)
- 列表排序:全局置顶 > 按时间
- declarationLabel 模板函数(7 种创作声明)
- Pin/Unpin API(admin+,category/global 两种置顶类型)
This commit is contained in:
2026-06-22 00:04:55 +08:00
parent fc57ed17d4
commit 9c452afb40
8 changed files with 127 additions and 8 deletions

View File

@ -19,6 +19,16 @@ type Post struct {
PendingTitle string `gorm:"type:varchar(200);default:''" json:"pending_title,omitempty"`
PendingBody string `gorm:"type:text" json:"pending_body,omitempty"`
RejectReason string `gorm:"type:varchar(500);default:''" json:"reject_reason,omitempty"`
// 文章属性
Visibility string `gorm:"type:varchar(10);default:public" json:"visibility"` // public / private
PostType string `gorm:"type:varchar(10);default:original" json:"post_type"` // original / reprint
ReprintSource string `gorm:"type:varchar(500);default:''" json:"reprint_source,omitempty"` // 转载来源
Declaration string `gorm:"type:varchar(30);default:''" json:"declaration,omitempty"` // 创作声明
ReprintProhibited bool `gorm:"default:false" json:"reprint_prohibited"` // 禁止转载
PinType string `gorm:"type:varchar(10);default:''" json:"pin_type,omitempty"` // category / global
PinnedAt *time.Time `json:"pinned_at,omitempty"` // 置顶时间
AllowComment bool `gorm:"default:true" json:"allow_comment"`
CommentsCount int `gorm:"default:0" json:"comments_count"` // 评论数(冗余计数器)
TotalEnergyReceived int `gorm:"default:0" json:"total_energy_received"` // 文章累计被赋能域能乘10冗余计数
@ -44,3 +54,32 @@ const (
PostStatusRejected = "rejected"
PostStatusLocked = "locked"
)
// 可见性常量
const (
VisibilityPublic = "public"
VisibilityPrivate = "private"
)
// 文章类型常量
const (
PostTypeOriginal = "original"
PostTypeReprint = "reprint"
)
// 置顶类型常量
const (
PinTypeCategory = "category"
PinTypeGlobal = "global"
)
// DeclarationLabels 创作声明名称映射
var DeclarationLabels = map[string]string{
"ai_generated": "该内容使用AI辅助创作",
"fictional": "该内容包含虚构情节",
"speculative": "该内容包含猜测/推测性内容",
"disturbing": "该内容可能包含令人不适的内容",
"spoiler": "该内容包含剧透内容",
"controversial": "该内容可能涉及争议性话题",
"opinion": "本文仅代表作者个人观点",
}