using QYZH.InteractiveMagazine.Models.Enum;
using System.Text.Json.Serialization;

namespace QYZH.InteractiveMagazine.Models.Dto;

/// <summary>
/// 绑定期刊输入DTO
/// </summary>
public class BindJournalInput
{
    /// <summary>
    /// 期刊模板Id（扫码解析的期刊定义Id）
    /// </summary>
    [JsonNumberHandling(JsonNumberHandling.AllowReadingFromString)]
    public long JournalId { get; set; }

    /// <summary>
    /// 实例化期刊Id（扫码解析的具体期刊实例Id，可选）
    /// </summary>
    [JsonNumberHandling(JsonNumberHandling.AllowReadingFromString)]
    public long Id { get; set; }

}

/// <summary>
/// 绑定期刊输出DTO
/// </summary>
public class BindJournalOutput
{
    /// <summary>
    /// 绑定记录Id
    /// </summary>
    public long Id { get; set; }

    /// <summary>
    /// 用户Id
    /// </summary>
    public long UserId { get; set; }

    /// <summary>
    /// 期刊模板Id
    /// </summary>
    public long JournalId { get; set; }

    /// <summary>
    /// 关联类型
    /// </summary>
    public string Type { get; set; } = string.Empty;

    /// <summary>
    /// 状态
    /// </summary>
    public string Status { get; set; } = string.Empty;

    /// <summary>
    /// 绑定时间
    /// </summary>
    public DateTime CreatedAt { get; set; }
}

/// <summary>
/// 用户绑定期刊消息
/// </summary>
public class BindJournalMessage
{
    /// <summary>
    /// 用户Id
    /// </summary>
    public long UserId { get; set; }

    /// <summary>
    /// 期刊Id
    /// </summary>
    public long JournalId { get; set; }

    /// <summary>
    /// 期刊开始时间
    /// </summary>
    public DateTime? StartTime { get; set; }

    /// <summary>
    /// 期刊结束时间
    /// </summary>
    public DateTime? EndTime { get; set; }

    /// <summary>
    /// 用户作答信息上传地址
    /// </summary>
    public string UploadDomain { get; set; } = string.Empty;
}

/// <summary>
/// 用户期刊关联查询输入DTO
/// </summary>
public class UserJournalQueryInput : PageQueryModel
{
    /// <summary>
    /// 期刊模板Id
    /// </summary>
    public long? JournalId { get; set; }

    /// <summary>
    /// 实例化期刊Id
    /// </summary>
    public long Id { get; set; }    

    /// <summary>
    /// 关联类型: Read, Favorite, Subscribe
    /// </summary>
    public string? Type { get; set; }
}

/// <summary>
/// 生成期刊二维码输入DTO
/// </summary>
public class CreateUserJournalQrCodeInput
{
    /// <summary>
    /// 期刊Id
    /// </summary>
    public long JournalId { get; set; }

    /// <summary>
    /// 生成数量
    /// </summary>
    public int Count { get; set; } = 1;
}

/// <summary>
/// 生成期刊二维码提交结果
/// </summary>
public class CreateUserJournalQrCodeOutput
{
    /// <summary>
    /// 期刊Id
    /// </summary>
    public long JournalId { get; set; }

    /// <summary>
    /// 请求生成数量
    /// </summary>
    public int RequestedCount { get; set; }

    /// <summary>
    /// 已提交生成数量
    /// </summary>
    public int AcceptedCount { get; set; }

    /// <summary>
    /// 二维码记录Id列表
    /// </summary>
    [JsonNumberHandling(JsonNumberHandling.WriteAsString)]
    public List<long> RecordIds { get; set; } = [];

    /// <summary>
    /// 是否后台生成
    /// </summary>
    public bool IsAsync { get; set; }

    /// <summary>
    /// 提示信息
    /// </summary>
    public string Message { get; set; } = string.Empty;
}

/// <summary>
/// 期刊二维码查询输入DTO
/// </summary>
public class GenerateUserJournalQrCodeMessage
{
    /// <summary>
    /// 二维码记录Id列表
    /// </summary>
    public List<long> RecordIds { get; set; } = [];

    /// <summary>
    /// 操作人名称
    /// </summary>
    public string OperatorName { get; set; } = string.Empty;
}

/// <summary>
/// 鏈熷垔浜岀淮鐮佹煡璇㈣緭鍏TO
/// </summary>
public class UserJournalQrCodeQueryInput : PageQueryModel
{
    /// <summary>
    /// 期刊Id
    /// </summary>
    public long? JournalId { get; set; }

    /// <summary>
    /// 用户Id
    /// </summary>
    public long? UserId { get; set; }

    /// <summary>
    /// 是否已绑定用户
    /// </summary>
    public bool? IsBound { get; set; }

    /// <summary>
    /// 状态
    /// </summary>
    public int? Status { get; set; }
}

/// <summary>
/// 期刊二维码输出DTO
/// </summary>
public class UserJournalQrCodeOutput
{
    /// <summary>
    /// 二维码记录Id
    /// </summary>
    [JsonNumberHandling(JsonNumberHandling.WriteAsString)]
    public long Id { get; set; }

    /// <summary>
    /// 期刊Id
    /// </summary>
    public long JournalId { get; set; }

    /// <summary>
    /// 期刊名称
    /// </summary>
    public string JournalName { get; set; } = string.Empty;

    /// <summary>
    /// 用户Id
    /// </summary>
    public long? UserId { get; set; }

    /// <summary>
    /// 用户昵称
    /// </summary>
    public string? UserName { get; set; }

    /// <summary>
    /// 关联类型
    /// </summary>
    public string Type { get; set; } = string.Empty;

    /// <summary>
    /// 状态
    /// </summary>
    public string Status { get; set; } = string.Empty;

    /// <summary>
    /// 是否已绑定用户
    /// </summary>
    public bool IsBound { get; set; }

    /// <summary>
    /// 二维码内容
    /// </summary>
    public string QrCodeUrl { get; set; } = string.Empty;

    /// <summary>
    /// 创建时间
    /// </summary>
    public DateTime CreatedAt { get; set; }

    /// <summary>
    /// 绑定时间
    /// </summary>
    public DateTime? BoundAt { get; set; }
}

/// <summary>
/// 删除期刊二维码输入DTO
/// </summary>
public class DeleteUserJournalQrCodeInput
{
    /// <summary>
    /// 二维码记录Id列表
    /// </summary>
    [JsonNumberHandling(JsonNumberHandling.AllowReadingFromString)]
    public List<long> Ids { get; set; } = [];
}
