using System.Text.Json.Serialization;

namespace HoneyBox.Model.Models.Auth;

/// <summary>
/// 微信小程序登录请求
/// </summary>
public class WechatLoginRequest
{
    /// <summary>
    /// 微信授权code
    /// </summary>
    [JsonPropertyName("code")]
    public string Code { get; set; } = string.Empty;

    /// <summary>
    /// 推荐人ID（前端可能传空字符串，所以用string接收）
    /// </summary>
    [JsonPropertyName("pid")]
    public string? PidStr { get; set; }

    /// <summary>
    /// 点击ID
    /// </summary>
    [JsonPropertyName("clickid")]
    public string? ClickId { get; set; }

    /// <summary>
    /// 获取推荐人ID（转换为int）
    /// </summary>
    [JsonIgnore]
    public int? Pid => string.IsNullOrWhiteSpace(PidStr) ? null : int.TryParse(PidStr, out var pid) ? pid : null;
}
