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:
@ -1,12 +1,14 @@
|
||||
package service
|
||||
|
||||
import (
|
||||
"strconv"
|
||||
|
||||
"metazone.cc/mce/internal/common"
|
||||
"metazone.cc/mce/internal/model"
|
||||
)
|
||||
|
||||
// Update 编辑帖子(权限在 controller 层检查)
|
||||
func (s *PostService) Update(postID uint, title, body string, visibility, postType, reprintSource, declaration string, reprintProhibited bool) error {
|
||||
func (s *PostService) Update(postID uint, title, body string, visibility, postType, reprintSource, declaration string, reprintProhibited bool, categoryID string) error {
|
||||
post, err := s.findPost(postID)
|
||||
if err != nil {
|
||||
return err
|
||||
@ -22,6 +24,13 @@ func (s *PostService) Update(postID uint, title, body string, visibility, postTy
|
||||
post.ReprintSource = reprintSource
|
||||
post.Declaration = declaration
|
||||
post.ReprintProhibited = reprintProhibited
|
||||
// 分类
|
||||
if cid, err := strconv.ParseUint(categoryID, 10, 64); err == nil && cid > 0 {
|
||||
id := uint(cid)
|
||||
post.CategoryID = &id
|
||||
} else {
|
||||
post.CategoryID = nil
|
||||
}
|
||||
|
||||
// 已通过帖子:编辑内容保存为待审修订,不影响当前展示
|
||||
if post.Status == model.PostStatusApproved {
|
||||
|
||||
Reference in New Issue
Block a user