You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

60 lines
1.4 KiB
C#

using System.ComponentModel.DataAnnotations;
using DS.Module.Core.Extensions;
namespace DS.Module.Core.Data;
/// <summary>
/// id实体
/// </summary>
public class IdModel : IValidatableObject
{
/// <summary>
/// 主键id
/// </summary>
public string? Id { get; set; }
/// <summary>
/// 主键ids
/// </summary>
public long[] Ids { get; set; }
/// <summary>
/// 业务类型1、海运出口 2、海运进口
/// </summary>
public int? BusinessType { get; set; }
/// <summary>
/// 请求值
/// </summary>
public object? Value { get; set; }
/// <summary>
/// 备注
/// </summary>
public string? Remark { get; set; }
/// <summary>
/// 确定当前对象是否有效
/// </summary>
/// <param name="validationContext">验证上下文</param>
/// <returns></returns>
public IEnumerable<ValidationResult> Validate(ValidationContext validationContext)
{
if (Id.IsNullOrEmpty() && (Ids == null || Ids.Length == 0))
{
yield return new ValidationResult($"未指定 {nameof(Ids)},参数无效");
}
}
}
/// <summary>
/// ID实体的泛型版本
/// </summary>
/// <typeparam name="T">请求值的类型</typeparam>
public class IdModel<T> : IdModel
{
/// <summary>
/// 请求值
/// </summary>
public new T? Value { get; set; }
}