feat: 系统参数应用层与验证
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
using FluentValidation;
|
||||
using TakeoutSaaS.Application.App.SystemParameters.Commands;
|
||||
|
||||
namespace TakeoutSaaS.Application.App.SystemParameters.Validators;
|
||||
|
||||
/// <summary>
|
||||
/// 创建系统参数命令验证器。
|
||||
/// </summary>
|
||||
public sealed class CreateSystemParameterCommandValidator : AbstractValidator<CreateSystemParameterCommand>
|
||||
{
|
||||
/// <summary>
|
||||
/// 初始化验证规则。
|
||||
/// </summary>
|
||||
public CreateSystemParameterCommandValidator()
|
||||
{
|
||||
RuleFor(x => x.Key).NotEmpty().MaximumLength(128);
|
||||
RuleFor(x => x.Value).NotEmpty();
|
||||
RuleFor(x => x.Description).MaximumLength(512);
|
||||
RuleFor(x => x.SortOrder).GreaterThanOrEqualTo(0);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
using FluentValidation;
|
||||
using TakeoutSaaS.Application.App.SystemParameters.Queries;
|
||||
|
||||
namespace TakeoutSaaS.Application.App.SystemParameters.Validators;
|
||||
|
||||
/// <summary>
|
||||
/// 系统参数列表查询验证器。
|
||||
/// </summary>
|
||||
public sealed class SearchSystemParametersQueryValidator : AbstractValidator<SearchSystemParametersQuery>
|
||||
{
|
||||
/// <summary>
|
||||
/// 初始化验证规则。
|
||||
/// </summary>
|
||||
public SearchSystemParametersQueryValidator()
|
||||
{
|
||||
RuleFor(x => x.Page).GreaterThan(0);
|
||||
RuleFor(x => x.PageSize).InclusiveBetween(1, 200);
|
||||
RuleFor(x => x.Keyword).MaximumLength(256);
|
||||
RuleFor(x => x.SortBy).MaximumLength(64);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
using FluentValidation;
|
||||
using TakeoutSaaS.Application.App.SystemParameters.Commands;
|
||||
|
||||
namespace TakeoutSaaS.Application.App.SystemParameters.Validators;
|
||||
|
||||
/// <summary>
|
||||
/// 更新系统参数命令验证器。
|
||||
/// </summary>
|
||||
public sealed class UpdateSystemParameterCommandValidator : AbstractValidator<UpdateSystemParameterCommand>
|
||||
{
|
||||
/// <summary>
|
||||
/// 初始化验证规则。
|
||||
/// </summary>
|
||||
public UpdateSystemParameterCommandValidator()
|
||||
{
|
||||
RuleFor(x => x.ParameterId).GreaterThan(0);
|
||||
RuleFor(x => x.Key).NotEmpty().MaximumLength(128);
|
||||
RuleFor(x => x.Value).NotEmpty();
|
||||
RuleFor(x => x.Description).MaximumLength(512);
|
||||
RuleFor(x => x.SortOrder).GreaterThanOrEqualTo(0);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user