Add validators and services for Product Galleries and Product Tags

- Implemented Create, Delete, Get, and Update validators for Product Galleries.
- Added Create, Delete, Get, and Update validators for Product Tags.
- Created service classes for handling Discount Categories, Discount Orders, Discount Products, Discount Shopping Cart, Product Categories, Product Galleries, and Product Tags.
- Each service class integrates with CQRS for command and query handling.
- Established mapping profiles for Product Galleries.
This commit is contained in:
masoodafar-web
2025-12-04 02:40:49 +03:30
parent 40d54d08fc
commit f0f48118e7
436 changed files with 33159 additions and 2005 deletions

View File

@@ -31,7 +31,7 @@
<Protobuf Include="Protos\userwallet.proto" ProtoRoot="Protos\" GrpcServices="Both" />
<Protobuf Include="Protos\userwalletchangelog.proto" ProtoRoot="Protos\" GrpcServices="Both" />
<Protobuf Include="Protos\usercarts.proto" ProtoRoot="Protos\" GrpcServices="Both" />
<Protobuf Include="Protos\productgallerys.proto" ProtoRoot="Protos\" GrpcServices="Both" />
<Protobuf Include="Protos\productgalleries.proto" ProtoRoot="Protos\" GrpcServices="Both" />
<Protobuf Include="Protos\factordetails.proto" ProtoRoot="Protos\" GrpcServices="Both" />
<Protobuf Include="Protos\products.proto" ProtoRoot="Protos\" GrpcServices="Both" />
<Protobuf Include="Protos\productimages.proto" ProtoRoot="Protos\" GrpcServices="Both" />
@@ -39,15 +39,20 @@
<!-- Added missing proto definitions so validators compile -->
<Protobuf Include="Protos\contract.proto" ProtoRoot="Protos\" GrpcServices="Both" />
<Protobuf Include="Protos\usercontract.proto" ProtoRoot="Protos\" GrpcServices="Both" />
<Protobuf Include="Protos\pruductcategory.proto" ProtoRoot="Protos\" GrpcServices="Both" />
<Protobuf Include="Protos\productcategory.proto" ProtoRoot="Protos\" GrpcServices="Both" />
<Protobuf Include="Protos\category.proto" ProtoRoot="Protos\" GrpcServices="Both" />
<Protobuf Include="Protos\tag.proto" ProtoRoot="Protos\" GrpcServices="Both" />
<Protobuf Include="Protos\pruducttag.proto" ProtoRoot="Protos\" GrpcServices="Both" />
<Protobuf Include="Protos\producttag.proto" ProtoRoot="Protos\" GrpcServices="Both" />
<!-- Network Club Commission System - Phase 6 -->
<Protobuf Include="Protos\configuration.proto" ProtoRoot="Protos\" GrpcServices="Both" />
<Protobuf Include="Protos\clubmembership.proto" ProtoRoot="Protos\" GrpcServices="Both" />
<Protobuf Include="Protos\networkmembership.proto" ProtoRoot="Protos\" GrpcServices="Both" />
<Protobuf Include="Protos\commission.proto" ProtoRoot="Protos\" GrpcServices="Both" />
<!-- Club Discount Shop System - Phase 9 -->
<Protobuf Include="Protos\discountproduct.proto" ProtoRoot="Protos\" GrpcServices="Both" />
<Protobuf Include="Protos\discountcategory.proto" ProtoRoot="Protos\" GrpcServices="Both" />
<Protobuf Include="Protos\discountshoppingcart.proto" ProtoRoot="Protos\" GrpcServices="Both" />
<Protobuf Include="Protos\discountorder.proto" ProtoRoot="Protos\" GrpcServices="Both" />
</ItemGroup>
<Target Name="PushToFoursatNuget" AfterTargets="Pack">

View File

@@ -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 = "CMSMicroservice.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
}

View File

@@ -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 = "CMSMicroservice.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;
}

View File

@@ -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 = "CMSMicroservice.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;
}

View File

@@ -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 = "CMSMicroservice.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;
}

View File

