38 lines
825 B
Go
38 lines
825 B
Go
|
|
package supplier
|
||
|
|
|
||
|
|
import (
|
||
|
|
"context"
|
||
|
|
|
||
|
|
"muyu-apiserver/gateway/internal/svc"
|
||
|
|
"muyu-apiserver/gateway/internal/types"
|
||
|
|
"muyu-apiserver/pkg/ctxdata"
|
||
|
|
"muyu-apiserver/rpc/purchase/purchaseservice"
|
||
|
|
|
||
|
|
"github.com/zeromicro/go-zero/core/logx"
|
||
|
|
)
|
||
|
|
|
||
|
|
type GetSupplierLogic struct {
|
||
|
|
logx.Logger
|
||
|
|
ctx context.Context
|
||
|
|
svcCtx *svc.ServiceContext
|
||
|
|
}
|
||
|
|
|
||
|
|
func NewGetSupplierLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetSupplierLogic {
|
||
|
|
return &GetSupplierLogic{
|
||
|
|
Logger: logx.WithContext(ctx),
|
||
|
|
ctx: ctx,
|
||
|
|
svcCtx: svcCtx,
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
func (l *GetSupplierLogic) GetSupplier() (*types.SupplierInfo, error) {
|
||
|
|
id := ctxdata.GetPathId(l.ctx)
|
||
|
|
resp, err := l.svcCtx.PurchaseRpc.GetSupplier(l.ctx, &purchaseservice.GetSupplierReq{
|
||
|
|
SupplierId: id,
|
||
|
|
})
|
||
|
|
if err != nil {
|
||
|
|
return nil, err
|
||
|
|
}
|
||
|
|
return supplierInfoFromPB(resp), nil
|
||
|
|
}
|