feat: Implement user permission checks and manual payment functionalities
- Added CheckUserPermissionQuery and CheckUserPermissionQueryHandler for permission validation. - Introduced GetUserRolesQuery and GetUserRolesQueryHandler to retrieve user roles. - Created IPermissionService interface and its implementation in PermissionService. - Defined permission and role constants in PermissionDefinitions. - Developed SetDefaultVatPercentageCommand and its handler for VAT configuration. - Implemented GetCurrentVatPercentageQuery and handler to fetch current VAT settings. - Added manual payment commands: CreateManualPayment, ApproveManualPayment, and RejectManualPayment with respective handlers and validators. - Created GetManualPaymentsQuery and handler for retrieving manual payment records. - Integrated gRPC services for manual payments with appropriate permission checks. - Established Protobuf definitions for manual payment operations and metadata.
This commit is contained in:
@@ -1,19 +1,18 @@
|
||||
// GetActiveMessages - Public view
|
||||
using BackOffice.BFF.Application.Common.Interfaces;
|
||||
using BackOffice.BFF.PublicMessage.Protobuf;
|
||||
using CMSMicroservice.Protobuf.Protos;
|
||||
using Google.Protobuf.WellKnownTypes;
|
||||
using MediatR;
|
||||
using BffProto = BackOffice.BFF.PublicMessage.Protobuf;
|
||||
using CmsProto = CMSMicroservice.Protobuf.Protos;
|
||||
|
||||
namespace BackOffice.BFF.Application.PublicMessageCQ.Queries.GetActiveMessages;
|
||||
|
||||
public record GetActiveMessagesQuery : IRequest<GetActiveMessagesResponse>
|
||||
public record GetActiveMessagesQuery : IRequest<BffProto.GetActiveMessagesResponse>
|
||||
{
|
||||
public int? MessageType { get; init; }
|
||||
public string? TargetAudience { get; init; }
|
||||
}
|
||||
|
||||
public class GetActiveMessagesQueryHandler : IRequestHandler<GetActiveMessagesQuery, GetActiveMessagesResponse>
|
||||
public class GetActiveMessagesQueryHandler : IRequestHandler<GetActiveMessagesQuery, BffProto.GetActiveMessagesResponse>
|
||||
{
|
||||
private readonly IApplicationContractContext _context;
|
||||
|
||||
@@ -22,18 +21,18 @@ public class GetActiveMessagesQueryHandler : IRequestHandler<GetActiveMessagesQu
|
||||
_context = context;
|
||||
}
|
||||
|
||||
public async Task<GetActiveMessagesResponse> Handle(GetActiveMessagesQuery request, CancellationToken cancellationToken)
|
||||
public async Task<BffProto.GetActiveMessagesResponse> Handle(GetActiveMessagesQuery request, CancellationToken cancellationToken)
|
||||
{
|
||||
var cmsRequest = new GetActiveMessagesRequest();
|
||||
var cmsRequest = new CmsProto.GetActiveMessagesRequest();
|
||||
|
||||
// نسخه فعلی CMS فیلدی برای فیلتر ندارد؛ در صورت اضافه شدن، اینجا مپ میشود.
|
||||
var cmsResponse = await _context.PublicMessages.GetActiveMessagesAsync(cmsRequest, cancellationToken: cancellationToken);
|
||||
|
||||
var result = new GetActiveMessagesResponse();
|
||||
var result = new BffProto.GetActiveMessagesResponse();
|
||||
|
||||
foreach (var message in cmsResponse.Messages)
|
||||
{
|
||||
result.Messages.Add(new PublicMessageDto
|
||||
result.Messages.Add(new BffProto.PublicMessageDto
|
||||
{
|
||||
MessageId = message.Id,
|
||||
Title = message.Title,
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
// GetAllMessages - Admin view
|
||||
using BackOffice.BFF.Application.Common.Interfaces;
|
||||
using BackOffice.BFF.PublicMessage.Protobuf;
|
||||
using CMSMicroservice.Protobuf.Protos;
|
||||
using Google.Protobuf.WellKnownTypes;
|
||||
using MediatR;
|
||||
using BffProto = BackOffice.BFF.PublicMessage.Protobuf;
|
||||
using CmsProto = CMSMicroservice.Protobuf.Protos;
|
||||
|
||||
namespace BackOffice.BFF.Application.PublicMessageCQ.Queries.GetAllMessages;
|
||||
|
||||
public record GetAllMessagesQuery : IRequest<GetAllMessagesResponse>
|
||||
public record GetAllMessagesQuery : IRequest<BffProto.GetAllMessagesResponse>
|
||||
{
|
||||
public int? Status { get; init; }
|
||||
public int? MessageType { get; init; }
|
||||
@@ -15,7 +15,7 @@ public record GetAllMessagesQuery : IRequest<GetAllMessagesResponse>
|
||||
public int PageSize { get; init; }
|
||||
}
|
||||
|
||||
public class GetAllMessagesQueryHandler : IRequestHandler<GetAllMessagesQuery, GetAllMessagesResponse>
|
||||
public class GetAllMessagesQueryHandler : IRequestHandler<GetAllMessagesQuery, BffProto.GetAllMessagesResponse>
|
||||
{
|
||||
private readonly IApplicationContractContext _context;
|
||||
|
||||
@@ -24,9 +24,9 @@ public class GetAllMessagesQueryHandler : IRequestHandler<GetAllMessagesQuery, G
|
||||
_context = context;
|
||||
}
|
||||
|
||||
public async Task<GetAllMessagesResponse> Handle(GetAllMessagesQuery request, CancellationToken cancellationToken)
|
||||
public async Task<BffProto.GetAllMessagesResponse> Handle(GetAllMessagesQuery request, CancellationToken cancellationToken)
|
||||
{
|
||||
var cmsRequest = new GetAllMessagesRequest
|
||||
var cmsRequest = new CmsProto.GetAllMessagesRequest
|
||||
{
|
||||
PageNumber = request.PageNumber,
|
||||
PageSize = request.PageSize
|
||||
@@ -44,7 +44,7 @@ public class GetAllMessagesQueryHandler : IRequestHandler<GetAllMessagesQuery, G
|
||||
|
||||
var cmsResponse = await _context.PublicMessages.GetAllMessagesAsync(cmsRequest, cancellationToken: cancellationToken);
|
||||
|
||||
var result = new GetAllMessagesResponse
|
||||
var result = new BffProto.GetAllMessagesResponse
|
||||
{
|
||||
TotalCount = (int)cmsResponse.MetaData.TotalCount,
|
||||
PageNumber = request.PageNumber,
|
||||
@@ -53,7 +53,7 @@ public class GetAllMessagesQueryHandler : IRequestHandler<GetAllMessagesQuery, G
|
||||
|
||||
foreach (var message in cmsResponse.Messages)
|
||||
{
|
||||
result.Messages.Add(new AdminPublicMessageDto
|
||||
result.Messages.Add(new BffProto.AdminPublicMessageDto
|
||||
{
|
||||
MessageId = message.Id,
|
||||
Title = message.Title,
|
||||
|
||||
Reference in New Issue
Block a user