feat: add Configuration gRPC service and queries for club settings and features
This commit is contained in:
+6
@@ -0,0 +1,6 @@
|
||||
namespace FrontOffice.BFF.Application.ConfigurationCQ.Queries.GetClubConfiguration;
|
||||
|
||||
/// <summary>
|
||||
/// دریافت تنظیمات باشگاه مشتریان
|
||||
/// </summary>
|
||||
public record GetClubConfigurationQuery : IRequest<GetClubConfigurationResponseDto>;
|
||||
+43
@@ -0,0 +1,43 @@
|
||||
using CMSMicroservice.Protobuf.Protos.Configuration;
|
||||
|
||||
namespace FrontOffice.BFF.Application.ConfigurationCQ.Queries.GetClubConfiguration;
|
||||
|
||||
/// <summary>
|
||||
/// هندلر دریافت تنظیمات باشگاه مشتریان از CMS
|
||||
/// </summary>
|
||||
public class GetClubConfigurationQueryHandler : IRequestHandler<GetClubConfigurationQuery, GetClubConfigurationResponseDto>
|
||||
{
|
||||
private readonly IApplicationContractContext _context;
|
||||
|
||||
public GetClubConfigurationQueryHandler(IApplicationContractContext context)
|
||||
{
|
||||
_context = context;
|
||||
}
|
||||
|
||||
public async Task<GetClubConfigurationResponseDto> Handle(GetClubConfigurationQuery request, CancellationToken cancellationToken)
|
||||
{
|
||||
// دریافت مبلغ فعالسازی از CMS
|
||||
var activationFeeRequest = new GetConfigurationByKeyRequest
|
||||
{
|
||||
Scope = 2, // ConfigurationScope.Club
|
||||
Key = "Club.ActivationFee"
|
||||
};
|
||||
|
||||
var giftValueRequest = new GetConfigurationByKeyRequest
|
||||
{
|
||||
Scope = 2, // ConfigurationScope.Club
|
||||
Key = "Club.MembershipGiftValue"
|
||||
};
|
||||
|
||||
var activationFeeResponse = await _context.Configuration.GetConfigurationByKeyAsync(activationFeeRequest, cancellationToken: cancellationToken);
|
||||
var giftValueResponse = await _context.Configuration.GetConfigurationByKeyAsync(giftValueRequest, cancellationToken: cancellationToken);
|
||||
|
||||
var response = new GetClubConfigurationResponseDto
|
||||
{
|
||||
ActivationFee = long.TryParse(activationFeeResponse?.Value, out var fee) ? fee : 25000000,
|
||||
MembershipGiftValue = long.TryParse(giftValueResponse?.Value, out var gift) ? gift : 25200000
|
||||
};
|
||||
|
||||
return response;
|
||||
}
|
||||
}
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
namespace FrontOffice.BFF.Application.ConfigurationCQ.Queries.GetClubConfiguration;
|
||||
|
||||
/// <summary>
|
||||
/// پاسخ تنظیمات باشگاه مشتریان
|
||||
/// </summary>
|
||||
public class GetClubConfigurationResponseDto
|
||||
{
|
||||
/// <summary>
|
||||
/// هزینه فعالسازی عضویت باشگاه (ریال)
|
||||
/// </summary>
|
||||
public long ActivationFee { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// مبلغ هدیه حق عضویت باشگاه (ریال)
|
||||
/// </summary>
|
||||
public long MembershipGiftValue { get; set; }
|
||||
}
|
||||
Reference in New Issue
Block a user