- Added CouponID field to Order model to track used coupons. - Updated order query generation to include CouponID. - Introduced UserCoupon model to manage user coupon associations. - Implemented query methods for UserCoupon to facilitate CRUD operations. - Updated query context and default query setup to include UserCoupon.
143 lines
2.6 KiB
Go
Executable File
143 lines
2.6 KiB
Go
Executable File
package services
|
|
|
|
import (
|
|
"quyun/v2/providers/job"
|
|
"quyun/v2/providers/jwt"
|
|
"quyun/v2/providers/storage"
|
|
|
|
"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() (*audit, error) {
|
|
obj := &audit{}
|
|
|
|
return obj, nil
|
|
}); err != nil {
|
|
return err
|
|
}
|
|
if err := container.Container.Provide(func(
|
|
storage *storage.Storage,
|
|
) (*common, error) {
|
|
obj := &common{
|
|
storage: storage,
|
|
}
|
|
|
|
return obj, nil
|
|
}); err != nil {
|
|
return err
|
|
}
|
|
if err := container.Container.Provide(func() (*content, error) {
|
|
obj := &content{}
|
|
|
|
return obj, nil
|
|
}); err != nil {
|
|
return err
|
|
}
|
|
if err := container.Container.Provide(func() (*coupon, error) {
|
|
obj := &coupon{}
|
|
|
|
return obj, nil
|
|
}); err != nil {
|
|
return err
|
|
}
|
|
if err := container.Container.Provide(func() (*creator, error) {
|
|
obj := &creator{}
|
|
|
|
return obj, nil
|
|
}); err != nil {
|
|
return err
|
|
}
|
|
if err := container.Container.Provide(func(
|
|
job *job.Job,
|
|
) (*notification, error) {
|
|
obj := ¬ification{
|
|
job: job,
|
|
}
|
|
|
|
return obj, nil
|
|
}); err != nil {
|
|
return err
|
|
}
|
|
if err := container.Container.Provide(func() (*order, error) {
|
|
obj := &order{}
|
|
|
|
return obj, nil
|
|
}); err != nil {
|
|
return err
|
|
}
|
|
if err := container.Container.Provide(func(
|
|
audit *audit,
|
|
common *common,
|
|
content *content,
|
|
coupon *coupon,
|
|
creator *creator,
|
|
db *gorm.DB,
|
|
notification *notification,
|
|
order *order,
|
|
super *super,
|
|
tenant *tenant,
|
|
user *user,
|
|
wallet *wallet,
|
|
) (contracts.Initial, error) {
|
|
obj := &services{
|
|
audit: audit,
|
|
common: common,
|
|
content: content,
|
|
coupon: coupon,
|
|
creator: creator,
|
|
db: db,
|
|
notification: notification,
|
|
order: order,
|
|
super: super,
|
|
tenant: tenant,
|
|
user: user,
|
|
wallet: wallet,
|
|
}
|
|
if err := obj.Prepare(); err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
return obj, nil
|
|
}, atom.GroupInitial); err != nil {
|
|
return err
|
|
}
|
|
if err := container.Container.Provide(func() (*super, error) {
|
|
obj := &super{}
|
|
|
|
return obj, nil
|
|
}); 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(
|
|
jwt *jwt.JWT,
|
|
) (*user, error) {
|
|
obj := &user{
|
|
jwt: jwt,
|
|
}
|
|
|
|
return obj, nil
|
|
}); err != nil {
|
|
return err
|
|
}
|
|
if err := container.Container.Provide(func() (*wallet, error) {
|
|
obj := &wallet{}
|
|
|
|
return obj, nil
|
|
}); err != nil {
|
|
return err
|
|
}
|
|
return nil
|
|
}
|