Generator Changes at 11/12/2025 10:14:04 PM +03:30
This commit is contained in:
@@ -0,0 +1,9 @@
|
||||
namespace CMSMicroservice.Application.UserCQ.Queries.AdminGetJwtToken;
|
||||
public record AdminGetJwtTokenQuery : IRequest<AdminGetJwtTokenResponseDto>
|
||||
{
|
||||
//نام کاربری
|
||||
public string Username { get; init; }
|
||||
//کلمه عبور
|
||||
public string Password { get; init; }
|
||||
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
namespace CMSMicroservice.Application.UserCQ.Queries.AdminGetJwtToken;
|
||||
public class AdminGetJwtTokenQueryHandler : IRequestHandler<AdminGetJwtTokenQuery, AdminGetJwtTokenResponseDto>
|
||||
{
|
||||
private readonly IApplicationDbContext _context;
|
||||
|
||||
public AdminGetJwtTokenQueryHandler(IApplicationDbContext context)
|
||||
{
|
||||
_context = context;
|
||||
}
|
||||
|
||||
public async Task<AdminGetJwtTokenResponseDto> Handle(AdminGetJwtTokenQuery request, CancellationToken cancellationToken)
|
||||
{
|
||||
//TODO: Implement your business logic
|
||||
return new AdminGetJwtTokenResponseDto();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
namespace CMSMicroservice.Application.UserCQ.Queries.AdminGetJwtToken;
|
||||
public class AdminGetJwtTokenQueryValidator : AbstractValidator<AdminGetJwtTokenQuery>
|
||||
{
|
||||
public AdminGetJwtTokenQueryValidator()
|
||||
{
|
||||
RuleFor(model => model.Username)
|
||||
.NotEmpty();
|
||||
RuleFor(model => model.Password)
|
||||
.NotEmpty();
|
||||
}
|
||||
public Func<object, string, Task<IEnumerable<string>>> ValidateValue => async (model, propertyName) =>
|
||||
{
|
||||
var result = await ValidateAsync(ValidationContext<AdminGetJwtTokenQuery>.CreateWithOptions((AdminGetJwtTokenQuery)model, x => x.IncludeProperties(propertyName)));
|
||||
if (result.IsValid)
|
||||
return Array.Empty<string>();
|
||||
return result.Errors.Select(e => e.ErrorMessage);
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
namespace CMSMicroservice.Application.UserCQ.Queries.AdminGetJwtToken;
|
||||
public class AdminGetJwtTokenResponseDto
|
||||
{
|
||||
//توکن
|
||||
public string Token { get; set; }
|
||||
|
||||
}
|
||||
@@ -34,16 +34,18 @@ public class User : BaseAuditableEntity
|
||||
public bool PushNotifications { get; set; }
|
||||
//تاریخ تولد
|
||||
public DateTime? BirthDate { get; set; }
|
||||
//پسوورد هش کاربر
|
||||
public string? HashPassword { get; set; }
|
||||
//UserAddress Collection Navigation Reference
|
||||
public virtual ICollection<UserAddress> UserAddresss { get; set; }
|
||||
//UserRole Collection Navigation Reference
|
||||
public virtual ICollection<UserRole> UserRoles { get; set; }
|
||||
//User Collection Navigation Reference
|
||||
public virtual ICollection<User> Users { get; set; }
|
||||
//UserWallet Collection Navigation Reference
|
||||
public virtual ICollection<UserWallet> UserWallets { get; set; }
|
||||
//UserCarts Collection Navigation Reference
|
||||
public virtual ICollection<UserCarts> UserCartss { get; set; }
|
||||
//UserOrder Collection Navigation Reference
|
||||
public virtual ICollection<UserOrder> UserOrders { get; set; }
|
||||
//User Collection Navigation Reference
|
||||
public virtual ICollection<User> Users { get; set; }
|
||||
}
|
||||
|
||||
@@ -49,6 +49,12 @@ service UserContract
|
||||
|
||||
};
|
||||
};
|
||||
rpc AdminGetJwtToken(AdminGetJwtTokenRequest) returns (AdminGetJwtTokenResponse){
|
||||
option (google.api.http) = {
|
||||
get: "/AdminGetJwtToken"
|
||||
|
||||
};
|
||||
};
|
||||
}
|
||||
message CreateNewUserRequest
|
||||
{
|
||||
@@ -159,3 +165,12 @@ message GetJwtTokenResponse
|
||||
{
|
||||
string token = 1;
|
||||
}
|
||||
message AdminGetJwtTokenRequest
|
||||
{
|
||||
string username = 1;
|
||||
string password = 2;
|
||||
}
|
||||
message AdminGetJwtTokenResponse
|
||||
{
|
||||
string token = 1;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
using FluentValidation;
|
||||
using CMSMicroservice.Protobuf.Protos.User;
|
||||
namespace CMSMicroservice.Protobuf.Validator.User;
|
||||
|
||||
public class AdminGetJwtTokenRequestValidator : AbstractValidator<AdminGetJwtTokenRequest>
|
||||
{
|
||||
public AdminGetJwtTokenRequestValidator()
|
||||
{
|
||||
RuleFor(model => model.Username)
|
||||
.NotEmpty();
|
||||
RuleFor(model => model.Password)
|
||||
.NotEmpty();
|
||||
}
|
||||
public Func<object, string, Task<IEnumerable<string>>> ValidateValue => async (model, propertyName) =>
|
||||
{
|
||||
var result = await ValidateAsync(ValidationContext<AdminGetJwtTokenRequest>.CreateWithOptions((AdminGetJwtTokenRequest)model, x => x.IncludeProperties(propertyName)));
|
||||
if (result.IsValid)
|
||||
return Array.Empty<string>();
|
||||
return result.Errors.Select(e => e.ErrorMessage);
|
||||
};
|
||||
}
|
||||
@@ -6,6 +6,7 @@ using CMSMicroservice.Application.UserCQ.Commands.DeleteUser;
|
||||
using CMSMicroservice.Application.UserCQ.Queries.GetUser;
|
||||
using CMSMicroservice.Application.UserCQ.Queries.GetAllUserByFilter;
|
||||
using CMSMicroservice.Application.UserCQ.Queries.GetJwtToken;
|
||||
using CMSMicroservice.Application.UserCQ.Queries.AdminGetJwtToken;
|
||||
namespace CMSMicroservice.WebApi.Services;
|
||||
public class UserService : UserContract.UserContractBase
|
||||
{
|
||||
@@ -39,4 +40,8 @@ public class UserService : UserContract.UserContractBase
|
||||
{
|
||||
return await _dispatchRequestToCQRS.Handle<GetJwtTokenRequest, GetJwtTokenQuery, GetJwtTokenResponse>(request, context);
|
||||
}
|
||||
public override async Task<AdminGetJwtTokenResponse> AdminGetJwtToken(AdminGetJwtTokenRequest request, ServerCallContext context)
|
||||
{
|
||||
return await _dispatchRequestToCQRS.Handle<AdminGetJwtTokenRequest, AdminGetJwtTokenQuery, AdminGetJwtTokenResponse>(request, context);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user