using System.Text.Json.Serialization;
namespace VoiceHubLanDesktop.Models;
///
/// 歌曲信息
///
public sealed class Song
{
///
/// 歌曲标题
///
[JsonPropertyName("title")]
public string Title { get; set; } = string.Empty;
///
/// 艺术家/歌手
///
[JsonPropertyName("artist")]
public string Artist { get; set; } = string.Empty;
///
/// 点歌人
///
[JsonPropertyName("requester")]
public string Requester { get; set; } = string.Empty;
///
/// 投票数/热度
///
[JsonPropertyName("voteCount")]
public int VoteCount { get; set; }
}
///
/// 排期歌曲项目
///
public sealed class SongItem
{
///
/// 播放日期 (yyyy-MM-dd)
///
[JsonPropertyName("playDate")]
public string PlayDate { get; set; } = string.Empty;
///
/// 播放序号
///
[JsonPropertyName("sequence")]
public int Sequence { get; set; }
///
/// 歌曲信息
///
[JsonPropertyName("song")]
public Song Song { get; set; } = new();
///
/// 获取播放日期
///
public DateTime GetPlayDate()
{
if (string.IsNullOrWhiteSpace(PlayDate))
{
return DateTime.MinValue;
}
if (DateTime.TryParseExact(PlayDate, "yyyy-MM-dd", null,
System.Globalization.DateTimeStyles.None, out var result))
{
return result;
}
return DateTime.MinValue;
}
}
///
/// 组件状态
///
public enum ComponentState
{
///
/// 加载中
///
Loading,
///
/// 正常显示
///
Normal,
///
/// 网络错误
///
NetworkError,
///
/// 暂无排期
///
NoSchedule
}
///
/// 显示数据
///
public sealed class DisplayData
{
public ComponentState State { get; set; }
public IReadOnlyList Songs { get; set; } = [];
public DateTime? DisplayDate { get; set; }
public string ErrorMessage { get; set; } = string.Empty;
}