- Service 层:energy_service → energize/operations/admin/query 四文件 - Service 层:post_service → helpers/audit + 核心 CRUD 保留 - Service 层:favorite_service → items + 核心文件夹操作保留 - Service 层:auth_service → password + 核心注册/登录保留 - Service 层:notification_service → notify + 核心列表/已读保留 - Service 层:audit_service → review + 核心列表/详情保留 - Controller 层:studio_controller → page/write/api/post_api/action 五文件 - Controller 层:post_controller → page/api/upload 三文件 - Controller 层:comment_controller → list/write/action/upload 四文件 - 清理未使用导入(notification_service.go 移除 fmt)
35 lines
915 B
Go
35 lines
915 B
Go
package controller
|
||
|
||
import (
|
||
"metazone.cc/metalab/internal/service"
|
||
)
|
||
|
||
// trendsUseCase StudioController 对趋势服务的最小依赖(ISP)
|
||
type trendsUseCase interface {
|
||
GetTrends(userID uint, since string) (*service.TrendResult, error)
|
||
}
|
||
|
||
// StudioController 创作中心控制器(SSR 页面 + API)
|
||
type StudioController struct {
|
||
postService studioUseCase
|
||
energySvc energyDeducter
|
||
trendsSvc trendsUseCase
|
||
}
|
||
|
||
// 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
|
||
}
|