Implement pricing management functionality and update related components
- Added new endpoints for managing global pricing settings, including retrieval and updates for `PricePerConfigPerQuarter` and `PricePerConfigPerYear`. - Updated `RoleService` and related commands to remove pricing fields from role management, ensuring a clear separation between role configurations and global pricing. - Enhanced the `FactoryResetCommandHandler` to include seeding of pricing settings during a factory reset. - Modified frontend components to support new pricing settings, including forms for creating and updating pricing information. - Updated API documentation to reflect changes in pricing management endpoints and their expected request/response formats. - Adjusted tests to ensure proper coverage for new pricing functionalities and their integration with existing role management features.
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
using PnvPanel.Api.Common;
|
||||
using PnvPanel.Application.Admin.Pricing;
|
||||
using PnvPanel.Application.Common.Messaging;
|
||||
using PnvPanel.Infrastructure.Identity;
|
||||
|
||||
namespace PnvPanel.Api.Endpoints;
|
||||
|
||||
public static class AdminPricingEndpoints
|
||||
{
|
||||
public static IEndpointRouteBuilder MapAdminPricingEndpoints(this IEndpointRouteBuilder app)
|
||||
{
|
||||
var admin = app.MapGroup("/api/admin/pricing")
|
||||
.WithTags("Admin.Pricing")
|
||||
.RequireAuthorization(policy => policy.RequireRole(RoleNames.Admin));
|
||||
|
||||
admin.MapGet("", GetPricing).Produces<PricingSettingsDto>();
|
||||
admin.MapPut("", UpdatePricing).Produces<PricingSettingsDto>();
|
||||
|
||||
return app;
|
||||
}
|
||||
|
||||
private static async Task<IResult> GetPricing(ISender sender, CancellationToken cancellationToken)
|
||||
{
|
||||
var result = await sender.Send(new GetPricingSettingsQuery(), cancellationToken);
|
||||
return result.ToHttpResult();
|
||||
}
|
||||
|
||||
private static async Task<IResult> UpdatePricing(
|
||||
UpdatePricingSettingsCommand command,
|
||||
ISender sender,
|
||||
CancellationToken cancellationToken
|
||||
)
|
||||
{
|
||||
var result = await sender.Send(command, cancellationToken);
|
||||
return result.ToHttpResult();
|
||||
}
|
||||
}
|
||||
@@ -53,13 +53,7 @@ public static class RoleEndpoints
|
||||
)
|
||||
{
|
||||
var result = await sender.Send(
|
||||
new UpdateRoleCommand(
|
||||
id,
|
||||
body.MaxConfigs,
|
||||
body.MaxIpLimit,
|
||||
body.PricePerConfigPerQuarter,
|
||||
body.PricePerConfigPerYear
|
||||
),
|
||||
new UpdateRoleCommand(id, body.MaxConfigs, body.MaxIpLimit),
|
||||
cancellationToken
|
||||
);
|
||||
return result.ToHttpResult();
|
||||
@@ -90,11 +84,6 @@ public static class RoleEndpoints
|
||||
}
|
||||
}
|
||||
|
||||
public sealed record UpdateRoleBody(
|
||||
int MaxConfigs,
|
||||
int MaxIpLimit,
|
||||
int? PricePerConfigPerQuarter,
|
||||
int? PricePerConfigPerYear
|
||||
);
|
||||
public sealed record UpdateRoleBody(int MaxConfigs, int MaxIpLimit);
|
||||
|
||||
public sealed record ChangeUserRoleBody(Guid RoleId);
|
||||
|
||||
@@ -22,7 +22,7 @@ public static class SupportEndpoints
|
||||
{
|
||||
var group = app.MapGroup("/api/support").WithTags("Support").RequireAuthorization();
|
||||
|
||||
group.MapGet("/roles", ListSelectableRoles).Produces<IReadOnlyList<SelectableRoleDto>>();
|
||||
group.MapGet("/roles", ListSelectableRoles).Produces<IReadOnlyList<RoleDto>>();
|
||||
group
|
||||
.MapPost("/tickets/bug-reports", CreateBugReport)
|
||||
.DisableAntiforgery()
|
||||
|
||||
@@ -191,6 +191,7 @@ app.MapAdminStatsEndpoints();
|
||||
app.MapAdminAppEndpoints();
|
||||
app.MapAdminNewsEndpoints();
|
||||
app.MapAdminInstructionEndpoints();
|
||||
app.MapAdminPricingEndpoints();
|
||||
app.MapSupportEndpoints();
|
||||
app.MapAdminSupportEndpoints();
|
||||
app.MapAdminMaintenanceEndpoints();
|
||||
|
||||
Reference in New Issue
Block a user