update
This commit is contained in:
@@ -39,6 +39,9 @@
|
||||
<!-- 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\tag.proto" ProtoRoot="Protos\" GrpcServices="Both" />
|
||||
<Protobuf Include="Protos\pruducttag.proto" ProtoRoot="Protos\" GrpcServices="Both" />
|
||||
</ItemGroup>
|
||||
|
||||
<Target Name="PushToFoursatNuget" AfterTargets="Pack">
|
||||
|
||||
99
src/CMSMicroservice.Protobuf/Protos/pruducttag.proto
Normal file
99
src/CMSMicroservice.Protobuf/Protos/pruducttag.proto
Normal file
@@ -0,0 +1,99 @@
|
||||
syntax = "proto3";
|
||||
|
||||
package pruducttag;
|
||||
|
||||
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.PruductTag";
|
||||
|
||||
service PruductTagContract
|
||||
{
|
||||
rpc CreateNewPruductTag(CreateNewPruductTagRequest) returns (CreateNewPruductTagResponse){
|
||||
option (google.api.http) = {
|
||||
post: "/CreateNewPruductTag"
|
||||
body: "*"
|
||||
};
|
||||
};
|
||||
rpc UpdatePruductTag(UpdatePruductTagRequest) returns (google.protobuf.Empty){
|
||||
option (google.api.http) = {
|
||||
put: "/UpdatePruductTag"
|
||||
body: "*"
|
||||
};
|
||||
};
|
||||
rpc DeletePruductTag(DeletePruductTagRequest) returns (google.protobuf.Empty){
|
||||
option (google.api.http) = {
|
||||
delete: "/DeletePruductTag"
|
||||
body: "*"
|
||||
};
|
||||
};
|
||||
rpc GetPruductTag(GetPruductTagRequest) returns (GetPruductTagResponse){
|
||||
option (google.api.http) = {
|
||||
get: "/GetPruductTag"
|
||||
|
||||
};
|
||||
};
|
||||
rpc GetAllPruductTagByFilter(GetAllPruductTagByFilterRequest) returns (GetAllPruductTagByFilterResponse){
|
||||
option (google.api.http) = {
|
||||
get: "/GetAllPruductTagByFilter"
|
||||
|
||||
};
|
||||
};
|
||||
}
|
||||
message CreateNewPruductTagRequest
|
||||
{
|
||||
string product_id = 1;
|
||||
string tag_id = 2;
|
||||
}
|
||||
message CreateNewPruductTagResponse
|
||||
{
|
||||
int64 id = 1;
|
||||
}
|
||||
message UpdatePruductTagRequest
|
||||
{
|
||||
int64 id = 1;
|
||||
string product_id = 2;
|
||||
string tag_id = 3;
|
||||
}
|
||||
message DeletePruductTagRequest
|
||||
{
|
||||
int64 id = 1;
|
||||
}
|
||||
message GetPruductTagRequest
|
||||
{
|
||||
int64 id = 1;
|
||||
}
|
||||
message GetPruductTagResponse
|
||||
{
|
||||
int64 id = 1;
|
||||
string product_id = 2;
|
||||
string tag_id = 3;
|
||||
}
|
||||
message GetAllPruductTagByFilterRequest
|
||||
{
|
||||
messages.PaginationState pagination_state = 1;
|
||||
google.protobuf.StringValue sort_by = 2;
|
||||
GetAllPruductTagByFilterFilter filter = 3;
|
||||
}
|
||||
message GetAllPruductTagByFilterFilter
|
||||
{
|
||||
google.protobuf.Int64Value id = 1;
|
||||
google.protobuf.StringValue product_id = 2;
|
||||
google.protobuf.StringValue tag_id = 3;
|
||||
}
|
||||
message GetAllPruductTagByFilterResponse
|
||||
{
|
||||
messages.MetaData meta_data = 1;
|
||||
repeated GetAllPruductTagByFilterResponseModel models = 2;
|
||||
}
|
||||
message GetAllPruductTagByFilterResponseModel
|
||||
{
|
||||
int64 id = 1;
|
||||
string product_id = 2;
|
||||
string tag_id = 3;
|
||||
}
|
||||
|
||||
114
src/CMSMicroservice.Protobuf/Protos/tag.proto
Normal file
114
src/CMSMicroservice.Protobuf/Protos/tag.proto
Normal file
@@ -0,0 +1,114 @@
|
||||
syntax = "proto3";
|
||||
|
||||
package tag;
|
||||
|
||||
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.Tag";
|
||||
|
||||
service TagContract
|
||||
{
|
||||
rpc CreateNewTag(CreateNewTagRequest) returns (CreateNewTagResponse){
|
||||
option (google.api.http) = {
|
||||
post: "/CreateNewTag"
|
||||
body: "*"
|
||||
};
|
||||
};
|
||||
rpc UpdateTag(UpdateTagRequest) returns (google.protobuf.Empty){
|
||||
option (google.api.http) = {
|
||||
put: "/UpdateTag"
|
||||
body: "*"
|
||||
};
|
||||
};
|
||||
rpc DeleteTag(DeleteTagRequest) returns (google.protobuf.Empty){
|
||||
option (google.api.http) = {
|
||||
delete: "/DeleteTag"
|
||||
body: "*"
|
||||
};
|
||||
};
|
||||
rpc GetTag(GetTagRequest) returns (GetTagResponse){
|
||||
option (google.api.http) = {
|
||||
get: "/GetTag"
|
||||
|
||||
};
|
||||
};
|
||||
rpc GetAllTagByFilter(GetAllTagByFilterRequest) returns (GetAllTagByFilterResponse){
|
||||
option (google.api.http) = {
|
||||
get: "/GetAllTagByFilter"
|
||||
|
||||
};
|
||||
};
|
||||
}
|
||||
message CreateNewTagRequest
|
||||
{
|
||||
string name = 1;
|
||||
string title = 2;
|
||||
string description = 3;
|
||||
bool is_active = 4;
|
||||
int32 sort_order = 5;
|
||||
}
|
||||
message CreateNewTagResponse
|
||||
{
|
||||
int64 id = 1;
|
||||
}
|
||||
message UpdateTagRequest
|
||||
{
|
||||
int64 id = 1;
|
||||
string name = 2;
|
||||
string title = 3;
|
||||
string description = 4;
|
||||
bool is_active = 5;
|
||||
int32 sort_order = 6;
|
||||
}
|
||||
message DeleteTagRequest
|
||||
{
|
||||
int64 id = 1;
|
||||
}
|
||||
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;
|
||||
}
|
||||
message GetAllTagByFilterRequest
|
||||
{
|
||||
messages.PaginationState pagination_state = 1;
|
||||
google.protobuf.StringValue sort_by = 2;
|
||||
GetAllTagByFilterFilter filter = 3;
|
||||
}
|
||||
message GetAllTagByFilterFilter
|
||||
{
|
||||
google.protobuf.Int64Value id = 1;
|
||||
google.protobuf.StringValue name = 2;
|
||||
google.protobuf.StringValue title = 3;
|
||||
google.protobuf.StringValue description = 4;
|
||||
google.protobuf.BoolValue is_active = 5;
|
||||
google.protobuf.Int32Value sort_order = 6;
|
||||
}
|
||||
message GetAllTagByFilterResponse
|
||||
{
|
||||
messages.MetaData meta_data = 1;
|
||||
repeated GetAllTagByFilterResponseModel models = 2;
|
||||
}
|
||||
message GetAllTagByFilterResponseModel
|
||||
{
|
||||
int64 id = 1;
|
||||
string name = 2;
|
||||
string title = 3;
|
||||
string description = 4;
|
||||
bool is_active = 5;
|
||||
int32 sort_order = 6;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
using FluentValidation;
|
||||
using CMSMicroservice.Protobuf.Protos.PruductTag;
|
||||
namespace CMSMicroservice.Protobuf.Validator.PruductTag;
|
||||
|
||||
public class CreateNewPruductTagRequestValidator : AbstractValidator<CreateNewPruductTagRequest>
|
||||
{
|
||||
public CreateNewPruductTagRequestValidator()
|
||||
{
|
||||
RuleFor(model => model.ProductId)
|
||||
.NotEmpty();
|
||||
RuleFor(model => model.TagId)
|
||||
.NotEmpty();
|
||||
}
|
||||
public Func<object, string, Task<IEnumerable<string>>> ValidateValue => async (model, propertyName) =>
|
||||
{
|
||||
var result = await ValidateAsync(ValidationContext<CreateNewPruductTagRequest>.CreateWithOptions((CreateNewPruductTagRequest)model, x => x.IncludeProperties(propertyName)));
|
||||
if (result.IsValid)
|
||||
return Array.Empty<string>();
|
||||
return result.Errors.Select(e => e.ErrorMessage);
|
||||
};
|
||||
}
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
using FluentValidation;
|
||||
using CMSMicroservice.Protobuf.Protos.PruductTag;
|
||||
namespace CMSMicroservice.Protobuf.Validator.PruductTag;
|
||||
|
||||
public class DeletePruductTagRequestValidator : AbstractValidator<DeletePruductTagRequest>
|
||||
{
|
||||
public DeletePruductTagRequestValidator()
|
||||
{
|
||||
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)));
|
||||
if (result.IsValid)
|
||||
return Array.Empty<string>();
|
||||
return result.Errors.Select(e => e.ErrorMessage);
|
||||
};
|
||||
}
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
using FluentValidation;
|
||||
using CMSMicroservice.Protobuf.Protos.PruductTag;
|
||||
namespace CMSMicroservice.Protobuf.Validator.PruductTag;
|
||||
|
||||
public class GetAllPruductTagByFilterRequestValidator : AbstractValidator<GetAllPruductTagByFilterRequest>
|
||||
{
|
||||
public GetAllPruductTagByFilterRequestValidator()
|
||||
{
|
||||
}
|
||||
public Func<object, string, Task<IEnumerable<string>>> ValidateValue => async (model, propertyName) =>
|
||||
{
|
||||
var result = await ValidateAsync(ValidationContext<GetAllPruductTagByFilterRequest>.CreateWithOptions((GetAllPruductTagByFilterRequest)model, x => x.IncludeProperties(propertyName)));
|
||||
if (result.IsValid)
|
||||
return Array.Empty<string>();
|
||||
return result.Errors.Select(e => e.ErrorMessage);
|
||||
};
|
||||
}
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
using FluentValidation;
|
||||
using CMSMicroservice.Protobuf.Protos.PruductTag;
|
||||
namespace CMSMicroservice.Protobuf.Validator.PruductTag;
|
||||
|
||||
public class GetPruductTagRequestValidator : AbstractValidator<GetPruductTagRequest>
|
||||
{
|
||||
public GetPruductTagRequestValidator()
|
||||
{
|
||||
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)));
|
||||
if (result.IsValid)
|
||||
return Array.Empty<string>();
|
||||
return result.Errors.Select(e => e.ErrorMessage);
|
||||
};
|
||||
}
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
using FluentValidation;
|
||||
using CMSMicroservice.Protobuf.Protos.PruductTag;
|
||||
namespace CMSMicroservice.Protobuf.Validator.PruductTag;
|
||||
|
||||
public class UpdatePruductTagRequestValidator : AbstractValidator<UpdatePruductTagRequest>
|
||||
{
|
||||
public UpdatePruductTagRequestValidator()
|
||||
{
|
||||
RuleFor(model => model.Id)
|
||||
.NotNull();
|
||||
RuleFor(model => model.ProductId)
|
||||
.NotEmpty();
|
||||
RuleFor(model => model.TagId)
|
||||
.NotEmpty();
|
||||
}
|
||||
public Func<object, string, Task<IEnumerable<string>>> ValidateValue => async (model, propertyName) =>
|
||||
{
|
||||
var result = await ValidateAsync(ValidationContext<UpdatePruductTagRequest>.CreateWithOptions((UpdatePruductTagRequest)model, x => x.IncludeProperties(propertyName)));
|
||||
if (result.IsValid)
|
||||
return Array.Empty<string>();
|
||||
return result.Errors.Select(e => e.ErrorMessage);
|
||||
};
|
||||
}
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
using FluentValidation;
|
||||
using CMSMicroservice.Protobuf.Protos.Tag;
|
||||
namespace CMSMicroservice.Protobuf.Validator.Tag;
|
||||
|
||||
public class CreateNewTagRequestValidator : AbstractValidator<CreateNewTagRequest>
|
||||
{
|
||||
public CreateNewTagRequestValidator()
|
||||
{
|
||||
RuleFor(model => model.Name)
|
||||
.NotEmpty();
|
||||
RuleFor(model => model.Title)
|
||||
.NotEmpty();
|
||||
RuleFor(model => model.SortOrder)
|
||||
.NotNull();
|
||||
}
|
||||
public Func<object, string, Task<IEnumerable<string>>> ValidateValue => async (model, propertyName) =>
|
||||
{
|
||||
var result = await ValidateAsync(ValidationContext<CreateNewTagRequest>.CreateWithOptions((CreateNewTagRequest)model, x => x.IncludeProperties(propertyName)));
|
||||
if (result.IsValid)
|
||||
return Array.Empty<string>();
|
||||
return result.Errors.Select(e => e.ErrorMessage);
|
||||
};
|
||||
}
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
using FluentValidation;
|
||||
using CMSMicroservice.Protobuf.Protos.Tag;
|
||||
namespace CMSMicroservice.Protobuf.Validator.Tag;
|
||||
|
||||
public class DeleteTagRequestValidator : AbstractValidator<DeleteTagRequest>
|
||||
{
|
||||
public DeleteTagRequestValidator()
|
||||
{
|
||||
RuleFor(model => model.Id)
|
||||
.NotNull();
|
||||
}
|
||||
public Func<object, string, Task<IEnumerable<string>>> ValidateValue => async (model, propertyName) =>
|
||||
{
|
||||
var result = await ValidateAsync(ValidationContext<DeleteTagRequest>.CreateWithOptions((DeleteTagRequest)model, x => x.IncludeProperties(propertyName)));
|
||||
if (result.IsValid)
|
||||
return Array.Empty<string>();
|
||||
return result.Errors.Select(e => e.ErrorMessage);
|
||||
};
|
||||
}
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
using FluentValidation;
|
||||
using CMSMicroservice.Protobuf.Protos.Tag;
|
||||
namespace CMSMicroservice.Protobuf.Validator.Tag;
|
||||
|
||||
public class GetAllTagByFilterRequestValidator : AbstractValidator<GetAllTagByFilterRequest>
|
||||
{
|
||||
public GetAllTagByFilterRequestValidator()
|
||||
{
|
||||
}
|
||||
public Func<object, string, Task<IEnumerable<string>>> ValidateValue => async (model, propertyName) =>
|
||||
{
|
||||
var result = await ValidateAsync(ValidationContext<GetAllTagByFilterRequest>.CreateWithOptions((GetAllTagByFilterRequest)model, x => x.IncludeProperties(propertyName)));
|
||||
if (result.IsValid)
|
||||
return Array.Empty<string>();
|
||||
return result.Errors.Select(e => e.ErrorMessage);
|
||||
};
|
||||
}
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
using FluentValidation;
|
||||
using CMSMicroservice.Protobuf.Protos.Tag;
|
||||
namespace CMSMicroservice.Protobuf.Validator.Tag;
|
||||
|
||||
public class GetTagRequestValidator : AbstractValidator<GetTagRequest>
|
||||
{
|
||||
public GetTagRequestValidator()
|
||||
{
|
||||
RuleFor(model => model.Id)
|
||||
.NotNull();
|
||||
}
|
||||
public Func<object, string, Task<IEnumerable<string>>> ValidateValue => async (model, propertyName) =>
|
||||
{
|
||||
var result = await ValidateAsync(ValidationContext<GetTagRequest>.CreateWithOptions((GetTagRequest)model, x => x.IncludeProperties(propertyName)));
|
||||
if (result.IsValid)
|
||||
return Array.Empty<string>();
|
||||
return result.Errors.Select(e => e.ErrorMessage);
|
||||
};
|
||||
}
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
using FluentValidation;
|
||||
using CMSMicroservice.Protobuf.Protos.Tag;
|
||||
namespace CMSMicroservice.Protobuf.Validator.Tag;
|
||||
|
||||
public class UpdateTagRequestValidator : AbstractValidator<UpdateTagRequest>
|
||||
{
|
||||
public UpdateTagRequestValidator()
|
||||
{
|
||||
RuleFor(model => model.Id)
|
||||
.NotNull();
|
||||
RuleFor(model => model.Name)
|
||||
.NotEmpty();
|
||||
RuleFor(model => model.Title)
|
||||
.NotEmpty();
|
||||
RuleFor(model => model.SortOrder)
|
||||
.NotNull();
|
||||
}
|
||||
public Func<object, string, Task<IEnumerable<string>>> ValidateValue => async (model, propertyName) =>
|
||||
{
|
||||
var result = await ValidateAsync(ValidationContext<UpdateTagRequest>.CreateWithOptions((UpdateTagRequest)model, x => x.IncludeProperties(propertyName)));
|
||||
if (result.IsValid)
|
||||
return Array.Empty<string>();
|
||||
return result.Errors.Select(e => e.ErrorMessage);
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user