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