You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
59 lines
1.6 KiB
59 lines
1.6 KiB
using FluentValidation;
|
|
using FluentValidation.Results;
|
|
using Kean.Infrastructure.Configuration;
|
|
|
|
namespace Kean.Domain.Material.Commands
|
|
{
|
|
/// <summary>
|
|
/// 创建物料命令
|
|
/// </summary>
|
|
public class CreateMaterialCommand : MaterialProperty, ICommand
|
|
{
|
|
/// <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<CreateMaterialCommand>
|
|
{
|
|
/// <summary>
|
|
/// 初始化 Kean.Domain.Material.Commands.CreateMaterialCommand.Validator 类的新实例
|
|
/// </summary>
|
|
internal Validator()
|
|
{
|
|
RuleFor(r => r.Code).NotEmpty().WithMessage("料号不允许空");
|
|
RuleFor(r => r.Name).NotEmpty().WithMessage("名称不允许空");
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 验证结果
|
|
/// </summary>
|
|
public ValidationResult ValidationResult => new Validator().Validate(this);
|
|
|
|
/// <summary>
|
|
/// 标识
|
|
/// </summary>
|
|
[Output]
|
|
public int Id { get; private set; }
|
|
}
|
|
}
|