60 lines
1.7 KiB
60 lines
1.7 KiB
3 months ago
|
using FluentValidation;
|
||
|
using FluentValidation.Results;
|
||
|
using Kean.Infrastructure.Configuration;
|
||
|
|
||
|
namespace Kean.Domain.Material.Commands
|
||
|
{
|
||
|
/// <summary>
|
||
|
/// 修改物料命令
|
||
|
/// </summary>
|
||
|
public class ModifyMaterialCommand : MaterialProperty, ICommand
|
||
|
{
|
||
|
/// <summary>
|
||
|
/// 标识
|
||
|
/// </summary>
|
||
|
public int Id { get; set; }
|
||
|
|
||
|
/// <summary>
|
||
|
/// 品类
|
||
|
/// </summary>
|
||
|
public int? Category { get; set; }
|
||
|
|
||
|
/// <summary>
|
||
|
/// 物料组
|
||
|
/// </summary>
|
||
|
public string Group { get; set; }
|
||
|
|
||
|
/// <summary>
|
||
|
/// 料号
|
||
|
/// </summary>
|
||
|
public string Code { get; set; }
|
||
|
|
||
|
/// <summary>
|
||
|
/// 名称
|
||
|
/// </summary>
|
||
|
public string Name { get; set; }
|
||
|
|
||
|
/// <summary>
|
||
|
/// 验证器
|
||
|
/// 由于命令需要继承 MaterialProperty,所以无法直接实现 CommandValidator
|
||
|
/// </summary>
|
||
|
internal class Validator : AbstractValidator<ModifyMaterialCommand>
|
||
|
{
|
||
|
/// <summary>
|
||
|
/// 初始化 Kean.Domain.Material.Commands.ModifyMaterialCommand.Validator 类的新实例
|
||
|
/// </summary>
|
||
|
internal Validator()
|
||
|
{
|
||
|
RuleFor(r => r.Id).NotEmpty().WithMessage("标识不允许空");
|
||
|
RuleFor(r => r.Code).NotEmpty().WithMessage("料号不允许空");
|
||
|
RuleFor(r => r.Name).NotEmpty().WithMessage("名称不允许空");
|
||
|
}
|
||
|
}
|
||
|
|
||
|
/// <summary>
|
||
|
/// 验证结果
|
||
|
/// </summary>
|
||
|
public ValidationResult ValidationResult => new Validator().Validate(this);
|
||
|
}
|
||
|
}
|