refactor all service dependency injection
This commit is contained in:
@@ -4,8 +4,10 @@ import (
|
||||
"context"
|
||||
"time"
|
||||
|
||||
"bsm/full/module/ec/address/internal/impl"
|
||||
"bsm/full/module/ec/address/internal/models"
|
||||
pb "bsm/full/module/ec/address/pb"
|
||||
|
||||
"git.apinb.com/bsm-sdk/core/errcode"
|
||||
"git.apinb.com/bsm-sdk/core/printer"
|
||||
"git.apinb.com/bsm-sdk/core/service"
|
||||
@@ -37,10 +39,10 @@ func Create(ctx context.Context, in *pb.AddressCreateRequest) (reply *pb.StatusR
|
||||
address.Status = int8(in.Status)
|
||||
|
||||
if address.Status == 2 {
|
||||
models.DBService.Model(&models.AddressLibrary{}).Where("owner_id = ? and status=2", auth.ID).UpdateColumn("status", "1")
|
||||
impl.DBService.Model(&models.AddressLibrary{}).Where("owner_id = ? and status=2", auth.ID).UpdateColumn("status", "1")
|
||||
}
|
||||
|
||||
err = models.DBService.Create(address).Error
|
||||
err = impl.DBService.Create(address).Error
|
||||
|
||||
if err != nil {
|
||||
printer.Error(err.Error())
|
||||
|
||||
@@ -4,8 +4,10 @@ import (
|
||||
"context"
|
||||
"time"
|
||||
|
||||
"bsm/full/module/ec/address/internal/impl"
|
||||
"bsm/full/module/ec/address/internal/models"
|
||||
pb "bsm/full/module/ec/address/pb"
|
||||
|
||||
"git.apinb.com/bsm-sdk/core/errcode"
|
||||
"git.apinb.com/bsm-sdk/core/printer"
|
||||
"git.apinb.com/bsm-sdk/core/service"
|
||||
@@ -19,7 +21,7 @@ func Delete(ctx context.Context, in *pb.AddressDeleteRequest) (reply *pb.StatusR
|
||||
return nil, err
|
||||
}
|
||||
|
||||
err = models.DBService.Delete(&models.AddressLibrary{}, "id in ?", in.Id).Error
|
||||
err = impl.DBService.Delete(&models.AddressLibrary{}, "id in ?", in.Id).Error
|
||||
if err != nil {
|
||||
printer.Error(err.Error())
|
||||
return nil, errcode.ErrDB
|
||||
|
||||
@@ -3,8 +3,10 @@ package library
|
||||
import (
|
||||
"context"
|
||||
|
||||
"bsm/full/module/ec/address/internal/impl"
|
||||
"bsm/full/module/ec/address/internal/models"
|
||||
pb "bsm/full/module/ec/address/pb"
|
||||
|
||||
"git.apinb.com/bsm-sdk/core/errcode"
|
||||
"git.apinb.com/bsm-sdk/core/printer"
|
||||
"git.apinb.com/bsm-sdk/core/service"
|
||||
@@ -23,7 +25,7 @@ func Fetch(ctx context.Context, in *pb.IdentRequest) (reply *pb.AddressListReply
|
||||
result = make([]*pb.AddressItem, 0)
|
||||
)
|
||||
|
||||
err = models.DBService.Where("owner_identity=?", auth.Identity).Find(&address).Error
|
||||
err = impl.DBService.Where("owner_identity=?", auth.Identity).Find(&address).Error
|
||||
if err != nil {
|
||||
printer.Error(err.Error())
|
||||
return nil, errcode.ErrDB
|
||||
|
||||
@@ -4,8 +4,10 @@ import (
|
||||
"context"
|
||||
"errors"
|
||||
|
||||
"bsm/full/module/ec/address/internal/impl"
|
||||
"bsm/full/module/ec/address/internal/models"
|
||||
pb "bsm/full/module/ec/address/pb"
|
||||
|
||||
"git.apinb.com/bsm-sdk/core/errcode"
|
||||
"git.apinb.com/bsm-sdk/core/printer"
|
||||
"git.apinb.com/bsm-sdk/core/service"
|
||||
@@ -24,7 +26,7 @@ func Get(ctx context.Context, in *pb.IdentRequest) (reply *pb.AddressItem, err e
|
||||
}
|
||||
|
||||
address := new(models.AddressLibrary)
|
||||
err = models.DBService.Where("id=?", in.Id).First(&address).Error
|
||||
err = impl.DBService.Where("id=?", in.Id).First(&address).Error
|
||||
|
||||
if err != nil {
|
||||
if errors.Is(err, models.ErrNotFound) {
|
||||
|
||||
@@ -4,8 +4,10 @@ import (
|
||||
"context"
|
||||
"time"
|
||||
|
||||
"bsm/full/module/ec/address/internal/impl"
|
||||
"bsm/full/module/ec/address/internal/models"
|
||||
pb "bsm/full/module/ec/address/pb"
|
||||
|
||||
"git.apinb.com/bsm-sdk/core/errcode"
|
||||
"git.apinb.com/bsm-sdk/core/printer"
|
||||
"git.apinb.com/bsm-sdk/core/service"
|
||||
@@ -31,10 +33,10 @@ func Modify(ctx context.Context, in *pb.AddressItem) (reply *pb.StatusReply, err
|
||||
address.Status = int8(in.Status)
|
||||
|
||||
if address.Status == 2 {
|
||||
models.DBService.Model(&models.AddressLibrary{}).Where("owner_id = ? and status=2", auth.ID).UpdateColumn("status", "1")
|
||||
impl.DBService.Model(&models.AddressLibrary{}).Where("owner_id = ? and status=2", auth.ID).UpdateColumn("status", "1")
|
||||
}
|
||||
|
||||
err = models.DBService.Where("id=?", in.Id).Updates(&address).Error
|
||||
err = impl.DBService.Where("id=?", in.Id).Updates(&address).Error
|
||||
if err != nil {
|
||||
printer.Error(err.Error())
|
||||
return nil, errcode.ErrDB
|
||||
|
||||
Reference in New Issue
Block a user