feat(评论): 添加评论置顶功能

- 在评论表中添加 priority 字段用于控制置顶权重
- 修改所有评论查询接口按 priority 和 created 排序
- 在管理后台添加置顶权重编辑功能
- 在评论列表显示置顶标识
This commit is contained in:
anghunk
2026-01-21 21:25:08 +08:00
parent 47c2eed6b5
commit 3871620fed
7 changed files with 51 additions and 16 deletions

View File

@@ -14,6 +14,7 @@ CREATE TABLE IF NOT EXISTS Comment (
content_text TEXT NOT NULL,
content_html TEXT NOT NULL,
parent_id INTEGER,
priority INTEGER NOT NULL DEFAULT 1,
status TEXT DEFAULT 'approved',
-- 建立自引用外键约束(父子评论关系)
FOREIGN KEY (parent_id) REFERENCES Comment (id) ON DELETE SET NULL
@@ -21,4 +22,4 @@ CREATE TABLE IF NOT EXISTS Comment (
-- 可选:为常用查询字段创建索引以提高性能
CREATE INDEX IF NOT EXISTS idx_post_slug ON Comment(post_slug);
CREATE INDEX IF NOT EXISTS idx_status ON Comment(status);
CREATE INDEX IF NOT EXISTS idx_status ON Comment(status);