Files
mce/internal/controller/studio_controller.go
Victor_Jay 0b8f6f890d feat: 分类系统 + 标签系统 — Phase 4 完成
分类:Model/Repo/Service/Controller + 管理后台树形页面 + 首页导航栏
标签:Model/Repo/Service/Controller + /tags/{slug} 落地页 + 写文章页输入
Post 加 CategoryID,Create/Update 支持分类和标签
SQL 迁移含 categories/tags/post_tags 表及预设未分类
2026-06-22 00:30:29 +08:00

61 lines
1.6 KiB
Go
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package controller
import (
"metazone.cc/mce/internal/model"
"metazone.cc/mce/internal/service"
)
// trendsUseCase StudioController 对趋势服务的最小依赖ISP
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 构造函数
func NewStudioController(ps studioUseCase) *StudioController {
return &StudioController{postService: ps}
}
// WithEnergyService 链式注入域能服务
func (ctrl *StudioController) WithEnergyService(svc energyDeducter) *StudioController {
ctrl.energySvc = svc
return ctrl
}
// WithTrendsService 链式注入趋势服务
func (ctrl *StudioController) WithTrendsService(svc trendsUseCase) *StudioController {
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
}