- 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.
38 lines
1.6 KiB
C#
38 lines
1.6 KiB
C#
using PnvPanel.Application.Auth;
|
|
using PnvPanel.Application.Common.Interfaces;
|
|
using PnvPanel.Application.Common.Messaging;
|
|
using PnvPanel.Application.Common.Models;
|
|
|
|
namespace PnvPanel.Application.Support.ListSelectableRoles;
|
|
|
|
public sealed class ListSelectableRolesQueryHandler(
|
|
IRoleService roleService,
|
|
IIdentityService identityService,
|
|
ICurrentUser currentUser
|
|
) : IQueryHandler<ListSelectableRolesQuery, Result<IReadOnlyList<RoleDto>>>
|
|
{
|
|
// Совпадает со значением Infrastructure.Identity.RoleNames.Admin — см. пояснение в
|
|
// CreateRoleRequestTicketCommandHandler (Application не может ссылаться на Infrastructure).
|
|
private const string AdminRoleName = "admin";
|
|
|
|
public async Task<Result<IReadOnlyList<RoleDto>>> Handle(
|
|
ListSelectableRolesQuery query,
|
|
CancellationToken cancellationToken
|
|
)
|
|
{
|
|
if (currentUser.UserId is not { } userId)
|
|
return Result.Failure<IReadOnlyList<RoleDto>>(AuthErrors.Unauthorized);
|
|
|
|
var profile = await identityService.GetProfileAsync(userId, cancellationToken);
|
|
var roles = await roleService.ListRolesAsync(cancellationToken);
|
|
|
|
// Без admin (нельзя запросить) и без текущей роли пользователя (уже есть — нечего запрашивать).
|
|
var selectable = roles
|
|
.Where(r => !r.Name.Equals(AdminRoleName, StringComparison.OrdinalIgnoreCase))
|
|
.Where(r => profile is null || r.Id != profile.RoleId)
|
|
.ToList();
|
|
|
|
return Result.Success<IReadOnlyList<RoleDto>>(selectable);
|
|
}
|
|
}
|