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() (*content, error) {
|
|
obj := &content{}
|
|
|
|
return obj, nil
|
|
}); err != nil {
|
|
return err
|
|
}
|
|
if err := container.Container.Provide(func(
|
|
content *content,
|
|
db *gorm.DB,
|
|
tenant *tenant,
|
|
test *test,
|
|
user *user,
|
|
) (contracts.Initial, error) {
|
|
obj := &services{
|
|
content: content,
|
|
db: db,
|
|
tenant: tenant,
|
|
test: test,
|
|
user: user,
|
|
}
|
|
if err := obj.Prepare(); err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
return obj, nil
|
|
}, atom.GroupInitial); err != nil {
|
|
return err
|
|
}
|
|
if err := container.Container.Provide(func() (*tenant, error) {
|
|
obj := &tenant{}
|
|
|
|
return obj, nil
|
|
}); err != nil {
|
|
return err
|
|
}
|
|
if err := container.Container.Provide(func() (*test, error) {
|
|
obj := &test{}
|
|
|
|
return obj, nil
|
|
}); err != nil {
|
|
return err
|
|
}
|
|
if err := container.Container.Provide(func() (*user, error) {
|
|
obj := &user{}
|
|
|
|
return obj, nil
|
|
}); err != nil {
|
|
return err
|
|
}
|
|
return nil
|
|
}
|