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.4 KiB
59 lines
1.4 KiB
using Kean.Domain;
|
|
|
|
namespace Kean.Application.Command.ViewModels
|
|
{
|
|
/// <summary>
|
|
/// 失败信息
|
|
/// </summary>
|
|
public sealed class Failure
|
|
{
|
|
/// <summary>
|
|
/// 根据 FluentValidation.Results.ValidationFailure 创建实例
|
|
/// </summary>
|
|
public static implicit operator Failure(NotificationEvent @event)
|
|
{
|
|
if (@event == null)
|
|
{
|
|
return null;
|
|
}
|
|
else
|
|
{
|
|
return new()
|
|
{
|
|
ErrorCode = @event.ErrorCode,
|
|
ErrorMessage = @event.ErrorMessage,
|
|
PropertyName = @event.PropertyName,
|
|
AttemptedValue = @event.AttemptedValue
|
|
};
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 消息码
|
|
/// </summary>
|
|
public object ErrorCode { get; set; }
|
|
|
|
/// <summary>
|
|
/// 消息内容
|
|
/// </summary>
|
|
public string ErrorMessage { get; set; }
|
|
|
|
/// <summary>
|
|
/// 属性名
|
|
/// </summary>
|
|
public string PropertyName { get; set; }
|
|
|
|
/// <summary>
|
|
/// 属性值
|
|
/// </summary>
|
|
public object AttemptedValue { get; set; }
|
|
|
|
/*
|
|
* 重写 ToString 方法
|
|
*/
|
|
public override string ToString()
|
|
{
|
|
return $"{ErrorMessage}({PropertyName}:{AttemptedValue})";
|
|
}
|
|
}
|
|
}
|