57 lines
1.0 KiB
Go
Executable File
57 lines
1.0 KiB
Go
Executable File
package medias
|
|
|
|
import (
|
|
"backend/providers/http"
|
|
"backend/providers/storage"
|
|
"database/sql"
|
|
|
|
"git.ipao.vip/rogeecn/atom"
|
|
"git.ipao.vip/rogeecn/atom/container"
|
|
"git.ipao.vip/rogeecn/atom/contracts"
|
|
"git.ipao.vip/rogeecn/atom/utils/opt"
|
|
)
|
|
|
|
func Provide(opts ...opt.Option) error {
|
|
if err := container.Container.Provide(func(
|
|
svc *Service,
|
|
) (*Controller, error) {
|
|
obj := &Controller{
|
|
svc: svc,
|
|
}
|
|
return obj, nil
|
|
}); err != nil {
|
|
return err
|
|
}
|
|
|
|
if err := container.Container.Provide(func(
|
|
controller *Controller,
|
|
http *http.Service,
|
|
) (contracts.HttpRoute, error) {
|
|
obj := &Router{
|
|
controller: controller,
|
|
http: http,
|
|
}
|
|
return obj, nil
|
|
}, atom.GroupRoutes); err != nil {
|
|
return err
|
|
}
|
|
|
|
if err := container.Container.Provide(func(
|
|
db *sql.DB,
|
|
storageConfig *storage.Config,
|
|
) (*Service, error) {
|
|
obj := &Service{
|
|
db: db,
|
|
storageConfig: storageConfig,
|
|
}
|
|
if err := obj.Prepare(); err != nil {
|
|
return nil, err
|
|
}
|
|
return obj, nil
|
|
}); err != nil {
|
|
return err
|
|
}
|
|
|
|
return nil
|
|
}
|