package contracts import ( "git.fsdpf.net/go/req" "github.com/samber/do" ) type Controller interface { // 初始化 Init() error // 获取 Container Container() *do.Injector // 派遣一个任务 Dispatch(job string, payload any, u req.User) error } type BaseController struct { container *do.Injector } func (this BaseController) Container() *do.Injector { return this.container } func (BaseController) Init() error { return nil } func (this BaseController) Dispatch(job string, payload any, u req.User) error { return do.MustInvoke[JobService](this.Container()).Dispatch(job, payload, u) } func NewBaseController(container *do.Injector) Controller { return &BaseController{container} }