@@ -1,6 +1,6 @@
syntax = "proto3";
package pruductcategory;
package productcategory;
import "public_messages.proto";
import "google/protobuf/empty.proto";
@@ -9,88 +9,88 @@ import "google/protobuf/duration.proto";
import "google/protobuf/timestamp.proto";
import "google/api/annotations.proto";
option csharp_namespace = "CMSMicroservice.Protobuf.Protos.PruductCategory";
option csharp_namespace = "CMSMicroservice.Protobuf.Protos.ProductCategory";
service PruductCategoryContract
service ProductCategoryContract
{
rpc CreateNewPruductCategory(CreateNewPruductCategoryRequest) returns (CreateNewPruductCategoryResponse){
rpc CreateNewProductCategory(CreateNewProductCategoryRequest) returns (CreateNewProductCategoryResponse){
option (google.api.http) = {
post: "/CreateNewPruductCategory"
post: "/CreateNewProductCategory"
body: "*"
};
};
rpc UpdatePruductCategory(UpdatePruductCategoryRequest) returns (google.protobuf.Empty){
rpc UpdateProductCategory(UpdateProductCategoryRequest) returns (google.protobuf.Empty){
option (google.api.http) = {
put: "/UpdatePruductCategory"
put: "/UpdateProductCategory"
body: "*"
};
};
rpc DeletePruductCategory(DeletePruductCategoryRequest) returns (google.protobuf.Empty){
rpc DeleteProductCategory(DeleteProductCategoryRequest) returns (google.protobuf.Empty){
option (google.api.http) = {
delete: "/DeletePruductCategory"
delete: "/DeleteProductCategory"
body: "*"
};
};
rpc GetPruductCategory(GetPruductCategoryRequest) returns (GetPruductCategoryResponse){
rpc GetProductCategory(GetProductCategoryRequest) returns (GetProductCategoryResponse){
option (google.api.http) = {
get: "/GetPruductCategory"
get: "/GetProductCategory"
};
};
rpc GetAllPruductCategoryByFilter(GetAllPruductCategoryByFilterRequest) returns (GetAllPruductCategoryByFilterResponse){
rpc GetAllProductCategoryByFilter(GetAllProductCategoryByFilterRequest) returns (GetAllProductCategoryByFilterResponse){
option (google.api.http) = {
get: "/GetAllPruductCategoryByFilter"
get: "/GetAllProductCategoryByFilter"
};
};
}
message CreateNewPruductCategoryRequest
message CreateNewProductCategoryRequest
{
int64 product_id = 1;
int64 category_id = 2;
}
message CreateNewPruductCategoryResponse
message CreateNewProductCategoryResponse
{
int64 id = 1;
}
message UpdatePruductCategoryRequest
message UpdateProductCategoryRequest
{
int64 id = 1;
int64 product_id = 2;
int64 category_id = 3;
}
message DeletePruductCategoryRequest
message DeleteProductCategoryRequest
{
int64 id = 1;
}
message GetPruductCategoryRequest
message GetProductCategoryRequest
{
int64 id = 1;
}
message GetPruductCategoryResponse
message GetProductCategoryResponse
{
int64 id = 1;
int64 product_id = 2;
int64 category_id = 3;
}
message GetAllPruductCategoryByFilterRequest
message GetAllProductCategoryByFilterRequest
{
messages.PaginationState pagination_state = 1;
google.protobuf.StringValue sort_by = 2;
GetAllPruductCategoryByFilterFilter filter = 3;
GetAllProductCategoryByFilterFilter filter = 3;
}
message GetAllPruductCategoryByFilterFilter
message GetAllProductCategoryByFilterFilter
{
google.protobuf.Int64Value id = 1;
google.protobuf.Int64Value product_id = 2;
google.protobuf.Int64Value category_id = 3;
}
message GetAllPruductCategoryByFilterResponse
message GetAllProductCategoryByFilterResponse
{
messages.MetaData meta_data = 1;
repeated GetAllPruductCategoryByFilterResponseModel models = 2;
repeated GetAllProductCategoryByFilterResponseModel models = 2;
}
message GetAllPruductCategoryByFilterResponseModel
message GetAllProductCategoryByFilterResponseModel
{
int64 id = 1;
int64 product_id = 2;

View File

@@ -0,0 +1,98 @@
syntax = "proto3";
package productgalleries;
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 = "CMSMicroservice.Protobuf.Protos.ProductGalleries";
service ProductGalleriesContract
{
rpc CreateNewProductGalleries(CreateNewProductGalleriesRequest) returns (CreateNewProductGalleriesResponse){
option (google.api.http) = {
post: "/CreateNewProductGalleries"
body: "*"
};
};
rpc UpdateProductGalleries(UpdateProductGalleriesRequest) returns (google.protobuf.Empty){
option (google.api.http) = {
put: "/UpdateProductGalleries"
body: "*"
};
};
rpc DeleteProductGalleries(DeleteProductGalleriesRequest) returns (google.protobuf.Empty){
option (google.api.http) = {
delete: "/DeleteProductGalleries"
body: "*"
};
};
rpc GetProductGalleries(GetProductGalleriesRequest) returns (GetProductGalleriesResponse){
option (google.api.http) = {
get: "/GetProductGalleries"
};
};
rpc GetAllProductGalleriesByFilter(GetAllProductGalleriesByFilterRequest) returns (GetAllProductGalleriesByFilterResponse){
option (google.api.http) = {
get: "/GetAllProductGalleriesByFilter"
};
};
}
message CreateNewProductGalleriesRequest
{
int64 product_image_id = 1;
int64 product_id = 2;
}
message CreateNewProductGalleriesResponse
{
int64 id = 1;
}
message UpdateProductGalleriesRequest
{
int64 id = 1;
int64 product_image_id = 2;
int64 product_id = 3;
}
message DeleteProductGalleriesRequest
{
int64 id = 1;
}
message GetProductGalleriesRequest
{
int64 id = 1;
}
message GetProductGalleriesResponse
{
int64 id = 1;
int64 product_image_id = 2;
int64 product_id = 3;
}
message GetAllProductGalleriesByFilterRequest
{
messages.PaginationState pagination_state = 1;
google.protobuf.StringValue sort_by = 2;
GetAllProductGalleriesByFilterFilter filter = 3;
}
message GetAllProductGalleriesByFilterFilter
{
google.protobuf.Int64Value id = 1;
google.protobuf.Int64Value product_image_id = 2;
google.protobuf.Int64Value product_id = 3;
}
message GetAllProductGalleriesByFilterResponse
{
messages.MetaData meta_data = 1;
repeated GetAllProductGalleriesByFilterResponseModel models = 2;
}
message GetAllProductGalleriesByFilterResponseModel
{
int64 id = 1;
int64 product_image_id = 2;
int64 product_id = 3;
}

View File

@@ -1,98 +0,0 @@
syntax = "proto3";
package productgallerys;
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 = "CMSMicroservice.Protobuf.Protos.ProductGallerys";
service ProductGallerysContract
{
rpc CreateNewProductGallerys(CreateNewProductGallerysRequest) returns (CreateNewProductGallerysResponse){
option (google.api.http) = {
post: "/CreateNewProductGallerys"
body: "*"
};
};
rpc UpdateProductGallerys(UpdateProductGallerysRequest) returns (google.protobuf.Empty){
option (google.api.http) = {
put: "/UpdateProductGallerys"
body: "*"
};
};
rpc DeleteProductGallerys(DeleteProductGallerysRequest) returns (google.protobuf.Empty){
option (google.api.http) = {
delete: "/DeleteProductGallerys"
body: "*"
};
};
rpc GetProductGallerys(GetProductGallerysRequest) returns (GetProductGallerysResponse){
option (google.api.http) = {
get: "/GetProductGallerys"
};
};
rpc GetAllProductGallerysByFilter(GetAllProductGallerysByFilterRequest) returns (GetAllProductGallerysByFilterResponse){
option (google.api.http) = {
get: "/GetAllProductGallerysByFilter"
};
};
}
message CreateNewProductGallerysRequest
{
int64 product_image_id = 1;
int64 product_id = 2;
}
message CreateNewProductGallerysResponse
{
int64 id = 1;
}
message UpdateProductGallerysRequest
{
int64 id = 1;
int64 product_image_id = 2;
int64 product_id = 3;
}
message DeleteProductGallerysRequest
{
int64 id = 1;
}
message GetProductGallerysRequest
{
int64 id = 1;
}
message GetProductGallerysResponse
{
int64 id = 1;
int64 product_image_id = 2;
int64 product_id = 3;
}
message GetAllProductGallerysByFilterRequest
{
messages.PaginationState pagination_state = 1;
google.protobuf.StringValue sort_by = 2;
GetAllProductGallerysByFilterFilter filter = 3;
}
message GetAllProductGallerysByFilterFilter
{
google.protobuf.Int64Value id = 1;
google.protobuf.Int64Value product_image_id = 2;
google.protobuf.Int64Value product_id = 3;
}
message GetAllProductGallerysByFilterResponse
{
messages.MetaData meta_data = 1;
repeated GetAllProductGallerysByFilterResponseModel models = 2;
}
message GetAllProductGallerysByFilterResponseModel
{
int64 id = 1;
int64 product_image_id = 2;
int64 product_id = 3;
}

View File

@@ -1,6 +1,6 @@
syntax = "proto3";
package pruducttag;
package producttag;
import "public_messages.proto";
import "google/protobuf/empty.proto";
@@ -9,88 +9,88 @@ import "google/protobuf/duration.proto";
import "google/protobuf/timestamp.proto";
import "google/api/annotations.proto";
option csharp_namespace = "CMSMicroservice.Protobuf.Protos.PruductTag";
option csharp_namespace = "CMSMicroservice.Protobuf.Protos.ProductTag";
service PruductTagContract
service ProductTagContract
{
rpc CreateNewPruductTag(CreateNewPruductTagRequest) returns (CreateNewPruductTagResponse){
rpc CreateNewProductTag(CreateNewProductTagRequest) returns (CreateNewProductTagResponse){
option (google.api.http) = {
post: "/CreateNewPruductTag"
post: "/CreateNewProductTag"
body: "*"
};
};
rpc UpdatePruductTag(UpdatePruductTagRequest) returns (google.protobuf.Empty){
rpc UpdateProductTag(UpdateProductTagRequest) returns (google.protobuf.Empty){
option (google.api.http) = {
put: "/UpdatePruductTag"
put: "/UpdateProductTag"
body: "*"
};
};
rpc DeletePruductTag(DeletePruductTagRequest) returns (google.protobuf.Empty){
rpc DeleteProductTag(DeleteProductTagRequest) returns (google.protobuf.Empty){
option (google.api.http) = {
delete: "/DeletePruductTag"
delete: "/DeleteProductTag"
body: "*"
};
};
rpc GetPruductTag(GetPruductTagRequest) returns (GetPruductTagResponse){
rpc GetProductTag(GetProductTagRequest) returns (GetProductTagResponse){
option (google.api.http) = {
get: "/GetPruductTag"
get: "/GetProductTag"
};
};
rpc GetAllPruductTagByFilter(GetAllPruductTagByFilterRequest) returns (GetAllPruductTagByFilterResponse){
rpc GetAllProductTagByFilter(GetAllProductTagByFilterRequest) returns (GetAllProductTagByFilterResponse){
option (google.api.http) = {
get: "/GetAllPruductTagByFilter"
get: "/GetAllProductTagByFilter"
};
};
}
message CreateNewPruductTagRequest
message CreateNewProductTagRequest
{
int64 product_id = 1;
int64 tag_id = 2;
}
message CreateNewPruductTagResponse
message CreateNewProductTagResponse
{
int64 id = 1;
}
message UpdatePruductTagRequest
message UpdateProductTagRequest
{
int64 id = 1;
int64 product_id = 2;
int64 tag_id = 3;
}
message DeletePruductTagRequest
message DeleteProductTagRequest
{
int64 id = 1;
}
message GetPruductTagRequest
message GetProductTagRequest
{
int64 id = 1;
}
message GetPruductTagResponse
message GetProductTagResponse
{
int64 id = 1;
int64 product_id = 2;
int64 tag_id = 3;
}
message GetAllPruductTagByFilterRequest
message GetAllProductTagByFilterRequest
{
messages.PaginationState pagination_state = 1;
google.protobuf.StringValue sort_by = 2;
GetAllPruductTagByFilterFilter filter = 3;
GetAllProductTagByFilterFilter filter = 3;
}
message GetAllPruductTagByFilterFilter
message GetAllProductTagByFilterFilter
{
google.protobuf.Int64Value id = 1;
google.protobuf.Int64Value product_id = 2;
google.protobuf.Int64Value tag_id = 3;
}
message GetAllPruductTagByFilterResponse
message GetAllProductTagByFilterResponse
{
messages.MetaData meta_data = 1;
repeated GetAllPruductTagByFilterResponseModel models = 2;
repeated GetAllProductTagByFilterResponseModel models = 2;
}
message GetAllPruductTagByFilterResponseModel
message GetAllProductTagByFilterResponseModel
{
int64 id = 1;
int64 product_id = 2;

View File

@@ -43,6 +43,11 @@ service TagContract
};
};
rpc GetProductsByTag(GetProductsByTagRequest) returns (GetProductsByTagResponse){
option (google.api.http) = {
get: "/GetProductsByTag"
};
};
}
message CreateNewTagRequest
{
@@ -111,3 +116,20 @@ message GetAllTagByFilterResponseModel
bool is_active = 5;
int32 sort_order = 6;
}
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;
google.protobuf.StringValue image_path = 6;
}

View File

@@ -1,10 +1,10 @@
using FluentValidation;
using CMSMicroservice.Protobuf.Protos.PruductCategory;
namespace CMSMicroservice.Protobuf.Validator.PruductCategory;
using CMSMicroservice.Protobuf.Protos.ProductCategory;
namespace CMSMicroservice.Protobuf.Validator.ProductCategory;
public class CreateNewPruductCategoryRequestValidator : AbstractValidator<CreateNewPruductCategoryRequest>
public class CreateNewProductCategoryRequestValidator : AbstractValidator<CreateNewProductCategoryRequest>
{
public CreateNewPruductCategoryRequestValidator()
public CreateNewProductCategoryRequestValidator()
{
RuleFor(model => model.ProductId)
.NotNull();
@@ -13,7 +13,7 @@ public class CreateNewPruductCategoryRequestValidator : AbstractValidator<Create
}
public Func<object, string, Task<IEnumerable<string>>> ValidateValue => async (model, propertyName) =>
{
var result = await ValidateAsync(ValidationContext<CreateNewPruductCategoryRequest>.CreateWithOptions((CreateNewPruductCategoryRequest)model, x => x.IncludeProperties(propertyName)));
var result = await ValidateAsync(ValidationContext<CreateNewProductCategoryRequest>.CreateWithOptions((CreateNewProductCategoryRequest)model, x => x.IncludeProperties(propertyName)));
if (result.IsValid)
return Array.Empty<string>();
return result.Errors.Select(e => e.ErrorMessage);

View File

@@ -1,17 +1,17 @@
using FluentValidation;
using CMSMicroservice.Protobuf.Protos.PruductCategory;
namespace CMSMicroservice.Protobuf.Validator.PruductCategory;
using CMSMicroservice.Protobuf.Protos.ProductCategory;
namespace CMSMicroservice.Protobuf.Validator.ProductCategory;
public class DeletePruductCategoryRequestValidator : AbstractValidator<DeletePruductCategoryRequest>
public class DeleteProductCategoryRequestValidator : AbstractValidator<DeleteProductCategoryRequest>
{
public DeletePruductCategoryRequestValidator()
public DeleteProductCategoryRequestValidator()
{
RuleFor(model => model.Id)
.NotNull();
}
public Func<object, string, Task<IEnumerable<string>>> ValidateValue => async (model, propertyName) =>
{
var result = await ValidateAsync(ValidationContext<DeletePruductCategoryRequest>.CreateWithOptions((DeletePruductCategoryRequest)model, x => x.IncludeProperties(propertyName)));
var result = await ValidateAsync(ValidationContext<DeleteProductCategoryRequest>.CreateWithOptions((DeleteProductCategoryRequest)model, x => x.IncludeProperties(propertyName)));
if (result.IsValid)
return Array.Empty<string>();
return result.Errors.Select(e => e.ErrorMessage);

View File

@@ -1,15 +1,15 @@
using FluentValidation;
using CMSMicroservice.Protobuf.Protos.PruductCategory;
namespace CMSMicroservice.Protobuf.Validator.PruductCategory;
using CMSMicroservice.Protobuf.Protos.ProductCategory;
namespace CMSMicroservice.Protobuf.Validator.ProductCategory;
public class GetAllPruductCategoryByFilterRequestValidator : AbstractValidator<GetAllPruductCategoryByFilterRequest>
public class GetAllProductCategoryByFilterRequestValidator : AbstractValidator<GetAllProductCategoryByFilterRequest>
{
public GetAllPruductCategoryByFilterRequestValidator()
public GetAllProductCategoryByFilterRequestValidator()
{
}
public Func<object, string, Task<IEnumerable<string>>> ValidateValue => async (model, propertyName) =>
{
var result = await ValidateAsync(ValidationContext<GetAllPruductCategoryByFilterRequest>.CreateWithOptions((GetAllPruductCategoryByFilterRequest)model, x => x.IncludeProperties(propertyName)));
var result = await ValidateAsync(ValidationContext<GetAllProductCategoryByFilterRequest>.CreateWithOptions((GetAllProductCategoryByFilterRequest)model, x => x.IncludeProperties(propertyName)));
if (result.IsValid)
return Array.Empty<string>();
return result.Errors.Select(e => e.ErrorMessage);

View File

@@ -1,17 +1,17 @@
using FluentValidation;
using CMSMicroservice.Protobuf.Protos.PruductCategory;
namespace CMSMicroservice.Protobuf.Validator.PruductCategory;
using CMSMicroservice.Protobuf.Protos.ProductCategory;
namespace CMSMicroservice.Protobuf.Validator.ProductCategory;
public class GetPruductCategoryRequestValidator : AbstractValidator<GetPruductCategoryRequest>
public class GetProductCategoryRequestValidator : AbstractValidator<GetProductCategoryRequest>
{
public GetPruductCategoryRequestValidator()
public GetProductCategoryRequestValidator()
{
RuleFor(model => model.Id)
.NotNull();
}
public Func<object, string, Task<IEnumerable<string>>> ValidateValue => async (model, propertyName) =>
{
var result = await ValidateAsync(ValidationContext<GetPruductCategoryRequest>.CreateWithOptions((GetPruductCategoryRequest)model, x => x.IncludeProperties(propertyName)));
var result = await ValidateAsync(ValidationContext<GetProductCategoryRequest>.CreateWithOptions((GetProductCategoryRequest)model, x => x.IncludeProperties(propertyName)));
if (result.IsValid)
return Array.Empty<string>();
return result.Errors.Select(e => e.ErrorMessage);

View File

@@ -1,10 +1,10 @@
using FluentValidation;
using CMSMicroservice.Protobuf.Protos.PruductCategory;
namespace CMSMicroservice.Protobuf.Validator.PruductCategory;
using CMSMicroservice.Protobuf.Protos.ProductCategory;
namespace CMSMicroservice.Protobuf.Validator.ProductCategory;
public class UpdatePruductCategoryRequestValidator : AbstractValidator<UpdatePruductCategoryRequest>
public class UpdateProductCategoryRequestValidator : AbstractValidator<UpdateProductCategoryRequest>
{
public UpdatePruductCategoryRequestValidator()
public UpdateProductCategoryRequestValidator()
{
RuleFor(model => model.Id)
.NotNull();
@@ -15,7 +15,7 @@ public class UpdatePruductCategoryRequestValidator : AbstractValidator<UpdatePru
}
public Func<object, string, Task<IEnumerable<string>>> ValidateValue => async (model, propertyName) =>
{
var result = await ValidateAsync(ValidationContext<UpdatePruductCategoryRequest>.CreateWithOptions((UpdatePruductCategoryRequest)model, x => x.IncludeProperties(propertyName)));
var result = await ValidateAsync(ValidationContext<UpdateProductCategoryRequest>.CreateWithOptions((UpdateProductCategoryRequest)model, x => x.IncludeProperties(propertyName)));
if (result.IsValid)
return Array.Empty<string>();
return result.Errors.Select(e => e.ErrorMessage);

View File

@@ -1,10 +1,10 @@
using FluentValidation;
using CMSMicroservice.Protobuf.Protos.ProductGallerys;
namespace CMSMicroservice.Protobuf.Validator.ProductGallerys;
using CMSMicroservice.Protobuf.Protos.ProductGalleries;
namespace CMSMicroservice.Protobuf.Validator.ProductGalleries;
public class CreateNewProductGallerysRequestValidator : AbstractValidator<CreateNewProductGallerysRequest>
public class CreateNewProductGalleriesRequestValidator : AbstractValidator<CreateNewProductGalleriesRequest>
{
public CreateNewProductGallerysRequestValidator()
public CreateNewProductGalleriesRequestValidator()
{
RuleFor(model => model.ProductImageId)
.NotNull();
@@ -13,7 +13,7 @@ public class CreateNewProductGallerysRequestValidator : AbstractValidator<Create
}
public Func<object, string, Task<IEnumerable<string>>> ValidateValue => async (model, propertyName) =>
{
var result = await ValidateAsync(ValidationContext<CreateNewProductGallerysRequest>.CreateWithOptions((CreateNewProductGallerysRequest)model, x => x.IncludeProperties(propertyName)));
var result = await ValidateAsync(ValidationContext<CreateNewProductGalleriesRequest>.CreateWithOptions((CreateNewProductGalleriesRequest)model, x => x.IncludeProperties(propertyName)));
if (result.IsValid)
return Array.Empty<string>();
return result.Errors.Select(e => e.ErrorMessage);

View File

@@ -1,17 +1,17 @@
using FluentValidation;
using CMSMicroservice.Protobuf.Protos.ProductGallerys;
namespace CMSMicroservice.Protobuf.Validator.ProductGallerys;
using CMSMicroservice.Protobuf.Protos.ProductGalleries;
namespace CMSMicroservice.Protobuf.Validator.ProductGalleries;
public class DeleteProductGallerysRequestValidator : AbstractValidator<DeleteProductGallerysRequest>
public class DeleteProductGalleriesRequestValidator : AbstractValidator<DeleteProductGalleriesRequest>
{
public DeleteProductGallerysRequestValidator()
public DeleteProductGalleriesRequestValidator()
{
RuleFor(model => model.Id)
.NotNull();
}
public Func<object, string, Task<IEnumerable<string>>> ValidateValue => async (model, propertyName) =>
{
var result = await ValidateAsync(ValidationContext<DeleteProductGallerysRequest>.CreateWithOptions((DeleteProductGallerysRequest)model, x => x.IncludeProperties(propertyName)));
var result = await ValidateAsync(ValidationContext<DeleteProductGalleriesRequest>.CreateWithOptions((DeleteProductGalleriesRequest)model, x => x.IncludeProperties(propertyName)));
if (result.IsValid)
return Array.Empty<string>();
return result.Errors.Select(e => e.ErrorMessage);

View File

@@ -0,0 +1,17 @@
using FluentValidation;
using CMSMicroservice.Protobuf.Protos.ProductGalleries;
namespace CMSMicroservice.Protobuf.Validator.ProductGalleries;
public class GetAllProductGalleriesByFilterRequestValidator : AbstractValidator<GetAllProductGalleriesByFilterRequest>
{
public GetAllProductGalleriesByFilterRequestValidator()
{
}
public Func<object, string, Task<IEnumerable<string>>> ValidateValue => async (model, propertyName) =>
{
var result = await ValidateAsync(ValidationContext<GetAllProductGalleriesByFilterRequest>.CreateWithOptions((GetAllProductGalleriesByFilterRequest)model, x => x.IncludeProperties(propertyName)));
if (result.IsValid)
return Array.Empty<string>();
return result.Errors.Select(e => e.ErrorMessage);
};
}

View File

@@ -1,17 +1,17 @@
using FluentValidation;
using CMSMicroservice.Protobuf.Protos.ProductGallerys;
namespace CMSMicroservice.Protobuf.Validator.ProductGallerys;
using CMSMicroservice.Protobuf.Protos.ProductGalleries;
namespace CMSMicroservice.Protobuf.Validator.ProductGalleries;
public class GetProductGallerysRequestValidator : AbstractValidator<GetProductGallerysRequest>
public class GetProductGalleriesRequestValidator : AbstractValidator<GetProductGalleriesRequest>
{
public GetProductGallerysRequestValidator()
public GetProductGalleriesRequestValidator()
{
RuleFor(model => model.Id)
.NotNull();
}
public Func<object, string, Task<IEnumerable<string>>> ValidateValue => async (model, propertyName) =>
{
var result = await ValidateAsync(ValidationContext<GetProductGallerysRequest>.CreateWithOptions((GetProductGallerysRequest)model, x => x.IncludeProperties(propertyName)));
var result = await ValidateAsync(ValidationContext<GetProductGalleriesRequest>.CreateWithOptions((GetProductGalleriesRequest)model, x => x.IncludeProperties(propertyName)));
if (result.IsValid)
return Array.Empty<string>();
return result.Errors.Select(e => e.ErrorMessage);

View File

@@ -1,10 +1,10 @@
using FluentValidation;
using CMSMicroservice.Protobuf.Protos.ProductGallerys;
namespace CMSMicroservice.Protobuf.Validator.ProductGallerys;
using CMSMicroservice.Protobuf.Protos.ProductGalleries;
namespace CMSMicroservice.Protobuf.Validator.ProductGalleries;
public class UpdateProductGallerysRequestValidator : AbstractValidator<UpdateProductGallerysRequest>
public class UpdateProductGalleriesRequestValidator : AbstractValidator<UpdateProductGalleriesRequest>
{
public UpdateProductGallerysRequestValidator()
public UpdateProductGalleriesRequestValidator()
{
RuleFor(model => model.Id)
.NotNull();
@@ -15,7 +15,7 @@ public class UpdateProductGallerysRequestValidator : AbstractValidator<UpdatePro
}
public Func<object, string, Task<IEnumerable<string>>> ValidateValue => async (model, propertyName) =>
{
var result = await ValidateAsync(ValidationContext<UpdateProductGallerysRequest>.CreateWithOptions((UpdateProductGallerysRequest)model, x => x.IncludeProperties(propertyName)));
var result = await ValidateAsync(ValidationContext<UpdateProductGalleriesRequest>.CreateWithOptions((UpdateProductGalleriesRequest)model, x => x.IncludeProperties(propertyName)));
if (result.IsValid)
return Array.Empty<string>();
return result.Errors.Select(e => e.ErrorMessage);

View File

@@ -1,17 +0,0 @@
using FluentValidation;
using CMSMicroservice.Protobuf.Protos.ProductGallerys;
namespace CMSMicroservice.Protobuf.Validator.ProductGallerys;
public class GetAllProductGallerysByFilterRequestValidator : AbstractValidator<GetAllProductGallerysByFilterRequest>
{
public GetAllProductGallerysByFilterRequestValidator()
{
}
public Func<object, string, Task<IEnumerable<string>>> ValidateValue => async (model, propertyName) =>
{
var result = await ValidateAsync(ValidationContext<GetAllProductGallerysByFilterRequest>.CreateWithOptions((GetAllProductGallerysByFilterRequest)model, x => x.IncludeProperties(propertyName)));
if (result.IsValid)
return Array.Empty<string>();
return result.Errors.Select(e => e.ErrorMessage);
};
}

View File

@@ -1,10 +1,10 @@
using FluentValidation;
using CMSMicroservice.Protobuf.Protos.PruductTag;
namespace CMSMicroservice.Protobuf.Validator.PruductTag;
using CMSMicroservice.Protobuf.Protos.ProductTag;
namespace CMSMicroservice.Protobuf.Validator.ProductTag;
public class CreateNewPruductTagRequestValidator : AbstractValidator<CreateNewPruductTagRequest>
public class CreateNewProductTagRequestValidator : AbstractValidator<CreateNewProductTagRequest>
{
public CreateNewPruductTagRequestValidator()
public CreateNewProductTagRequestValidator()
{
RuleFor(model => model.ProductId)
.NotNull();
@@ -13,7 +13,7 @@ public class CreateNewPruductTagRequestValidator : AbstractValidator<CreateNewPr
}
public Func<object, string, Task<IEnumerable<string>>> ValidateValue => async (model, propertyName) =>
{
var result = await ValidateAsync(ValidationContext<CreateNewPruductTagRequest>.CreateWithOptions((CreateNewPruductTagRequest)model, x => x.IncludeProperties(propertyName)));
var result = await ValidateAsync(ValidationContext<CreateNewProductTagRequest>.CreateWithOptions((CreateNewProductTagRequest)model, x => x.IncludeProperties(propertyName)));
if (result.IsValid)
return Array.Empty<string>();
return result.Errors.Select(e => e.ErrorMessage);

View File

@@ -1,17 +1,17 @@
using FluentValidation;
using CMSMicroservice.Protobuf.Protos.PruductTag;
namespace CMSMicroservice.Protobuf.Validator.PruductTag;
using CMSMicroservice.Protobuf.Protos.ProductTag;
namespace CMSMicroservice.Protobuf.Validator.ProductTag;
public class DeletePruductTagRequestValidator : AbstractValidator<DeletePruductTagRequest>
public class DeleteProductTagRequestValidator : AbstractValidator<DeleteProductTagRequest>
{
public DeletePruductTagRequestValidator()
public DeleteProductTagRequestValidator()
{
RuleFor(model => model.Id)
.NotNull();
}
public Func<object, string, Task<IEnumerable<string>>> ValidateValue => async (model, propertyName) =>
{
var result = await ValidateAsync(ValidationContext<DeletePruductTagRequest>.CreateWithOptions((DeletePruductTagRequest)model, x => x.IncludeProperties(propertyName)));
var result = await ValidateAsync(ValidationContext<DeleteProductTagRequest>.CreateWithOptions((DeleteProductTagRequest)model, x => x.IncludeProperties(propertyName)));
if (result.IsValid)
return Array.Empty<string>();
return result.Errors.Select(e => e.ErrorMessage);

View File

@@ -1,15 +1,15 @@
using FluentValidation;
using CMSMicroservice.Protobuf.Protos.PruductTag;
namespace CMSMicroservice.Protobuf.Validator.PruductTag;
using CMSMicroservice.Protobuf.Protos.ProductTag;
namespace CMSMicroservice.Protobuf.Validator.ProductTag;
public class GetAllPruductTagByFilterRequestValidator : AbstractValidator<GetAllPruductTagByFilterRequest>
public class GetAllProductTagByFilterRequestValidator : AbstractValidator<GetAllProductTagByFilterRequest>
{
public GetAllPruductTagByFilterRequestValidator()
public GetAllProductTagByFilterRequestValidator()
{
}
public Func<object, string, Task<IEnumerable<string>>> ValidateValue => async (model, propertyName) =>
{
var result = await ValidateAsync(ValidationContext<GetAllPruductTagByFilterRequest>.CreateWithOptions((GetAllPruductTagByFilterRequest)model, x => x.IncludeProperties(propertyName)));
var result = await ValidateAsync(ValidationContext<GetAllProductTagByFilterRequest>.CreateWithOptions((GetAllProductTagByFilterRequest)model, x => x.IncludeProperties(propertyName)));
if (result.IsValid)
return Array.Empty<string>();
return result.Errors.Select(e => e.ErrorMessage);

View File

@@ -1,17 +1,17 @@
using FluentValidation;
using CMSMicroservice.Protobuf.Protos.PruductTag;
namespace CMSMicroservice.Protobuf.Validator.PruductTag;
using CMSMicroservice.Protobuf.Protos.ProductTag;
namespace CMSMicroservice.Protobuf.Validator.ProductTag;
public class GetPruductTagRequestValidator : AbstractValidator<GetPruductTagRequest>
public class GetProductTagRequestValidator : AbstractValidator<GetProductTagRequest>
{
public GetPruductTagRequestValidator()
public GetProductTagRequestValidator()
{
RuleFor(model => model.Id)
.NotNull();
}
public Func<object, string, Task<IEnumerable<string>>> ValidateValue => async (model, propertyName) =>
{
var result = await ValidateAsync(ValidationContext<GetPruductTagRequest>.CreateWithOptions((GetPruductTagRequest)model, x => x.IncludeProperties(propertyName)));
var result = await ValidateAsync(ValidationContext<GetProductTagRequest>.CreateWithOptions((GetProductTagRequest)model, x => x.IncludeProperties(propertyName)));
if (result.IsValid)
return Array.Empty<string>();
return result.Errors.Select(e => e.ErrorMessage);

View File

@@ -1,10 +1,10 @@
using FluentValidation;
using CMSMicroservice.Protobuf.Protos.PruductTag;
namespace CMSMicroservice.Protobuf.Validator.PruductTag;
using CMSMicroservice.Protobuf.Protos.ProductTag;
namespace CMSMicroservice.Protobuf.Validator.ProductTag;
public class UpdatePruductTagRequestValidator : AbstractValidator<UpdatePruductTagRequest>
public class UpdateProductTagRequestValidator : AbstractValidator<UpdateProductTagRequest>
{
public UpdatePruductTagRequestValidator()
public UpdateProductTagRequestValidator()
{
RuleFor(model => model.Id)
.NotNull();
@@ -15,7 +15,7 @@ public class UpdatePruductTagRequestValidator : AbstractValidator<UpdatePruductT
}
public Func<object, string, Task<IEnumerable<string>>> ValidateValue => async (model, propertyName) =>
{
var result = await ValidateAsync(ValidationContext<UpdatePruductTagRequest>.CreateWithOptions((UpdatePruductTagRequest)model, x => x.IncludeProperties(propertyName)));
var result = await ValidateAsync(ValidationContext<UpdateProductTagRequest>.CreateWithOptions((UpdateProductTagRequest)model, x => x.IncludeProperties(propertyName)));
if (result.IsValid)
return Array.Empty<string>();
return result.Errors.Select(e => e.ErrorMessage);