feat: 完成门店子资源管理与文档同步

This commit is contained in:
2025-12-04 08:38:31 +08:00
parent 17d143a351
commit 9051a024ea
45 changed files with 1671 additions and 3 deletions

View File

@@ -0,0 +1,21 @@
using FluentValidation;
using TakeoutSaaS.Application.App.Stores.Commands;
namespace TakeoutSaaS.Application.App.Stores.Validators;
/// <summary>
/// 创建营业时段命令验证器。
/// </summary>
public sealed class CreateStoreBusinessHourCommandValidator : AbstractValidator<CreateStoreBusinessHourCommand>
{
/// <summary>
/// 初始化验证规则。
/// </summary>
public CreateStoreBusinessHourCommandValidator()
{
RuleFor(x => x.StoreId).GreaterThan(0);
RuleFor(x => x.StartTime).LessThan(x => x.EndTime).WithMessage("结束时间必须晚于开始时间");
RuleFor(x => x.CapacityLimit).GreaterThanOrEqualTo(0).When(x => x.CapacityLimit.HasValue);
RuleFor(x => x.Notes).MaximumLength(256);
}
}

View File

@@ -0,0 +1,24 @@
using FluentValidation;
using TakeoutSaaS.Application.App.Stores.Commands;
namespace TakeoutSaaS.Application.App.Stores.Validators;
/// <summary>
/// 创建配送区域命令验证器。
/// </summary>
public sealed class CreateStoreDeliveryZoneCommandValidator : AbstractValidator<CreateStoreDeliveryZoneCommand>
{
/// <summary>
/// 初始化验证规则。
/// </summary>
public CreateStoreDeliveryZoneCommandValidator()
{
RuleFor(x => x.StoreId).GreaterThan(0);
RuleFor(x => x.ZoneName).NotEmpty().MaximumLength(64);
RuleFor(x => x.PolygonGeoJson).NotEmpty();
RuleFor(x => x.MinimumOrderAmount).GreaterThanOrEqualTo(0).When(x => x.MinimumOrderAmount.HasValue);
RuleFor(x => x.DeliveryFee).GreaterThanOrEqualTo(0).When(x => x.DeliveryFee.HasValue);
RuleFor(x => x.EstimatedMinutes).GreaterThan(0).When(x => x.EstimatedMinutes.HasValue);
RuleFor(x => x.SortOrder).GreaterThanOrEqualTo(0);
}
}

View File

@@ -0,0 +1,20 @@
using FluentValidation;
using TakeoutSaaS.Application.App.Stores.Commands;
namespace TakeoutSaaS.Application.App.Stores.Validators;
/// <summary>
/// 创建节假日命令验证器。
/// </summary>
public sealed class CreateStoreHolidayCommandValidator : AbstractValidator<CreateStoreHolidayCommand>
{
/// <summary>
/// 初始化验证规则。
/// </summary>
public CreateStoreHolidayCommandValidator()
{
RuleFor(x => x.StoreId).GreaterThan(0);
RuleFor(x => x.Date).NotEmpty();
RuleFor(x => x.Reason).MaximumLength(256);
}
}

View File

@@ -0,0 +1,22 @@
using FluentValidation;
using TakeoutSaaS.Application.App.Stores.Commands;
namespace TakeoutSaaS.Application.App.Stores.Validators;
/// <summary>
/// 更新营业时段命令验证器。
/// </summary>
public sealed class UpdateStoreBusinessHourCommandValidator : AbstractValidator<UpdateStoreBusinessHourCommand>
{
/// <summary>
/// 初始化验证规则。
/// </summary>
public UpdateStoreBusinessHourCommandValidator()
{
RuleFor(x => x.BusinessHourId).GreaterThan(0);
RuleFor(x => x.StoreId).GreaterThan(0);
RuleFor(x => x.StartTime).LessThan(x => x.EndTime).WithMessage("结束时间必须晚于开始时间");
RuleFor(x => x.CapacityLimit).GreaterThanOrEqualTo(0).When(x => x.CapacityLimit.HasValue);
RuleFor(x => x.Notes).MaximumLength(256);
}
}

View File

@@ -0,0 +1,25 @@
using FluentValidation;
using TakeoutSaaS.Application.App.Stores.Commands;
namespace TakeoutSaaS.Application.App.Stores.Validators;
/// <summary>
/// 更新配送区域命令验证器。
/// </summary>
public sealed class UpdateStoreDeliveryZoneCommandValidator : AbstractValidator<UpdateStoreDeliveryZoneCommand>
{
/// <summary>
/// 初始化验证规则。
/// </summary>
public UpdateStoreDeliveryZoneCommandValidator()
{
RuleFor(x => x.DeliveryZoneId).GreaterThan(0);
RuleFor(x => x.StoreId).GreaterThan(0);
RuleFor(x => x.ZoneName).NotEmpty().MaximumLength(64);
RuleFor(x => x.PolygonGeoJson).NotEmpty();
RuleFor(x => x.MinimumOrderAmount).GreaterThanOrEqualTo(0).When(x => x.MinimumOrderAmount.HasValue);
RuleFor(x => x.DeliveryFee).GreaterThanOrEqualTo(0).When(x => x.DeliveryFee.HasValue);
RuleFor(x => x.EstimatedMinutes).GreaterThan(0).When(x => x.EstimatedMinutes.HasValue);
RuleFor(x => x.SortOrder).GreaterThanOrEqualTo(0);
}
}

View File

@@ -0,0 +1,21 @@
using FluentValidation;
using TakeoutSaaS.Application.App.Stores.Commands;
namespace TakeoutSaaS.Application.App.Stores.Validators;
/// <summary>
/// 更新节假日命令验证器。
/// </summary>
public sealed class UpdateStoreHolidayCommandValidator : AbstractValidator<UpdateStoreHolidayCommand>
{
/// <summary>
/// 初始化验证规则。
/// </summary>
public UpdateStoreHolidayCommandValidator()
{
RuleFor(x => x.HolidayId).GreaterThan(0);
RuleFor(x => x.StoreId).GreaterThan(0);
RuleFor(x => x.Date).NotEmpty();
RuleFor(x => x.Reason).MaximumLength(256);
}
}