40 lines
813 B
Go
Raw Normal View History

package product
import (
"context"
"muyu-apiserver/gateway/internal/svc"
"muyu-apiserver/gateway/internal/types"
"muyu-apiserver/pkg/ctxdata"
"muyu-apiserver/rpc/inventory/pb"
"github.com/zeromicro/go-zero/core/logx"
)
type DeleteProductLogic struct {
logx.Logger
ctx context.Context
svcCtx *svc.ServiceContext
}
func NewDeleteProductLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DeleteProductLogic {
return &DeleteProductLogic{
Logger: logx.WithContext(ctx),
ctx: ctx,
svcCtx: svcCtx,
}
}
func (l *DeleteProductLogic) DeleteProduct() (resp *types.IdResp, err error) {
id := ctxdata.GetPathId(l.ctx)
_, err = l.svcCtx.InventoryRpc.DeleteProduct(l.ctx, &pb.DeleteProductReq{
ProductId: id,
})
if err != nil {
return nil, err
}
return &types.IdResp{Id: id}, nil
}