feat: Add discount module with protobuf definitions and gRPC services
This commit is contained in:
+33
@@ -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;
|
||||
}
|
||||
+31
@@ -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;
|
||||
}
|
||||
Reference in New Issue
Block a user