Refactor pricing endpoints and enhance support for pricing retrieval
- Added a new endpoint `/api/support/pricing` to allow users to retrieve pricing information, making it accessible for role request dialogs. - Introduced the `GetSupportPricing` method to handle pricing queries, ensuring that pricing data is available to non-admin users. - Updated frontend components to integrate the new pricing retrieval functionality, displaying estimated costs based on user-selected configurations. - Removed the `PricingSettingsDto` as it is no longer needed, streamlining the pricing data structure. - Enhanced API documentation to reflect the new endpoint and its usage in the support context.
This commit is contained in:
@@ -0,0 +1,9 @@
|
||||
using PnvPanel.Application.Common.Interfaces;
|
||||
using PnvPanel.Application.Common.Messaging;
|
||||
using PnvPanel.Application.Common.Models;
|
||||
|
||||
namespace PnvPanel.Application.Support.GetSupportPricing;
|
||||
|
||||
/// <summary>Справочная цена конфига для заявки на роль (не редактирование, только чтение) — в отличие
|
||||
/// от GetPricingSettingsQuery (Admin/Pricing), доступна любому активированному пользователю.</summary>
|
||||
public sealed record GetSupportPricingQuery : IQuery<Result<PricingSettingsDto>>, IRequiresActivation;
|
||||
+27
@@ -0,0 +1,27 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using PnvPanel.Application.Common.Interfaces;
|
||||
using PnvPanel.Application.Common.Messaging;
|
||||
using PnvPanel.Application.Common.Models;
|
||||
|
||||
namespace PnvPanel.Application.Support.GetSupportPricing;
|
||||
|
||||
public sealed class GetSupportPricingQueryHandler(IAppDbContext dbContext)
|
||||
: IQueryHandler<GetSupportPricingQuery, Result<PricingSettingsDto>>
|
||||
{
|
||||
public async Task<Result<PricingSettingsDto>> Handle(
|
||||
GetSupportPricingQuery query,
|
||||
CancellationToken cancellationToken
|
||||
)
|
||||
{
|
||||
var settings = await dbContext
|
||||
.PricingSettings.AsNoTracking()
|
||||
.FirstOrDefaultAsync(cancellationToken);
|
||||
|
||||
// Ещё не сидировано/не сохранено ни разу — цена не задана, а не ошибка.
|
||||
return Result.Success(
|
||||
settings is null
|
||||
? new PricingSettingsDto(null, null, null)
|
||||
: PricingSettingsDto.FromDomain(settings)
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user