feat: tenant门店管理首批接口落地
All checks were successful
Build and Deploy TenantApi / build-and-deploy (push) Successful in 30s
All checks were successful
Build and Deploy TenantApi / build-and-deploy (push) Successful in 30s
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
using FluentValidation;
|
||||
using TakeoutSaaS.Application.App.Stores.Commands;
|
||||
|
||||
namespace TakeoutSaaS.Application.App.Stores.Validators;
|
||||
|
||||
/// <summary>
|
||||
/// 创建门店命令验证器。
|
||||
/// </summary>
|
||||
public sealed class CreateStoreCommandValidator : AbstractValidator<CreateStoreCommand>
|
||||
{
|
||||
/// <summary>
|
||||
/// 初始化验证规则。
|
||||
/// </summary>
|
||||
public CreateStoreCommandValidator()
|
||||
{
|
||||
// 1. 校验核心字段
|
||||
RuleFor(command => command.Name).NotEmpty().MaximumLength(128);
|
||||
RuleFor(command => command.Code).NotEmpty().MaximumLength(32);
|
||||
RuleFor(command => command.ContactPhone).NotEmpty().MaximumLength(32);
|
||||
RuleFor(command => command.ManagerName).NotEmpty().MaximumLength(64);
|
||||
RuleFor(command => command.Address).NotEmpty().MaximumLength(256);
|
||||
|
||||
// 2. 校验可选字段
|
||||
RuleFor(command => command.CoverImage).MaximumLength(500);
|
||||
RuleFor(command => command.BusinessStatus).IsInEnum().When(command => command.BusinessStatus.HasValue);
|
||||
|
||||
// 3. 校验服务方式列表
|
||||
RuleForEach(command => command.ServiceTypes).IsInEnum();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
using FluentValidation;
|
||||
using TakeoutSaaS.Application.App.Stores.Commands;
|
||||
|
||||
namespace TakeoutSaaS.Application.App.Stores.Validators;
|
||||
|
||||
/// <summary>
|
||||
/// 删除门店命令验证器。
|
||||
/// </summary>
|
||||
public sealed class DeleteStoreCommandValidator : AbstractValidator<DeleteStoreCommand>
|
||||
{
|
||||
/// <summary>
|
||||
/// 初始化验证规则。
|
||||
/// </summary>
|
||||
public DeleteStoreCommandValidator()
|
||||
{
|
||||
// 1. 校验门店标识
|
||||
RuleFor(command => command.Id).GreaterThan(0);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
using FluentValidation;
|
||||
using TakeoutSaaS.Application.App.Stores.Queries;
|
||||
|
||||
namespace TakeoutSaaS.Application.App.Stores.Validators;
|
||||
|
||||
/// <summary>
|
||||
/// 门店列表查询验证器。
|
||||
/// </summary>
|
||||
public sealed class SearchStoresQueryValidator : AbstractValidator<SearchStoresQuery>
|
||||
{
|
||||
/// <summary>
|
||||
/// 初始化验证规则。
|
||||
/// </summary>
|
||||
public SearchStoresQueryValidator()
|
||||
{
|
||||
// 1. 校验分页参数
|
||||
RuleFor(query => query.Page).GreaterThan(0);
|
||||
RuleFor(query => query.PageSize).InclusiveBetween(1, 200);
|
||||
|
||||
// 2. 校验字符串长度
|
||||
RuleFor(query => query.Keyword).MaximumLength(64);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
using FluentValidation;
|
||||
using TakeoutSaaS.Application.App.Stores.Commands;
|
||||
|
||||
namespace TakeoutSaaS.Application.App.Stores.Validators;
|
||||
|
||||
/// <summary>
|
||||
/// 更新门店命令验证器。
|
||||
/// </summary>
|
||||
public sealed class UpdateStoreCommandValidator : AbstractValidator<UpdateStoreCommand>
|
||||
{
|
||||
/// <summary>
|
||||
/// 初始化验证规则。
|
||||
/// </summary>
|
||||
public UpdateStoreCommandValidator()
|
||||
{
|
||||
// 1. 校验标识与核心字段
|
||||
RuleFor(command => command.Id).GreaterThan(0);
|
||||
RuleFor(command => command.Name).NotEmpty().MaximumLength(128);
|
||||
RuleFor(command => command.Code).NotEmpty().MaximumLength(32);
|
||||
RuleFor(command => command.ContactPhone).NotEmpty().MaximumLength(32);
|
||||
RuleFor(command => command.ManagerName).NotEmpty().MaximumLength(64);
|
||||
RuleFor(command => command.Address).NotEmpty().MaximumLength(256);
|
||||
|
||||
// 2. 校验可选字段
|
||||
RuleFor(command => command.CoverImage).MaximumLength(500);
|
||||
RuleFor(command => command.BusinessStatus).IsInEnum().When(command => command.BusinessStatus.HasValue);
|
||||
|
||||
// 3. 校验服务方式列表
|
||||
RuleForEach(command => command.ServiceTypes).IsInEnum();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user