update product service proto

This commit is contained in:
daniel.w 2024-10-25 16:21:12 +08:00
parent e01d14ab90
commit 25b422b907
1 changed files with 130 additions and 105 deletions

View File

@ -247,6 +247,12 @@ message StockResp {
int64 reserved_quantity = 3; // 預留庫存 int64 reserved_quantity = 3; // 預留庫存
} }
message StockListReq {
int64 page_index = 1; // required
int64 page_size = 2; // required
repeated string product_id = 3; // 一次查多筆
}
message StockListResp { message StockListResp {
repeated StockResp stock_items = 1; // 所有商品的庫存清單 repeated StockResp stock_items = 1; // 所有商品的庫存清單
Pager page = 2; Pager page = 2;
@ -261,8 +267,9 @@ message BatchStockAdjustmentReq {
repeated StockAdjustmentReq adjustments = 1; // 批次調整庫存 repeated StockAdjustmentReq adjustments = 1; // 批次調整庫存
} }
service InventoryService { service InventoryService {
// CreateStock 建立庫存品項
rpc CreateStock(StockAdjustmentReq) returns (OKResp);
// AddStock 增加庫存 // AddStock 增加庫存
rpc AddStock(StockAdjustmentReq) returns (OKResp); rpc AddStock(StockAdjustmentReq) returns (OKResp);
// ReduceStock 減少庫存 // ReduceStock 減少庫存
@ -270,7 +277,7 @@ service InventoryService {
// QueryStock 查詢單一商品的庫存 // QueryStock 查詢單一商品的庫存
rpc QueryStock(StockQueryReq) returns (StockResp); rpc QueryStock(StockQueryReq) returns (StockResp);
// ListAllStock 查詢所有商品的庫存狀況 // ListAllStock 查詢所有商品的庫存狀況
rpc ListAllStock(NoneReq) returns (StockListResp); rpc ListAllStock(StockListReq) returns (StockListResp);
// ReserveStock 預留庫存 (用於未完成的訂單) // ReserveStock 預留庫存 (用於未完成的訂單)
rpc ReserveStock(StockReservationReq) returns (OKResp); rpc ReserveStock(StockReservationReq) returns (OKResp);
// ReleaseReservedStock 釋放預留庫存 (取消或失效的訂單) // ReleaseReservedStock 釋放預留庫存 (取消或失效的訂單)
@ -284,17 +291,34 @@ service InventoryService {
// 商品請求和回應訊息 // 商品請求和回應訊息
message ProductCreateReq { message ProductCreateReq {
string name = 1; // 商品名稱 string name = 1; // 商品名稱
string category = 2; // 商品分類 string description = 2; // 商品簡述
string description = 3; // 商品描述 string content = 3; // 詳細商品內容
double price = 4; // 商品價格 double price = 4; // 商品價格
int64 amount_type = 5; // 1 有限數量 2 無限數量
string currency = 6; // 貨幣類型 (如 USD, TWD)
repeated string brand = 7; // 產品品牌,可以看成channel_id or uid 就是誰得商品,用品牌比較通用
repeated string category = 8; // 商品分類
repeated string tags = 9; // 產品標籤(方便篩選)
string sku = 10; // 庫存單位(Stock Keeping Unit)
repeated string images = 11; // 商品照片網址
optional string coupon_id = 12; // 本商品專屬折扣碼 id
} }
message ProductUpdateReq { message ProductUpdateReq {
string product_id = 1; // 商品ID string product_id = 1; // 商品ID
string name = 2; // 商品名稱 optional string name = 2; // 商品名稱
string category = 3; // 商品分類 optional string description = 3; // 商品簡述
string description = 4; // 商品描述 optional string content = 4; // 詳細商品內容
double price = 5; // 商品價格 optional double price = 5; // 商品價格
optional int64 amount_type = 6; // 1 有限數量 2 無限數量
optional string currency = 7; // 貨幣類型 (如 USD, TWD)
repeated string brand = 8; // 產品品牌,可以看成channel_id or uid 就是誰得商品,用品牌比較通用
repeated string category = 9; // 商品分類
repeated string tags = 10; // 產品標籤(方便篩選)
optional string sku = 11; // 庫存單位(Stock Keeping Unit)
repeated string images = 12; // 商品照片網址
optional string coupon_id = 13; // 本商品專屬折扣碼 id
optional bool is_available = 14; // 是否上架
} }
message ProductDeleteReq { message ProductDeleteReq {
@ -308,28 +332,36 @@ message ProductQueryReq {
message ProductResp { message ProductResp {
string product_id = 1; // 商品ID string product_id = 1; // 商品ID
string name = 2; // 商品名稱 string name = 2; // 商品名稱
string category = 3; // 商品分類 string description = 3; // 商品簡述
string description = 4; // 商品描述 string content = 4; // 詳細商品內容
double price = 5; // 商品價格 double price = 5; // 商品價格
bool is_available = 6; // 是否上架 int64 amount_type = 6; // 1 有限數量 2 無限數量
repeated string currency = 7; // 貨幣類型 (如 USD, TWD)
repeated string brand = 8; // 產品品牌,可以看成channel_id or uid 就是誰得商品,用品牌比較通用
string category = 9; // 商品分類
repeated string tags = 10; // 產品標籤(方便篩選)
string sku = 11; // 庫存單位(Stock Keeping Unit)
repeated string images = 12; // 商品照片網址
string coupon_id = 13; // 本商品專屬折扣碼 id
bool is_available = 14; // 是否上架
}
message ProductListReq {
int64 page_index = 1;
int64 page_size = 2;
repeated string product_id = 3; // 商品ID
optional bool is_available = 4; // 是否上架
repeated string tags = 5; // 產品標籤(方便篩選)
optional int64 amount_type = 6; // 1 有限數量 2 無限數量
repeated string currency = 7; // 貨幣類型 (如 USD, TWD)
repeated string brand = 8; // 產品品牌,可以看成channel_id or uid 就是誰得商品,用品牌比較通用
repeated string category = 9; // 商品分類
} }
message ProductListResp { message ProductListResp {
repeated ProductResp products = 1; // 所有商品清單 repeated ProductResp products = 1; // 所有商品清單
} Pager page = 2;
message CategoryQueryReq {
string category = 1; // 商品分類
}
message ProductPriceUpdateReq {
string product_id = 1; // 商品ID
double new_price = 2; // 新價格
}
message ProductStatusUpdateReq {
string product_id = 1; // 商品ID
bool is_available = 2; // 是否上架
} }
service ProductService { service ProductService {
@ -342,13 +374,7 @@ service ProductService {
// QueryProduct 查詢單一商品資訊 // QueryProduct 查詢單一商品資訊
rpc QueryProduct(ProductQueryReq) returns (ProductResp); rpc QueryProduct(ProductQueryReq) returns (ProductResp);
// ListAllProducts 查詢所有商品資訊 // ListAllProducts 查詢所有商品資訊
rpc ListAllProducts(NoneReq) returns (ProductListResp); rpc ListAllProducts(ProductListReq) returns (ProductListResp);
// ListProductsByCategory 根據分類查詢商品
rpc ListProductsByCategory(CategoryQueryReq) returns (ProductListResp);
// UpdateProductPrice 更新商品價格
rpc UpdateProductPrice(ProductPriceUpdateReq) returns (OKResp);
// UpdateProductStatus 更新商品狀態 (上架/下架)
rpc UpdateProductStatus(ProductStatusUpdateReq) returns (OKResp);
} }
// ========== 訂閱服務 =========== // ========== 訂閱服務 ===========
@ -382,7 +408,6 @@ message SubscriptionResp {
string status = 6; // 訂閱狀態 (例如: "active", "expired", "canceled") string status = 6; // 訂閱狀態 (例如: "active", "expired", "canceled")
} }
message ListSubscriptionsReq { message ListSubscriptionsReq {
int64 page_index = 1; int64 page_index = 1;
int64 page_size = 2; int64 page_size = 2;