feat: Implement bulk update for product prices and stock, and add low stock products query and toggle product status functionality
This commit is contained in:
@@ -43,6 +43,29 @@ service ProductsContract
|
||||
|
||||
};
|
||||
};
|
||||
rpc BulkUpdateProductPrices(BulkUpdateProductPricesRequest) returns (BulkUpdateProductPricesResponse){
|
||||
option (google.api.http) = {
|
||||
post: "/BulkUpdateProductPrices"
|
||||
body: "*"
|
||||
};
|
||||
};
|
||||
rpc BulkUpdateProductStock(BulkUpdateProductStockRequest) returns (BulkUpdateProductStockResponse){
|
||||
option (google.api.http) = {
|
||||
post: "/BulkUpdateProductStock"
|
||||
body: "*"
|
||||
};
|
||||
};
|
||||
rpc GetLowStockProducts(GetLowStockProductsRequest) returns (GetLowStockProductsResponse){
|
||||
option (google.api.http) = {
|
||||
get: "/GetLowStockProducts"
|
||||
};
|
||||
};
|
||||
rpc ToggleProductStatus(ToggleProductStatusRequest) returns (ToggleProductStatusResponse){
|
||||
option (google.api.http) = {
|
||||
post: "/ToggleProductStatus"
|
||||
body: "*"
|
||||
};
|
||||
};
|
||||
}
|
||||
message CreateNewProductsRequest
|
||||
{
|
||||
@@ -155,3 +178,99 @@ message GetAllProductsByFilterResponseModel
|
||||
// لیست شناسه دستهبندیهای محصول
|
||||
repeated int64 category_ids = 14;
|
||||
}
|
||||
|
||||
// Bulk Update Product Prices
|
||||
message BulkUpdateProductPricesRequest
|
||||
{
|
||||
repeated ProductPriceUpdate products = 1;
|
||||
}
|
||||
|
||||
message ProductPriceUpdate
|
||||
{
|
||||
int64 product_id = 1;
|
||||
int64 new_price = 2;
|
||||
google.protobuf.Int32Value new_discount = 3;
|
||||
google.protobuf.Int32Value new_club_discount_percent = 4;
|
||||
}
|
||||
|
||||
message BulkUpdateProductPricesResponse
|
||||
{
|
||||
int32 total = 1;
|
||||
int32 succeeded = 2;
|
||||
int32 failed = 3;
|
||||
repeated BulkOperationError errors = 4;
|
||||
}
|
||||
|
||||
message BulkOperationError
|
||||
{
|
||||
int64 product_id = 1;
|
||||
string error_message = 2;
|
||||
}
|
||||
|
||||
// Bulk Update Product Stock
|
||||
message BulkUpdateProductStockRequest
|
||||
{
|
||||
repeated ProductStockUpdate products = 1;
|
||||
StockUpdateType update_type = 2;
|
||||
}
|
||||
|
||||
message ProductStockUpdate
|
||||
{
|
||||
int64 product_id = 1;
|
||||
int32 quantity = 2;
|
||||
}
|
||||
|
||||
enum StockUpdateType
|
||||
{
|
||||
SET = 0;
|
||||
ADD = 1;
|
||||
SUBTRACT = 2;
|
||||
}
|
||||
|
||||
message BulkUpdateProductStockResponse
|
||||
{
|
||||
int32 total = 1;
|
||||
int32 succeeded = 2;
|
||||
int32 failed = 3;
|
||||
repeated BulkOperationError errors = 4;
|
||||
}
|
||||
|
||||
// Get Low Stock Products
|
||||
message GetLowStockProductsRequest
|
||||
{
|
||||
int32 threshold = 1;
|
||||
int32 page_index = 2;
|
||||
int32 page_size = 3;
|
||||
google.protobuf.BoolValue is_club_exclusive = 4;
|
||||
}
|
||||
|
||||
message GetLowStockProductsResponse
|
||||
{
|
||||
messages.MetaData meta_data = 1;
|
||||
repeated LowStockProduct products = 2;
|
||||
}
|
||||
|
||||
message LowStockProduct
|
||||
{
|
||||
int64 id = 1;
|
||||
string title = 2;
|
||||
int32 remaining_count = 3;
|
||||
int64 price = 4;
|
||||
bool is_club_exclusive = 5;
|
||||
}
|
||||
|
||||
// Toggle Product Status
|
||||
message ToggleProductStatusRequest
|
||||
{
|
||||
repeated int64 product_ids = 1;
|
||||
bool enable = 2;
|
||||
int32 default_stock = 3;
|
||||
}
|
||||
|
||||
message ToggleProductStatusResponse
|
||||
{
|
||||
int32 total = 1;
|
||||
int32 succeeded = 2;
|
||||
int32 failed = 3;
|
||||
repeated BulkOperationError errors = 4;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user