refactor all service dependency injection
This commit is contained in:
@@ -5,8 +5,10 @@ import (
|
||||
"errors"
|
||||
"time"
|
||||
|
||||
"bsm/full/module/ec/order/internal/impl"
|
||||
"bsm/full/module/ec/order/internal/models"
|
||||
pb "bsm/full/module/ec/order/pb"
|
||||
|
||||
"git.apinb.com/bsm-sdk/core/errcode"
|
||||
"git.apinb.com/bsm-sdk/core/printer"
|
||||
"git.apinb.com/bsm-sdk/core/service"
|
||||
@@ -22,7 +24,7 @@ func Create(ctx context.Context, in *pb.CartAddRequest) (reply *pb.OrderStatusRe
|
||||
}
|
||||
var cart *models.OrderCart
|
||||
|
||||
err = models.DBService.Where("cart_identity=? and product_identity=? and spec_id = ? ", in.CartIdentity, in.ProductIdentity, in.SpecId).First(&cart).Error
|
||||
err = impl.DBService.Where("cart_identity=? and product_identity=? and spec_id = ? ", in.CartIdentity, in.ProductIdentity, in.SpecId).First(&cart).Error
|
||||
if err != nil {
|
||||
if !errors.Is(err, gorm.ErrRecordNotFound) {
|
||||
printer.Error(err.Error())
|
||||
@@ -41,10 +43,10 @@ func Create(ctx context.Context, in *pb.CartAddRequest) (reply *pb.OrderStatusRe
|
||||
data.PassportIdentity = auth.Identity
|
||||
data.Identity = utils.UUID()
|
||||
if cart.ID == 0 {
|
||||
err = models.DBService.Create(&data).Error
|
||||
err = impl.DBService.Create(&data).Error
|
||||
} else {
|
||||
data.Number += cart.Number
|
||||
err = models.DBService.Where("cart_identity=? and product_identity=? and spec_id = ? ", in.CartIdentity, in.ProductIdentity, in.SpecId).Updates(&data).Error
|
||||
err = impl.DBService.Where("cart_identity=? and product_identity=? and spec_id = ? ", in.CartIdentity, in.ProductIdentity, in.SpecId).Updates(&data).Error
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user