- Added new configuration options for user plans in `.env.example`, including `Plans__MaxCustomConfigCount` and `Plans__MinCustomConfigCount`. - Introduced `MapPlanEndpoints` in `Program.cs` to handle plan-related API routes. - Implemented `SetUserPlan` endpoint in `RoleEndpoints` to allow admins to assign plans to users. - Removed deprecated role request approval endpoints from `AdminSupportEndpoints`. - Updated `ITelegramNotifier` and related classes to reflect changes in role request handling and payment notifications. - Refactored role management commands to remove `MaxConfigs` and focus on `MaxIpLimit` and billing settings. - Enhanced billing request handling to accommodate plan changes instead of role changes. - Updated various interfaces and command handlers to support new plan management features.
24 lines
862 B
C#
24 lines
862 B
C#
using FluentValidation;
|
|
using Microsoft.Extensions.Options;
|
|
|
|
namespace PnvPanel.Application.Plans;
|
|
|
|
public sealed class ChangePlanCommandValidator : AbstractValidator<ChangePlanCommand>
|
|
{
|
|
public ChangePlanCommandValidator(IOptions<PlansOptions> plansOptions)
|
|
{
|
|
RuleFor(x => x)
|
|
.Must(x => x.PlanId.HasValue ^ x.CustomConfigCount.HasValue)
|
|
.WithMessage("Укажите либо PlanId, либо CustomConfigCount — ровно одно из двух.");
|
|
|
|
When(
|
|
x => x.CustomConfigCount.HasValue,
|
|
() =>
|
|
RuleFor(x => x.CustomConfigCount!.Value)
|
|
.InclusiveBetween(plansOptions.Value.MinCustomConfigCount, plansOptions.Value.MaxCustomConfigCount)
|
|
);
|
|
|
|
RuleFor(x => x.ConfigIdsToRevoke).Must(ids => ids.Distinct().Count() == ids.Count);
|
|
}
|
|
}
|