213 lines
6.1 KiB
C#

using Newtonsoft.Json;
namespace YD_Event.Application.CitizenSports.Dtos;
/// <summary>
/// 市民运动会报名同步请求。
/// </summary>
public class CitizenSportsSyncInput
{
/// <summary>
/// 跃动系统赛事 ID。
/// </summary>
[Required]
public long EventId { get; set; }
/// <summary>
/// 市民运动会平台中的赛事名称,必须与一网通办申报名称一致。
/// </summary>
[Required]
public string PlatformEventName { get; set; } = string.Empty;
/// <summary>
/// 系列赛场次名称,没有时不传。
/// </summary>
public string? SeriesName { get; set; }
}
/// <summary>
/// 市民运动会报名执行同步请求。
/// </summary>
public class CitizenSportsExecuteInput : CitizenSportsSyncInput
{
/// <summary>
/// 必须明确确认后才允许向外部平台写入。
/// </summary>
public bool ConfirmUpload { get; set; }
}
/// <summary>
/// 同步预览结果,包含实际待上传的运动员明细。
/// </summary>
public class CitizenSportsPreviewOutput
{
public long EventId { get; set; }
public string EventName { get; set; } = string.Empty;
public string PlatformEventName { get; set; } = string.Empty;
public int RegistrationCount { get; set; }
public int UploadRecordCount { get; set; }
public int TypeCount { get; set; }
public bool CanUpload => Errors.Count == 0 && UploadRecordCount > 0;
public List<CitizenSportsTypePreview> Types { get; set; } = [];
public List<CitizenSportsPlayerPreview> Players { get; set; } = [];
public List<CitizenSportsValidationError> Errors { get; set; } = [];
}
public class CitizenSportsTypePreview
{
public string TypeName { get; set; } = string.Empty;
public int PlayerCount { get; set; }
}
/// <summary>
/// 实际发送给市民运动会平台的运动员数据。
/// </summary>
public class CitizenSportsPlayerPreview
{
public string TypeName { get; set; } = string.Empty;
public string PlayerId { get; set; } = string.Empty;
public string CardNumber { get; set; } = string.Empty;
public string CardType { get; set; } = string.Empty;
public string PlayerName { get; set; } = string.Empty;
public string? PlayerSex { get; set; }
public string? PlayerPhone { get; set; }
public string? PlayerBirth { get; set; }
public string? GroupName { get; set; }
}
public class CitizenSportsValidationError
{
public long RegistrationPersonId { get; set; }
public string Message { get; set; } = string.Empty;
}
public class CitizenSportsConnectionTestOutput
{
public bool Success { get; set; }
public string Message { get; set; } = string.Empty;
public long? PlatformTime { get; set; }
}
public class CitizenSportsExecuteOutput
{
public string PlatformEventCode { get; set; } = string.Empty;
public int RequestedCount { get; set; }
public int SuccessCount { get; set; }
public int FailureCount { get; set; }
public int UnattemptedCount { get; set; }
public bool Aborted { get; set; }
public List<CitizenSportsBatchResult> Batches { get; set; } = [];
}
public class CitizenSportsBatchResult
{
public string TypeName { get; set; } = string.Empty;
public int RequestedCount { get; set; }
public int SuccessCount { get; set; }
public int FailureCount { get; set; }
public bool Success { get; set; }
public string Message { get; set; } = string.Empty;
}
internal sealed class CitizenSportsGetCodeRequest
{
[JsonProperty("mname")]
public string EventName { get; set; } = string.Empty;
[JsonProperty("sname", NullValueHandling = NullValueHandling.Ignore)]
public string? SeriesName { get; set; }
}
internal sealed class CitizenSportsUploadRequest
{
[JsonProperty("mcode")]
public string EventCode { get; set; } = string.Empty;
[JsonProperty("typename")]
public string TypeName { get; set; } = string.Empty;
[JsonProperty("players")]
public List<CitizenSportsPlayer> Players { get; set; } = [];
}
internal sealed class CitizenSportsPlayer
{
[JsonProperty("playerId")]
public string PlayerId { get; set; } = string.Empty;
[JsonProperty("CardNumber")]
public string CardNumber { get; set; } = string.Empty;
[JsonProperty("CardType")]
public string CardType { get; set; } = string.Empty;
[JsonProperty("playerName")]
public string PlayerName { get; set; } = string.Empty;
[JsonProperty("playerSex", NullValueHandling = NullValueHandling.Ignore)]
public string? PlayerSex { get; set; }
[JsonProperty("playerPhone", NullValueHandling = NullValueHandling.Ignore)]
public string? PlayerPhone { get; set; }
[JsonProperty("playerBirth", NullValueHandling = NullValueHandling.Ignore)]
public string? PlayerBirth { get; set; }
[JsonProperty("groupName", NullValueHandling = NullValueHandling.Ignore)]
public string? GroupName { get; set; }
[JsonProperty("deleteStatus")]
public int DeleteStatus { get; set; } = 1;
}
internal sealed class CitizenSportsPlatformResponse<T>
{
[JsonProperty("code")]
public string? Code { get; set; }
[JsonProperty("status")]
public string? Status { get; set; }
[JsonProperty("message")]
public string? Message { get; set; }
[JsonProperty("msg")]
public string? Msg { get; set; }
[JsonProperty("data")]
public T? Data { get; set; }
[JsonProperty("sys_time")]
public long? SystemTime { get; set; }
[JsonIgnore]
public bool IsSuccess => Code == "200" && string.Equals(Status, "success", StringComparison.OrdinalIgnoreCase);
[JsonIgnore]
public string EffectiveMessage => Message ?? Msg ?? "平台未返回说明";
}
internal sealed class CitizenSportsTestData
{
[JsonProperty("Test")]
public string? Test { get; set; }
}
internal sealed class CitizenSportsEventCodeData
{
[JsonProperty("mcode")]
public string? EventCode { get; set; }
[JsonProperty("mname")]
public string? EventName { get; set; }
}
internal sealed class CitizenSportsUploadData
{
[JsonProperty("num")]
public int SuccessCount { get; set; }
[JsonProperty("errnum")]
public int FailureCount { get; set; }
}