using NetAdmin.Domain.Enums.Sys;
using HttpMethods = NetAdmin.Domain.Enums.HttpMethods;
namespace NetAdmin.Domain.Dto.Sys.Job;
///
/// 请求:创建计划作业
///
public record CreateJobReq : Sys_Job
{
///
[JsonIgnore(Condition = JsonIgnoreCondition.Never)]
public override bool Enabled { get; init; } = true;
///
[Cron]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
[Required(ErrorMessageResourceType = typeof(Ln), ErrorMessageResourceName = nameof(Ln.时间计划不能为空))]
public override string ExecutionCron { get; init; }
///
[EnumDataType(typeof(HttpMethods), ErrorMessageResourceType = typeof(Ln)
, ErrorMessageResourceName = nameof(Ln.请求方法不正确))]
[JsonIgnore(Condition = JsonIgnoreCondition.Never)]
public override HttpMethods HttpMethod { get; init; }
///
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
[Required(ErrorMessageResourceType = typeof(Ln), ErrorMessageResourceName = nameof(Ln.作业名称不能为空))]
public override string JobName { get; init; }
///
public override long? NextTimeId { get; init; }
///
[Range(1, int.MaxValue, ErrorMessageResourceType = typeof(Ln), ErrorMessageResourceName = nameof(Ln.随机延时起始时间不正确))]
public override int? RandomDelayBegin { get; init; }
///
[Range(1, int.MaxValue, ErrorMessageResourceType = typeof(Ln), ErrorMessageResourceName = nameof(Ln.随机延时结束时间不正确))]
public override int? RandomDelayEnd { get; init; }
///
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public override string RequestBody { get; init; }
///
/// 请求头
///
public Dictionary RequestHeaders { get; init; }
///
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
[Required(ErrorMessageResourceType = typeof(Ln), ErrorMessageResourceName = nameof(Ln.请求地址不能为空))]
[Url(ErrorMessageResourceType = typeof(Ln), ErrorMessageResourceName = nameof(Ln.网络地址不正确))]
public override string RequestUrl { get; init; }
///
public override JobStatues Status { get; init; } = JobStatues.Idle;
///
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public override string Summary { get; init; }
///
[JsonIgnore(Condition = JsonIgnoreCondition.Never)]
[Range(1, long.MaxValue, ErrorMessageResourceType = typeof(Ln), ErrorMessageResourceName = nameof(Ln.用户编号不存在))]
[UserId]
public override long UserId { get; init; }
}