72 lines
2.6 KiB
Go
72 lines
2.6 KiB
Go
// Code generated by goctl. DO NOT EDIT.
|
|
// Source: trade.proto
|
|
|
|
package server
|
|
|
|
import (
|
|
"context"
|
|
|
|
"app-cloudep-trade-service/gen_result/pb/trade"
|
|
"app-cloudep-trade-service/internal/logic/inventoryservice"
|
|
"app-cloudep-trade-service/internal/svc"
|
|
)
|
|
|
|
type InventoryServiceServer struct {
|
|
svcCtx *svc.ServiceContext
|
|
trade.UnimplementedInventoryServiceServer
|
|
}
|
|
|
|
func NewInventoryServiceServer(svcCtx *svc.ServiceContext) *InventoryServiceServer {
|
|
return &InventoryServiceServer{
|
|
svcCtx: svcCtx,
|
|
}
|
|
}
|
|
|
|
// CreateStock 建立庫存品項
|
|
func (s *InventoryServiceServer) CreateStock(ctx context.Context, in *trade.StockAdjustmentReq) (*trade.OKResp, error) {
|
|
l := inventoryservicelogic.NewCreateStockLogic(ctx, s.svcCtx)
|
|
return l.CreateStock(in)
|
|
}
|
|
|
|
// AddStock 增加庫存
|
|
func (s *InventoryServiceServer) AddStock(ctx context.Context, in *trade.StockAdjustmentReq) (*trade.OKResp, error) {
|
|
l := inventoryservicelogic.NewAddStockLogic(ctx, s.svcCtx)
|
|
return l.AddStock(in)
|
|
}
|
|
|
|
// ReduceStock 減少庫存
|
|
func (s *InventoryServiceServer) ReduceStock(ctx context.Context, in *trade.StockAdjustmentReq) (*trade.OKResp, error) {
|
|
l := inventoryservicelogic.NewReduceStockLogic(ctx, s.svcCtx)
|
|
return l.ReduceStock(in)
|
|
}
|
|
|
|
// QueryStock 查詢單一商品的庫存
|
|
func (s *InventoryServiceServer) QueryStock(ctx context.Context, in *trade.StockQueryReq) (*trade.StockResp, error) {
|
|
l := inventoryservicelogic.NewQueryStockLogic(ctx, s.svcCtx)
|
|
return l.QueryStock(in)
|
|
}
|
|
|
|
// ListAllStock 查詢所有商品的庫存狀況
|
|
func (s *InventoryServiceServer) ListAllStock(ctx context.Context, in *trade.StockListReq) (*trade.StockListResp, error) {
|
|
l := inventoryservicelogic.NewListAllStockLogic(ctx, s.svcCtx)
|
|
return l.ListAllStock(in)
|
|
}
|
|
|
|
// ReserveStock 預留庫存 (用於未完成的訂單)
|
|
func (s *InventoryServiceServer) ReserveStock(ctx context.Context, in *trade.StockReservationReq) (*trade.OKResp, error) {
|
|
l := inventoryservicelogic.NewReserveStockLogic(ctx, s.svcCtx)
|
|
return l.ReserveStock(in)
|
|
}
|
|
|
|
// ReleaseReservedStock 釋放預留庫存 (取消或失效的訂單)
|
|
func (s *InventoryServiceServer) ReleaseReservedStock(ctx context.Context, in *trade.StockReservationReq) (*trade.OKResp, error) {
|
|
l := inventoryservicelogic.NewReleaseReservedStockLogic(ctx, s.svcCtx)
|
|
return l.ReleaseReservedStock(in)
|
|
}
|
|
|
|
// AdjustStock 調整庫存 (批量修改庫存,用於大批商品更新)
|
|
func (s *InventoryServiceServer) AdjustStock(ctx context.Context, in *trade.BatchStockAdjustmentReq) (*trade.OKResp, error) {
|
|
l := inventoryservicelogic.NewAdjustStockLogic(ctx, s.svcCtx)
|
|
return l.AdjustStock(in)
|
|
}
|