feat: Add discount module with protobuf definitions and gRPC services

This commit is contained in:
masoodafar-web
2025-12-06 01:39:22 +03:30
parent 4aa9f28f6e
commit 09fc0d85af
51 changed files with 1964 additions and 80 deletions
@@ -0,0 +1,33 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net9.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<Version>0.0.1</Version>
<DebugType>None</DebugType>
<DebugSymbols>False</DebugSymbols>
<GeneratePackageOnBuild>False</GeneratePackageOnBuild>
<PackageId>Foursat.BackOffice.BFF.DiscountCategory.Protobuf</PackageId>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Google.Protobuf" Version="3.23.3" />
<PackageReference Include="Grpc.Core.Api" Version="2.54.0" />
<PackageReference Include="Grpc.Tools" Version="2.72.0">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="FluentValidation.DependencyInjectionExtensions" Version="11.2.2" />
<PackageReference Include="Google.Api.CommonProtos" Version="2.10.0" />
</ItemGroup>
<ItemGroup>
<Protobuf Include="Protos\discountcategory.proto" ProtoRoot="Protos\" GrpcServices="Client" AdditionalImportDirs="..\BackOffice.BFF.Common.Protobuf\Protos"/>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\BackOffice.BFF.Common.Protobuf\BackOffice.BFF.Common.Protobuf.csproj" />
</ItemGroup>
</Project>
@@ -0,0 +1,100 @@
syntax = "proto3";
package discountcategory;
import "public_messages.proto";
import "google/protobuf/empty.proto";
import "google/protobuf/wrappers.proto";
import "google/protobuf/timestamp.proto";
import "google/api/annotations.proto";
option csharp_namespace = "BackOffice.BFF.DiscountCategory.Protobuf.Protos.DiscountCategory";
service DiscountCategoryContract
{
rpc CreateDiscountCategory(CreateDiscountCategoryRequest) returns (CreateDiscountCategoryResponse){
option (google.api.http) = {
post: "/CreateDiscountCategory"
body: "*"
};
};
rpc UpdateDiscountCategory(UpdateDiscountCategoryRequest) returns (google.protobuf.Empty){
option (google.api.http) = {
put: "/UpdateDiscountCategory"
body: "*"
};
};
rpc DeleteDiscountCategory(DeleteDiscountCategoryRequest) returns (google.protobuf.Empty){
option (google.api.http) = {
delete: "/DeleteDiscountCategory"
body: "*"
};
};
rpc GetDiscountCategories(GetDiscountCategoriesRequest) returns (GetDiscountCategoriesResponse){
option (google.api.http) = {
get: "/GetDiscountCategories"
};
};
}
// Create Category
message CreateDiscountCategoryRequest
{
string name = 1;
string title = 2;
google.protobuf.StringValue description = 3;
google.protobuf.StringValue image_path = 4;
google.protobuf.Int64Value parent_category_id = 5;
int32 sort_order = 6;
bool is_active = 7;
}
message CreateDiscountCategoryResponse
{
int64 category_id = 1;
}
// Update Category
message UpdateDiscountCategoryRequest
{
int64 category_id = 1;
string name = 2;
string title = 3;
google.protobuf.StringValue description = 4;
google.protobuf.StringValue image_path = 5;
google.protobuf.Int64Value parent_category_id = 6;
int32 sort_order = 7;
bool is_active = 8;
}
// Delete Category
message DeleteDiscountCategoryRequest
{
int64 category_id = 1;
}
// Get Categories with Tree Structure
message GetDiscountCategoriesRequest
{
google.protobuf.Int64Value parent_category_id = 1; // null = root categories
google.protobuf.BoolValue is_active = 2;
}
message GetDiscountCategoriesResponse
{
repeated DiscountCategoryDto categories = 1;
}
message DiscountCategoryDto
{
int64 id = 1;
string name = 2;
string title = 3;
google.protobuf.StringValue description = 4;
google.protobuf.StringValue image_path = 5;
google.protobuf.Int64Value parent_category_id = 6;
int32 sort_order = 7;
bool is_active = 8;
int32 product_count = 9;
repeated DiscountCategoryDto children = 10; // Recursive children
}
@@ -0,0 +1,31 @@
// Copyright (c) 2015, Google Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
syntax = "proto3";
package google.api;
import "google/api/http.proto";
import "google/protobuf/descriptor.proto";
option go_package = "google.golang.org/genproto/googleapis/api/annotations;annotations";
option java_multiple_files = true;
option java_outer_classname = "AnnotationsProto";
option java_package = "com.google.api";
option objc_class_prefix = "GAPI";
extend google.protobuf.MethodOptions {
// See `HttpRule`.
HttpRule http = 72295728;
}
@@ -0,0 +1,51 @@
// Copyright 2019 Google LLC.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
syntax = "proto3";
package google.api;
option cc_enable_arenas = true;
option go_package = "google.golang.org/genproto/googleapis/api/annotations;annotations";
option java_multiple_files = true;
option java_outer_classname = "HttpProto";
option java_package = "com.google.api";
option objc_class_prefix = "GAPI";
message Http {
repeated HttpRule rules = 1;
bool fully_decode_reserved_expansion = 2;
}
message HttpRule {
string selector = 1;
oneof pattern {
string get = 2;
string put = 3;
string post = 4;
string delete = 5;
string patch = 6;
CustomHttpPattern custom = 8;
}
string body = 7;
string response_body = 12;
repeated HttpRule additional_bindings = 11;
}
message CustomHttpPattern {
string kind = 1;
string path = 2;
}
@@ -0,0 +1,33 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net9.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<Version>0.0.1</Version>
<DebugType>None</DebugType>
<DebugSymbols>False</DebugSymbols>
<GeneratePackageOnBuild>False</GeneratePackageOnBuild>
<PackageId>Foursat.BackOffice.BFF.DiscountOrder.Protobuf</PackageId>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Google.Protobuf" Version="3.23.3" />
<PackageReference Include="Grpc.Core.Api" Version="2.54.0" />
<PackageReference Include="Grpc.Tools" Version="2.72.0">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="FluentValidation.DependencyInjectionExtensions" Version="11.2.2" />
<PackageReference Include="Google.Api.CommonProtos" Version="2.10.0" />
</ItemGroup>
<ItemGroup>
<Protobuf Include="Protos\discountorder.proto" ProtoRoot="Protos\" GrpcServices="Client" AdditionalImportDirs="..\BackOffice.BFF.Common.Protobuf\Protos"/>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\BackOffice.BFF.Common.Protobuf\BackOffice.BFF.Common.Protobuf.csproj" />
</ItemGroup>
</Project>
@@ -0,0 +1,177 @@
syntax = "proto3";
package discountorder;
import "public_messages.proto";
import "google/protobuf/empty.proto";
import "google/protobuf/wrappers.proto";
import "google/protobuf/timestamp.proto";
import "google/api/annotations.proto";
option csharp_namespace = "BackOffice.BFF.DiscountOrder.Protobuf.Protos.DiscountOrder";
service DiscountOrderContract
{
rpc PlaceOrder(PlaceOrderRequest) returns (PlaceOrderResponse){
option (google.api.http) = {
post: "/PlaceOrder"
body: "*"
};
};
rpc CompleteOrderPayment(CompleteOrderPaymentRequest) returns (CompleteOrderPaymentResponse){
option (google.api.http) = {
post: "/CompleteOrderPayment"
body: "*"
};
};
rpc UpdateOrderStatus(UpdateOrderStatusRequest) returns (UpdateOrderStatusResponse){
option (google.api.http) = {
put: "/UpdateOrderStatus"
body: "*"
};
};
rpc GetOrderById(GetOrderByIdRequest) returns (GetOrderByIdResponse){
option (google.api.http) = {
get: "/GetOrderById"
};
};
rpc GetUserOrders(GetUserOrdersRequest) returns (GetUserOrdersResponse){
option (google.api.http) = {
get: "/GetUserOrders"
};
};
}
// Place Order (Initial Step - Create Order)
message PlaceOrderRequest
{
int64 user_id = 1;
int64 user_address_id = 2;
int64 discount_balance_to_use = 3; // Amount from DiscountBalance wallet
google.protobuf.StringValue notes = 4;
}
message PlaceOrderResponse
{
bool success = 1;
string message = 2;
int64 order_id = 3;
int64 gateway_amount = 4; // Amount to pay via gateway (if any)
google.protobuf.StringValue payment_url = 5; // Payment gateway URL (if needed)
}
// Complete Order Payment (After Gateway Callback)
message CompleteOrderPaymentRequest
{
int64 order_id = 1;
google.protobuf.StringValue transaction_id = 2;
bool payment_success = 3;
}
message CompleteOrderPaymentResponse
{
bool success = 1;
string message = 2;
}
// Update Order Status (Admin)
message UpdateOrderStatusRequest
{
int64 order_id = 1;
DeliveryStatus delivery_status = 2;
google.protobuf.StringValue tracking_code = 3;
google.protobuf.StringValue admin_notes = 4;
}
message UpdateOrderStatusResponse
{
bool success = 1;
string message = 2;
}
enum DeliveryStatus
{
DELIVERY_PENDING = 0;
DELIVERY_PROCESSING = 1;
DELIVERY_SHIPPED = 2;
DELIVERY_DELIVERED = 3;
DELIVERY_CANCELLED = 4;
}
// Get Order By Id
message GetOrderByIdRequest
{
int64 order_id = 1;
int64 user_id = 2; // For authorization check
}
message GetOrderByIdResponse
{
int64 id = 1;
int64 user_id = 2;
string order_number = 3;
AddressInfo address = 4;
int64 total_price = 5;
int64 discount_balance_used = 6;
int64 gateway_amount = 7;
bool payment_completed = 8;
google.protobuf.StringValue transaction_id = 9;
DeliveryStatus delivery_status = 10;
google.protobuf.StringValue tracking_code = 11;
google.protobuf.StringValue notes = 12;
google.protobuf.StringValue admin_notes = 13;
repeated OrderItemDto items = 14;
google.protobuf.Timestamp created = 15;
google.protobuf.Timestamp last_modified = 16;
}
message AddressInfo
{
int64 id = 1;
string title = 2;
string address = 3;
string postal_code = 4;
google.protobuf.StringValue phone = 5;
}
message OrderItemDto
{
int64 product_id = 1;
string product_title = 2;
int64 unit_price = 3;
int32 max_discount_percent = 4;
int32 count = 5;
int64 total_price = 6;
int64 discount_amount = 7;
int64 final_price = 8;
}
// Get User Orders
message GetUserOrdersRequest
{
int64 user_id = 1;
google.protobuf.BoolValue payment_completed = 2;
google.protobuf.Int32Value delivery_status = 3; // DeliveryStatus as int
int32 page_number = 4;
int32 page_size = 5;
}
message GetUserOrdersResponse
{
messages.MetaData meta_data = 1;
repeated OrderSummaryDto models = 2;
}
message OrderSummaryDto
{
int64 id = 1;
string order_number = 2;
int64 total_price = 3;
int64 discount_balance_used = 4;
int64 gateway_amount = 5;
bool payment_completed = 6;
DeliveryStatus delivery_status = 7;
google.protobuf.StringValue tracking_code = 8;
int32 items_count = 9;
google.protobuf.Timestamp created = 10;
}
@@ -0,0 +1,31 @@
// Copyright (c) 2015, Google Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
syntax = "proto3";
package google.api;
import "google/api/http.proto";
import "google/protobuf/descriptor.proto";
option go_package = "google.golang.org/genproto/googleapis/api/annotations;annotations";
option java_multiple_files = true;
option java_outer_classname = "AnnotationsProto";
option java_package = "com.google.api";
option objc_class_prefix = "GAPI";
extend google.protobuf.MethodOptions {
// See `HttpRule`.
HttpRule http = 72295728;
}
@@ -0,0 +1,51 @@
// Copyright 2019 Google LLC.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
syntax = "proto3";
package google.api;
option cc_enable_arenas = true;
option go_package = "google.golang.org/genproto/googleapis/api/annotations;annotations";
option java_multiple_files = true;
option java_outer_classname = "HttpProto";
option java_package = "com.google.api";
option objc_class_prefix = "GAPI";
message Http {
repeated HttpRule rules = 1;
bool fully_decode_reserved_expansion = 2;
}
message HttpRule {
string selector = 1;
oneof pattern {
string get = 2;
string put = 3;
string post = 4;
string delete = 5;
string patch = 6;
CustomHttpPattern custom = 8;
}
string body = 7;
string response_body = 12;
repeated HttpRule additional_bindings = 11;
}
message CustomHttpPattern {
string kind = 1;
string path = 2;
}
@@ -0,0 +1,33 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net9.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<Version>0.0.1</Version>
<DebugType>None</DebugType>
<DebugSymbols>False</DebugSymbols>
<GeneratePackageOnBuild>False</GeneratePackageOnBuild>
<PackageId>Foursat.BackOffice.BFF.DiscountProduct.Protobuf</PackageId>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Google.Protobuf" Version="3.23.3" />
<PackageReference Include="Grpc.Core.Api" Version="2.54.0" />
<PackageReference Include="Grpc.Tools" Version="2.72.0">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="FluentValidation.DependencyInjectionExtensions" Version="11.2.2" />
<PackageReference Include="Google.Api.CommonProtos" Version="2.10.0" />
</ItemGroup>
<ItemGroup>
<Protobuf Include="Protos\discountproduct.proto" ProtoRoot="Protos\" GrpcServices="Client" AdditionalImportDirs="..\BackOffice.BFF.Common.Protobuf\Protos"/>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\BackOffice.BFF.Common.Protobuf\BackOffice.BFF.Common.Protobuf.csproj" />
</ItemGroup>
</Project>
@@ -0,0 +1,152 @@
syntax = "proto3";
package discountproduct;
import "public_messages.proto";
import "google/protobuf/empty.proto";
import "google/protobuf/wrappers.proto";
import "google/protobuf/timestamp.proto";
import "google/api/annotations.proto";
option csharp_namespace = "BackOffice.BFF.DiscountProduct.Protobuf.Protos.DiscountProduct";
service DiscountProductContract
{
rpc CreateDiscountProduct(CreateDiscountProductRequest) returns (CreateDiscountProductResponse){
option (google.api.http) = {
post: "/CreateDiscountProduct"
body: "*"
};
};
rpc UpdateDiscountProduct(UpdateDiscountProductRequest) returns (google.protobuf.Empty){
option (google.api.http) = {
put: "/UpdateDiscountProduct"
body: "*"
};
};
rpc DeleteDiscountProduct(DeleteDiscountProductRequest) returns (google.protobuf.Empty){
option (google.api.http) = {
delete: "/DeleteDiscountProduct"
body: "*"
};
};
rpc GetDiscountProductById(GetDiscountProductByIdRequest) returns (GetDiscountProductByIdResponse){
option (google.api.http) = {
get: "/GetDiscountProductById"
};
};
rpc GetDiscountProducts(GetDiscountProductsRequest) returns (GetDiscountProductsResponse){
option (google.api.http) = {
get: "/GetDiscountProducts"
};
};
}
// Create Product
message CreateDiscountProductRequest
{
string title = 1;
string short_infomation = 2;
string full_information = 3;
int64 price = 4;
int32 max_discount_percent = 5;
string image_path = 6;
string thumbnail_path = 7;
int32 initial_count = 8;
int32 sort_order = 9;
bool is_active = 10;
repeated int64 category_ids = 11;
}
message CreateDiscountProductResponse
{
int64 product_id = 1;
}
// Update Product
message UpdateDiscountProductRequest
{
int64 product_id = 1;
string title = 2;
string short_infomation = 3;
string full_information = 4;
int64 price = 5;
int32 max_discount_percent = 6;
string image_path = 7;
string thumbnail_path = 8;
int32 sort_order = 9;
bool is_active = 10;
repeated int64 category_ids = 11;
}
// Delete Product
message DeleteDiscountProductRequest
{
int64 product_id = 1;
}
// Get Product By Id
message GetDiscountProductByIdRequest
{
int64 product_id = 1;
int64 user_id = 2; // Optional for view count tracking
}
message GetDiscountProductByIdResponse
{
int64 id = 1;
string title = 2;
string short_infomation = 3;
string full_information = 4;
int64 price = 5;
int32 max_discount_percent = 6;
string image_path = 7;
string thumbnail_path = 8;
int32 remaining_count = 9;
int32 view_count = 10;
int32 sort_order = 11;
bool is_active = 12;
repeated CategoryInfo categories = 13;
google.protobuf.Timestamp created = 14;
}
message CategoryInfo
{
int64 id = 1;
string name = 2;
string title = 3;
}
// Get Products with Filters
message GetDiscountProductsRequest
{
google.protobuf.Int64Value category_id = 1;
google.protobuf.StringValue search_query = 2;
google.protobuf.Int64Value min_price = 3;
google.protobuf.Int64Value max_price = 4;
google.protobuf.BoolValue is_active = 5;
google.protobuf.BoolValue in_stock = 6;
int32 page_number = 7;
int32 page_size = 8;
}
message GetDiscountProductsResponse
{
messages.MetaData meta_data = 1;
repeated DiscountProductDto models = 2;
}
message DiscountProductDto
{
int64 id = 1;
string title = 2;
string short_infomation = 3;
int64 price = 4;
int32 max_discount_percent = 5;
string image_path = 6;
string thumbnail_path = 7;
int32 remaining_count = 8;
int32 view_count = 9;
bool is_active = 10;
google.protobuf.Timestamp created = 11;
}
@@ -0,0 +1,31 @@
// Copyright (c) 2015, Google Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
syntax = "proto3";
package google.api;
import "google/api/http.proto";
import "google/protobuf/descriptor.proto";
option go_package = "google.golang.org/genproto/googleapis/api/annotations;annotations";
option java_multiple_files = true;
option java_outer_classname = "AnnotationsProto";
option java_package = "com.google.api";
option objc_class_prefix = "GAPI";
extend google.protobuf.MethodOptions {
// See `HttpRule`.
HttpRule http = 72295728;
}
@@ -0,0 +1,51 @@
// Copyright 2019 Google LLC.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
syntax = "proto3";
package google.api;
option cc_enable_arenas = true;
option go_package = "google.golang.org/genproto/googleapis/api/annotations;annotations";
option java_multiple_files = true;
option java_outer_classname = "HttpProto";
option java_package = "com.google.api";
option objc_class_prefix = "GAPI";
message Http {
repeated HttpRule rules = 1;
bool fully_decode_reserved_expansion = 2;
}
message HttpRule {
string selector = 1;
oneof pattern {
string get = 2;
string put = 3;
string post = 4;
string delete = 5;
string patch = 6;
CustomHttpPattern custom = 8;
}
string body = 7;
string response_body = 12;
repeated HttpRule additional_bindings = 11;
}
message CustomHttpPattern {
string kind = 1;
string path = 2;
}
@@ -0,0 +1,33 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net9.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<Version>0.0.1</Version>
<DebugType>None</DebugType>
<DebugSymbols>False</DebugSymbols>
<GeneratePackageOnBuild>False</GeneratePackageOnBuild>
<PackageId>Foursat.BackOffice.BFF.DiscountShoppingCart.Protobuf</PackageId>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Google.Protobuf" Version="3.23.3" />
<PackageReference Include="Grpc.Core.Api" Version="2.54.0" />
<PackageReference Include="Grpc.Tools" Version="2.72.0">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="FluentValidation.DependencyInjectionExtensions" Version="11.2.2" />
<PackageReference Include="Google.Api.CommonProtos" Version="2.10.0" />
</ItemGroup>
<ItemGroup>
<Protobuf Include="Protos\discountshoppingcart.proto" ProtoRoot="Protos\" GrpcServices="Client" AdditionalImportDirs="..\BackOffice.BFF.Common.Protobuf\Protos"/>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\BackOffice.BFF.Common.Protobuf\BackOffice.BFF.Common.Protobuf.csproj" />
</ItemGroup>
</Project>
@@ -0,0 +1,120 @@
syntax = "proto3";
package discountshoppingcart;
import "public_messages.proto";
import "google/protobuf/empty.proto";
import "google/protobuf/wrappers.proto";
import "google/protobuf/timestamp.proto";
import "google/api/annotations.proto";
option csharp_namespace = "BackOffice.BFF.DiscountShoppingCart.Protobuf.Protos.DiscountShoppingCart";
service DiscountShoppingCartContract
{
rpc AddToCart(AddToCartRequest) returns (AddToCartResponse){
option (google.api.http) = {
post: "/AddToCart"
body: "*"
};
};
rpc RemoveFromCart(RemoveFromCartRequest) returns (RemoveFromCartResponse){
option (google.api.http) = {
delete: "/RemoveFromCart"
body: "*"
};
};
rpc UpdateCartItemCount(UpdateCartItemCountRequest) returns (UpdateCartItemCountResponse){
option (google.api.http) = {
put: "/UpdateCartItemCount"
body: "*"
};
};
rpc GetUserCart(GetUserCartRequest) returns (GetUserCartResponse){
option (google.api.http) = {
get: "/GetUserCart"
};
};
rpc ClearCart(ClearCartRequest) returns (google.protobuf.Empty){
option (google.api.http) = {
delete: "/ClearCart"
body: "*"
};
};
}
// Add to Cart
message AddToCartRequest
{
int64 user_id = 1;
int64 product_id = 2;
int32 count = 3;
}
message AddToCartResponse
{
bool success = 1;
string message = 2;
}
// Remove from Cart
message RemoveFromCartRequest
{
int64 user_id = 1;
int64 product_id = 2;
}
message RemoveFromCartResponse
{
bool success = 1;
string message = 2;
}
// Update Cart Item Count
message UpdateCartItemCountRequest
{
int64 user_id = 1;
int64 product_id = 2;
int32 new_count = 3;
}
message UpdateCartItemCountResponse
{
bool success = 1;
string message = 2;
}
// Get User Cart
message GetUserCartRequest
{
int64 user_id = 1;
}
message GetUserCartResponse
{
repeated CartItemDto items = 1;
int64 total_price = 2;
int64 total_discount_amount = 3;
int64 final_price = 4;
}
message CartItemDto
{
int64 product_id = 1;
string product_title = 2;
string product_image_path = 3;
int64 unit_price = 4;
int32 max_discount_percent = 5;
int32 count = 6;
int64 total_price = 7;
int64 discount_amount = 8;
int64 final_price = 9;
int32 product_remaining_count = 10;
google.protobuf.Timestamp created = 11;
}
// Clear Cart
message ClearCartRequest
{
int64 user_id = 1;
}
@@ -0,0 +1,31 @@
// Copyright (c) 2015, Google Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
syntax = "proto3";
package google.api;
import "google/api/http.proto";
import "google/protobuf/descriptor.proto";
option go_package = "google.golang.org/genproto/googleapis/api/annotations;annotations";
option java_multiple_files = true;
option java_outer_classname = "AnnotationsProto";
option java_package = "com.google.api";
option objc_class_prefix = "GAPI";
extend google.protobuf.MethodOptions {
// See `HttpRule`.
HttpRule http = 72295728;
}
@@ -0,0 +1,51 @@
// Copyright 2019 Google LLC.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
syntax = "proto3";
package google.api;
option cc_enable_arenas = true;
option go_package = "google.golang.org/genproto/googleapis/api/annotations;annotations";
option java_multiple_files = true;
option java_outer_classname = "HttpProto";
option java_package = "com.google.api";
option objc_class_prefix = "GAPI";
message Http {
repeated HttpRule rules = 1;
bool fully_decode_reserved_expansion = 2;
}
message HttpRule {
string selector = 1;
oneof pattern {
string get = 2;
string put = 3;
string post = 4;
string delete = 5;
string patch = 6;
CustomHttpPattern custom = 8;
}
string body = 7;
string response_body = 12;
repeated HttpRule additional_bindings = 11;
}
message CustomHttpPattern {
string kind = 1;
string path = 2;
}
@@ -0,0 +1,33 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net9.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<Version>0.0.1</Version>
<DebugType>None</DebugType>
<DebugSymbols>False</DebugSymbols>
<GeneratePackageOnBuild>False</GeneratePackageOnBuild>
<PackageId>Foursat.BackOffice.BFF.ProductTag.Protobuf</PackageId>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Google.Protobuf" Version="3.23.3" />
<PackageReference Include="Grpc.Core.Api" Version="2.54.0" />
<PackageReference Include="Grpc.Tools" Version="2.72.0">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="FluentValidation.DependencyInjectionExtensions" Version="11.2.2" />
<PackageReference Include="Google.Api.CommonProtos" Version="2.10.0" />
</ItemGroup>
<ItemGroup>
<Protobuf Include="Protos\producttag.proto" ProtoRoot="Protos\" GrpcServices="Client" AdditionalImportDirs="..\BackOffice.BFF.Common.Protobuf\Protos"/>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\BackOffice.BFF.Common.Protobuf\BackOffice.BFF.Common.Protobuf.csproj" />
</ItemGroup>
</Project>
@@ -0,0 +1,31 @@
// Copyright (c) 2015, Google Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
syntax = "proto3";
package google.api;
import "google/api/http.proto";
import "google/protobuf/descriptor.proto";
option go_package = "google.golang.org/genproto/googleapis/api/annotations;annotations";
option java_multiple_files = true;
option java_outer_classname = "AnnotationsProto";
option java_package = "com.google.api";
option objc_class_prefix = "GAPI";
extend google.protobuf.MethodOptions {
// See `HttpRule`.
HttpRule http = 72295728;
}
@@ -0,0 +1,51 @@
// Copyright 2019 Google LLC.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
syntax = "proto3";
package google.api;
option cc_enable_arenas = true;
option go_package = "google.golang.org/genproto/googleapis/api/annotations;annotations";
option java_multiple_files = true;
option java_outer_classname = "HttpProto";
option java_package = "com.google.api";
option objc_class_prefix = "GAPI";
message Http {
repeated HttpRule rules = 1;
bool fully_decode_reserved_expansion = 2;
}
message HttpRule {
string selector = 1;
oneof pattern {
string get = 2;
string put = 3;
string post = 4;
string delete = 5;
string patch = 6;
CustomHttpPattern custom = 8;
}
string body = 7;
string response_body = 12;
repeated HttpRule additional_bindings = 11;
}
message CustomHttpPattern {
string kind = 1;
string path = 2;
}
@@ -0,0 +1,108 @@
syntax = "proto3";
package producttag;
import "public_messages.proto";
import "google/protobuf/empty.proto";
import "google/protobuf/wrappers.proto";
import "google/protobuf/duration.proto";
import "google/protobuf/timestamp.proto";
import "google/api/annotations.proto";
option csharp_namespace = "BackOffice.BFF.ProductTag.Protobuf.Protos.ProductTag";
service ProductTagContract
{
rpc CreateNewProductTag(CreateNewProductTagRequest) returns (CreateNewProductTagResponse){
option (google.api.http) = {
post: "/CreateNewProductTag"
body: "*"
};
};
rpc UpdateProductTag(UpdateProductTagRequest) returns (google.protobuf.Empty){
option (google.api.http) = {
put: "/UpdateProductTag"
body: "*"
};
};
rpc DeleteProductTag(DeleteProductTagRequest) returns (google.protobuf.Empty){
option (google.api.http) = {
delete: "/DeleteProductTag"
body: "*"
};
};
rpc GetProductTag(GetProductTagRequest) returns (GetProductTagResponse){
option (google.api.http) = {
get: "/GetProductTag"
};
};
rpc GetAllProductTagByFilter(GetAllProductTagByFilterRequest) returns (GetAllProductTagByFilterResponse){
option (google.api.http) = {
get: "/GetAllProductTagByFilter"
};
};
}
message CreateNewProductTagRequest
{
int64 product_id = 1;
int64 tag_id = 2;
}
message CreateNewProductTagResponse
{
int64 id = 1;
}
message UpdateProductTagRequest
{
int64 id = 1;
int64 product_id = 2;
int64 tag_id = 3;
}
message DeleteProductTagRequest
{
int64 id = 1;
}
message GetProductTagRequest
{
int64 id = 1;
}
message GetProductTagResponse
{
int64 id = 1;
int64 product_id = 2;
int64 tag_id = 3;
}
message GetAllProductTagByFilterRequest
{
messages.PaginationState pagination_state = 1;
google.protobuf.StringValue sort_by = 2;
GetAllProductTagByFilterFilter filter = 3;
}
message GetAllProductTagByFilterFilter
{
google.protobuf.Int64Value id = 1;
google.protobuf.Int64Value product_id = 2;
google.protobuf.Int64Value tag_id = 3;
}
message GetAllProductTagByFilterResponse
{
messages.MetaData meta_data = 1;
repeated GetAllProductTagByFilterResponseModel models = 2;
}
message GetAllProductTagByFilterResponseModel
{
int64 id = 1;
int64 product_id = 2;
int64 tag_id = 3;
}
@@ -9,7 +9,7 @@ import "google/protobuf/duration.proto";
import "google/protobuf/timestamp.proto";
import "google/api/annotations.proto";
option csharp_namespace = "CMSMicroservice.Protobuf.Protos.Products";
option csharp_namespace = "BackOffice.BFF.Products.Protobuf.Protos.Products";
service ProductsContract
{
@@ -66,6 +66,46 @@ service ProductsContract
body: "*"
};
};
rpc GetProductsForCategory(GetProductsForCategoryRequest) returns (GetProductsForCategoryResponse){
option (google.api.http) = {
get: "/GetProductsForCategory"
};
};
rpc GetCategories(GetCategoriesRequest) returns (GetCategoriesResponse){
option (google.api.http) = {
get: "/GetCategories"
};
};
rpc UpdateProductCategories(UpdateProductCategoriesRequest) returns (google.protobuf.Empty){
option (google.api.http) = {
post: "/UpdateProductCategories"
body: "*"
};
};
rpc UpdateCategoryProducts(UpdateCategoryProductsRequest) returns (google.protobuf.Empty){
option (google.api.http) = {
post: "/UpdateCategoryProducts"
body: "*"
};
};
// Product Gallery / Image Management
rpc GetProductGallery(GetProductGalleryRequest) returns (GetProductGalleryResponse){
option (google.api.http) = {
get: "/GetProductGallery"
};
};
rpc AddProductImage(AddProductImageRequest) returns (AddProductImageResponse){
option (google.api.http) = {
post: "/AddProductImage"
body: "*"
};
};
rpc RemoveProductImage(RemoveProductImageRequest) returns (google.protobuf.Empty){
option (google.api.http) = {
delete: "/RemoveProductImage"
};
};
}
message CreateNewProductsRequest
{
@@ -274,3 +314,106 @@ message ToggleProductStatusResponse
int32 failed = 3;
repeated BulkOperationError errors = 4;
}
// Category Product Item (for drag-drop UI)
message CategoryProductItem
{
int64 id = 1;
string title = 2;
bool selected = 3;
}
// Get Products for Category
message GetProductsForCategoryRequest
{
int64 category_id = 1;
}
message GetProductsForCategoryResponse
{
repeated CategoryProductItem items = 1;
}
// Category Item (for product categories drag-drop)
message CategoryItem
{
int64 id = 1;
string title = 2;
bool selected = 3;
}
// Get Categories for Product
message GetCategoriesRequest
{
int64 product_id = 1;
}
message GetCategoriesResponse
{
repeated CategoryItem items = 1;
}
// Update Product Categories
message UpdateProductCategoriesRequest
{
int64 product_id = 1;
repeated int64 category_ids = 2;
}
// Update Category Products
message UpdateCategoryProductsRequest
{
int64 category_id = 1;
repeated int64 product_ids = 2;
}
// Image File Model
message ImageFileModel
{
bytes file = 1;
string mime = 2;
string file_name = 3;
}
// Get Product Gallery
message GetProductGalleryRequest
{
int64 product_id = 1;
}
message ProductGalleryItem
{
int64 product_gallery_id = 1;
int64 product_image_id = 2;
string title = 3;
string image_path = 4;
string image_thumbnail_path = 5;
}
message GetProductGalleryResponse
{
repeated ProductGalleryItem items = 1;
}
// Add Product Image
message AddProductImageRequest
{
int64 product_id = 1;
string title = 2;
ImageFileModel image_file = 3;
}
message AddProductImageResponse
{
int64 product_gallery_id = 1;
int64 product_image_id = 2;
string title = 3;
string image_path = 4;
string image_thumbnail_path = 5;
}
// Remove Product Image
message RemoveProductImageRequest
{
int64 product_gallery_id = 1;
}
@@ -0,0 +1,70 @@
syntax = "proto3";
package messages;
option csharp_namespace = "BackOffice.BFF.Products.Protobuf.Protos";
service PublicMessageContract{}
message PaginationState
{
int32 page_number = 1;
int32 page_size = 2;
}
message MetaData
{
int64 current_page = 1;
int64 total_page = 2;
int64 page_size = 3;
int64 total_count = 4;
bool has_previous = 5;
bool has_next = 6;
}
message DecimalValue
{
int64 units = 1;
sfixed32 nanos = 2;
}
enum PaymentStatus
{
Success = 0;
Reject = 1;
Pending = 2;
}
// وضعیت ارسال سفارش
enum DeliveryStatus
{
// نامشخص / نیاز به ارسال ندارد (مثلا سفارش پکیج)
DeliveryStatus_None = 0;
// ثبت شده و در انتظار آماده‌سازی/ارسال
DeliveryStatus_Pending = 1;
// تحویل پست/حمل‌ونقل شده است
DeliveryStatus_InTransit = 2;
// توسط مشتری دریافت شده است
DeliveryStatus_Delivered = 3;
// مرجوع شده
DeliveryStatus_Returned = 4;
}
enum TransactionType
{
Buy = 0;
DepositIpg = 1;
DepositExternal1 = 2;
Withdraw = 3;
}
enum ContractType
{
Main = 0;
CMS = 1;
}
enum PaymentMethod
{
IPG = 0;
Wallet = 1;
}
@@ -10,8 +10,8 @@ package publicmessages;
service PublicMessageContract
{
rpc CreatePublicMessage(CreatePublicMessageRequest) returns (CreatePublicMessageResponse);
rpc UpdatePublicMessage(UpdatePublicMessageRequest) returns (UpdatePublicMessageRequest);
rpc DeletePublicMessage(DeletePublicMessageRequest) returns (DeletePublicMessageRequest);
rpc UpdatePublicMessage(UpdatePublicMessageRequest) returns (UpdatePublicMessageResponse);
rpc DeletePublicMessage(DeletePublicMessageRequest) returns (DeletePublicMessageResponse);
rpc PublishMessage(PublishMessageRequest) returns (PublishMessageResponse);
rpc ArchiveMessage(ArchiveMessageRequest) returns (ArchiveMessageResponse);
rpc GetAllMessages(GetAllMessagesRequest) returns (GetAllMessagesResponse);
@@ -55,12 +55,24 @@ message UpdatePublicMessageRequest
repeated string tags = 10;
}
message UpdatePublicMessageResponse
{
bool success = 1;
string message = 2;
}
// Delete Public Message
message DeletePublicMessageRequest
{
int64 message_id = 1;
}
message DeletePublicMessageResponse
{
bool success = 1;
string message = 2;
}
// Publish Message
message PublishMessageRequest
{
@@ -0,0 +1,33 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net9.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<Version>0.0.1</Version>
<DebugType>None</DebugType>
<DebugSymbols>False</DebugSymbols>
<GeneratePackageOnBuild>False</GeneratePackageOnBuild>
<PackageId>Foursat.BackOffice.BFF.Tag.Protobuf</PackageId>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Google.Protobuf" Version="3.23.3" />
<PackageReference Include="Grpc.Core.Api" Version="2.54.0" />
<PackageReference Include="Grpc.Tools" Version="2.72.0">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="FluentValidation.DependencyInjectionExtensions" Version="11.2.2" />
<PackageReference Include="Google.Api.CommonProtos" Version="2.10.0" />
</ItemGroup>
<ItemGroup>
<Protobuf Include="Protos\tag.proto" ProtoRoot="Protos\" GrpcServices="Client" AdditionalImportDirs="..\BackOffice.BFF.Common.Protobuf\Protos"/>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\BackOffice.BFF.Common.Protobuf\BackOffice.BFF.Common.Protobuf.csproj" />
</ItemGroup>
</Project>
@@ -0,0 +1,31 @@
// Copyright (c) 2015, Google Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
syntax = "proto3";
package google.api;
import "google/api/http.proto";
import "google/protobuf/descriptor.proto";
option go_package = "google.golang.org/genproto/googleapis/api/annotations;annotations";
option java_multiple_files = true;
option java_outer_classname = "AnnotationsProto";
option java_package = "com.google.api";
option objc_class_prefix = "GAPI";
extend google.protobuf.MethodOptions {
// See `HttpRule`.
HttpRule http = 72295728;
}
@@ -0,0 +1,51 @@
// Copyright 2019 Google LLC.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
syntax = "proto3";
package google.api;
option cc_enable_arenas = true;
option go_package = "google.golang.org/genproto/googleapis/api/annotations;annotations";
option java_multiple_files = true;
option java_outer_classname = "HttpProto";
option java_package = "com.google.api";
option objc_class_prefix = "GAPI";
message Http {
repeated HttpRule rules = 1;
bool fully_decode_reserved_expansion = 2;
}
message HttpRule {
string selector = 1;
oneof pattern {
string get = 2;
string put = 3;
string post = 4;
string delete = 5;
string patch = 6;
CustomHttpPattern custom = 8;
}
string body = 7;
string response_body = 12;
repeated HttpRule additional_bindings = 11;
}
message CustomHttpPattern {
string kind = 1;
string path = 2;
}
@@ -0,0 +1,139 @@
syntax = "proto3";
package tag;
import "google/protobuf/empty.proto";
import "google/protobuf/wrappers.proto";
import "google/protobuf/timestamp.proto";
option csharp_namespace = "BackOffice.BFF.Tag.Protobuf.Protos.Tag";
service TagContract
{
rpc CreateNewTag(CreateNewTagRequest) returns (CreateNewTagResponse);
rpc UpdateTag(UpdateTagRequest) returns (google.protobuf.Empty);
rpc DeleteTag(DeleteTagRequest) returns (google.protobuf.Empty);
rpc GetTag(GetTagRequest) returns (GetTagResponse);
rpc GetAllTagByFilter(GetAllTagByFilterRequest) returns (GetAllTagByFilterResponse);
rpc GetProductsByTag(GetProductsByTagRequest) returns (GetProductsByTagResponse);
}
// Create Tag
message CreateNewTagRequest
{
string name = 1;
string title = 2;
string description = 3;
bool is_active = 4;
int32 sort_order = 5;
}
message CreateNewTagResponse
{
int64 id = 1;
}
// Update Tag
message UpdateTagRequest
{
int64 id = 1;
string name = 2;
string title = 3;
string description = 4;
bool is_active = 5;
int32 sort_order = 6;
}
// Delete Tag
message DeleteTagRequest
{
int64 id = 1;
}
// Get Tag
message GetTagRequest
{
int64 id = 1;
}
message GetTagResponse
{
int64 id = 1;
string name = 2;
string title = 3;
string description = 4;
bool is_active = 5;
int32 sort_order = 6;
}
// Get All Tags
message GetAllTagByFilterRequest
{
PaginationState pagination_state = 1;
string sort_by = 2;
GetAllTagByFilterFilter filter = 3;
}
message GetAllTagByFilterFilter
{
int64 id = 1;
string name = 2;
string title = 3;
string description = 4;
bool is_active = 5;
int32 sort_order = 6;
}
message GetAllTagByFilterResponse
{
MetaData meta_data = 1;
repeated TagModel models = 2;
}
message TagModel
{
int64 id = 1;
string name = 2;
string title = 3;
string description = 4;
bool is_active = 5;
int32 sort_order = 6;
}
// Get Products By Tag
message GetProductsByTagRequest
{
int64 tag_id = 1;
}
message GetProductsByTagResponse
{
repeated ProductSimpleModel products = 1;
}
message ProductSimpleModel
{
int64 id = 1;
string title = 2;
int64 price = 3;
int32 inventory = 4;
bool is_active = 5;
string image_path = 6;
}
// Common
message PaginationState
{
int32 page_number = 1;
int32 page_size = 2;
}
message MetaData
{
int32 current_page = 1;
int32 total_page = 2;
int32 page_size = 3;
int64 total_count = 4;
bool has_previous = 5;
bool has_next = 6;
}