35 lines
911 B
Go
35 lines
911 B
Go
package controller
|
||
|
||
import (
|
||
"metazone.cc/mce/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
|
||
}
|