38 lines
882 B
Go
Raw Permalink Normal View History

package supplier
import (
"context"
"muyu-apiserver/gateway/internal/svc"
"muyu-apiserver/gateway/internal/types"
"muyu-apiserver/rpc/purchase/purchaseservice"
"github.com/zeromicro/go-zero/core/logx"
)
type CreateSupplierLogic struct {
logx.Logger
ctx context.Context
svcCtx *svc.ServiceContext
}
func NewCreateSupplierLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CreateSupplierLogic {
return &CreateSupplierLogic{
Logger: logx.WithContext(ctx),
ctx: ctx,
svcCtx: svcCtx,
}
}
func (l *CreateSupplierLogic) CreateSupplier(req *types.CreateSupplierReq) (*types.IdResp, error) {
resp, err := l.svcCtx.PurchaseRpc.CreateSupplier(l.ctx, &purchaseservice.CreateSupplierReq{
SupplierName: req.SupplierName,
Phone: req.Phone,
Remark: req.Remark,
})
if err != nil {
return nil, err
}
return &types.IdResp{Id: resp.Id}, nil
}