feat: 分类系统 + 标签系统 — Phase 4 完成

分类:Model/Repo/Service/Controller + 管理后台树形页面 + 首页导航栏
标签:Model/Repo/Service/Controller + /tags/{slug} 落地页 + 写文章页输入
Post 加 CategoryID,Create/Update 支持分类和标签
SQL 迁移含 categories/tags/post_tags 表及预设未分类
This commit is contained in:
2026-06-22 00:30:29 +08:00
parent 977c52513a
commit 0b8f6f890d
30 changed files with 988 additions and 13 deletions

View File

@ -17,6 +17,16 @@ func (ctrl *StudioController) WritePage(c *gin.Context) {
return
}
// 加载分类列表(叶子节点)
var categories []interface{}
if ctrl.categorySvc != nil {
if leaves, err := ctrl.categorySvc.GetLeaves(); err == nil {
for _, cat := range leaves {
categories = append(categories, cat)
}
}
}
// 支持编辑模式:传入 post_id 参数
postIDStr := c.Query("id")
if postIDStr != "" {
@ -32,10 +42,11 @@ func (ctrl *StudioController) WritePage(c *gin.Context) {
return
}
c.HTML(http.StatusOK, "studio/write.html", common.BuildPageData(c, gin.H{
"Title": "编辑文章 - 创作中心",
"Post": post,
"ActiveTab": "write",
"ExtraCSS": "/static/css/studio.css",
"Title": "编辑文章 - 创作中心",
"Post": post,
"ActiveTab": "write",
"ExtraCSS": "/static/css/studio.css",
"Categories": categories,
}))
return
}
@ -43,9 +54,10 @@ func (ctrl *StudioController) WritePage(c *gin.Context) {
}
c.HTML(http.StatusOK, "studio/write.html", common.BuildPageData(c, gin.H{
"Title": "写文章 - 创作中心",
"ActiveTab": "write",
"ExtraCSS": "/static/css/studio.css",
"Title": "写文章 - 创作中心",
"ActiveTab": "write",
"ExtraCSS": "/static/css/studio.css",
"Categories": categories,
}))
}