64 lines
1.1 KiB
Go
Executable File
64 lines
1.1 KiB
Go
Executable File
package services
|
|
|
|
import (
|
|
"go.ipao.vip/atom"
|
|
"go.ipao.vip/atom/container"
|
|
"go.ipao.vip/atom/contracts"
|
|
"go.ipao.vip/atom/opt"
|
|
"gorm.io/gorm"
|
|
)
|
|
|
|
func Provide(opts ...opt.Option) error {
|
|
if err := container.Container.Provide(func() (*media, error) {
|
|
obj := &media{}
|
|
|
|
return obj, nil
|
|
}); err != nil {
|
|
return err
|
|
}
|
|
if err := container.Container.Provide(func() (*orders, error) {
|
|
obj := &orders{}
|
|
|
|
return obj, nil
|
|
}); err != nil {
|
|
return err
|
|
}
|
|
if err := container.Container.Provide(func() (*posts, error) {
|
|
obj := &posts{}
|
|
|
|
return obj, nil
|
|
}); err != nil {
|
|
return err
|
|
}
|
|
if err := container.Container.Provide(func(
|
|
db *gorm.DB,
|
|
media *media,
|
|
orders *orders,
|
|
posts *posts,
|
|
users *users,
|
|
) (contracts.Initial, error) {
|
|
obj := &services{
|
|
db: db,
|
|
media: media,
|
|
orders: orders,
|
|
posts: posts,
|
|
users: users,
|
|
}
|
|
if err := obj.Prepare(); err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
return obj, nil
|
|
}, atom.GroupInitial); err != nil {
|
|
return err
|
|
}
|
|
if err := container.Container.Provide(func() (*users, error) {
|
|
obj := &users{}
|
|
|
|
return obj, nil
|
|
}); err != nil {
|
|
return err
|
|
}
|
|
return nil
|
|
}
|