using QYZH.InteractiveMagazine.Common.Helpers;
using QYZH.InteractiveMagazine.Models.Enum;

namespace QYZH.InteractiveMagazine.Models.Dto.Banner;

/// <summary>
/// 轮播图创建/更新输入
/// </summary>
public class BannerInput
{
    /// <summary>
    /// 标题
    /// </summary>
    public string Title { get; set; } = string.Empty;

    /// <summary>
    /// 轮播图OSS路径
    /// </summary>
    public string ImageUrl { get; set; } = string.Empty;

    /// <summary>
    /// 展示位置
    /// </summary>
    public BannerPositionEnum Position { get; set; } = BannerPositionEnum.Home;

    /// <summary>
    /// 跳转类型
    /// </summary>
    public BannerTargetTypeEnum TargetType { get; set; } = BannerTargetTypeEnum.None;

    /// <summary>
    /// 跳转值
    /// </summary>
    public string? TargetValue { get; set; }

    /// <summary>
    /// 排序值，越小越靠前
    /// </summary>
    public int Sort { get; set; }

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

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

    /// <summary>
    /// 备注
    /// </summary>
    public string? Remark { get; set; }
}

/// <summary>
/// 轮播图输出
/// </summary>
public class BannerOutput
{
    private string _imageUrl = string.Empty;

    /// <summary>
    /// 主键ID
    /// </summary>
    public long Id { get; set; }

    /// <summary>
    /// 标题
    /// </summary>
    public string Title { get; set; } = string.Empty;

    /// <summary>
    /// 轮播图完整地址
    /// </summary>
    public string ImageUrl
    {
        get => DomainHelper.OssFullUrl(_imageUrl);
        set => _imageUrl = value ?? string.Empty;
    }

    /// <summary>
    /// 展示位置
    /// </summary>
    public BannerPositionEnum Position { get; set; }

    /// <summary>
    /// 跳转类型
    /// </summary>
    public BannerTargetTypeEnum TargetType { get; set; }

    /// <summary>
    /// 跳转值
    /// </summary>
    public string? TargetValue { get; set; }

    /// <summary>
    /// 排序值，越小越靠前
    /// </summary>
    public int Sort { get; set; }

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

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

    /// <summary>
    /// 备注
    /// </summary>
    public string? Remark { get; set; }

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

    /// <summary>
    /// 创建人
    /// </summary>
    public string? CreatedBy { get; set; }

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

    /// <summary>
    /// 修改人
    /// </summary>
    public string? UpdatedBy { get; set; }

    /// <summary>
    /// 修改时间
    /// </summary>
    public DateTime? UpdatedAt { get; set; }
}

/// <summary>
/// 轮播图分页查询输入
/// </summary>
public class BannerQueryInput : PageQueryModel
{
    /// <summary>
    /// 标题
    /// </summary>
    public string? Title { get; set; }

    /// <summary>
    /// 展示位置
    /// </summary>
    public BannerPositionEnum? Position { get; set; }

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