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,6 +1,7 @@
|
||||
package controller
|
||||
|
||||
import (
|
||||
"metazone.cc/mce/internal/model"
|
||||
"metazone.cc/mce/internal/service"
|
||||
)
|
||||
|
||||
@ -9,11 +10,24 @@ type trendsUseCase interface {
|
||||
GetTrends(userID uint, since string) (*service.TrendResult, error)
|
||||
}
|
||||
|
||||
// tagParser ISP:标签解析
|
||||
type tagParser interface {
|
||||
ParseAndSave(tagStr string) ([]uint, error)
|
||||
SetPostTags(postID uint, tagStr string) error
|
||||
}
|
||||
|
||||
// StudioController 创作中心控制器(SSR 页面 + API)
|
||||
type StudioController struct {
|
||||
postService studioUseCase
|
||||
energySvc energyDeducter
|
||||
trendsSvc trendsUseCase
|
||||
tagSvc tagParser
|
||||
categorySvc categoryLoader
|
||||
}
|
||||
|
||||
// categoryLoader ISP:分类叶子节点查询
|
||||
type categoryLoader interface {
|
||||
GetLeaves() ([]model.Category, error)
|
||||
}
|
||||
|
||||
// NewStudioController 构造函数
|
||||
@ -32,3 +46,15 @@ func (ctrl *StudioController) WithTrendsService(svc trendsUseCase) *StudioContro
|
||||
ctrl.trendsSvc = svc
|
||||
return ctrl
|
||||
}
|
||||
|
||||
// WithTagService 链式注入标签服务
|
||||
func (ctrl *StudioController) WithTagService(svc tagParser) *StudioController {
|
||||
ctrl.tagSvc = svc
|
||||
return ctrl
|
||||
}
|
||||
|
||||
// WithCategoryService 链式注入分类服务
|
||||
func (ctrl *StudioController) WithCategoryService(svc categoryLoader) *StudioController {
|
||||
ctrl.categorySvc = svc
|
||||
return ctrl
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user