using HoneyBox.Model.Models.Auth;

namespace HoneyBox.Core.Interfaces;

/// <summary>
/// 认证服务接口
/// </summary>
public interface IAuthService
{
    /// <summary>
    /// 微信小程序登录
    /// </summary>
    /// <param name="code">微信授权code</param>
    /// <param name="pid">推荐人ID</param>
    /// <param name="clickId">点击ID</param>
    /// <returns>登录结果</returns>
    Task<LoginResult> WechatMiniProgramLoginAsync(string code, int? pid, string? clickId);

    /// <summary>
    /// 手机号验证码登录
    /// </summary>
    /// <param name="mobile">手机号</param>
    /// <param name="code">短信验证码</param>
    /// <param name="pid">推荐人ID</param>
    /// <param name="clickId">点击ID</param>
    /// <returns>登录结果</returns>
    Task<LoginResult> MobileLoginAsync(string mobile, string code, int? pid, string? clickId);

    /// <summary>
    /// 验证码绑定手机号
    /// </summary>
    /// <param name="userId">用户ID</param>
    /// <param name="mobile">手机号</param>
    /// <param name="code">短信验证码</param>
    /// <returns>绑定结果</returns>
    Task<BindMobileResponse> BindMobileAsync(int userId, string mobile, string code);

    /// <summary>
    /// 微信授权绑定手机号
    /// </summary>
    /// <param name="userId">用户ID</param>
    /// <param name="wechatCode">微信授权code</param>
    /// <returns>绑定结果</returns>
    Task<BindMobileResponse> WechatBindMobileAsync(int userId, string wechatCode);

    /// <summary>
    /// 微信手机号快速验证登录
    /// </summary>
    /// <param name="phoneCode">微信手机号授权code（getPhoneNumber返回）</param>
    /// <param name="loginCode">微信登录code（uni.login返回，用于获取openid）</param>
    /// <param name="pid">推荐人ID</param>
    /// <returns>登录结果</returns>
    Task<LoginResult> WechatPhoneLoginAsync(string phoneCode, string? loginCode, int? pid);

    /// <summary>
    /// 记录登录信息
    /// </summary>
    /// <param name="userId">用户ID</param>
    /// <param name="device">设备类型</param>
    /// <param name="deviceInfo">设备信息</param>
    /// <returns>记录登录响应</returns>
    Task<RecordLoginResponse> RecordLoginAsync(int userId, string? device, string? deviceInfo);

    /// <summary>
    /// 账号注销
    /// </summary>
    /// <param name="userId">用户ID</param>
    /// <param name="type">类型：0=注销 1=取消注销</param>
    /// <returns>异步任务</returns>
    Task LogOffAsync(int userId, int type);

    /// <summary>
    /// H5绑定手机号（无需验证码）
    /// </summary>
    /// <param name="userId">用户ID</param>
    /// <param name="mobile">手机号</param>
    /// <returns>绑定结果</returns>
    Task<BindMobileResponse> BindMobileH5Async(int userId, string mobile);

    #region Refresh Token 相关方法

    /// <summary>
    /// 刷新 Token
    /// </summary>
    /// <param name="refreshToken">Refresh Token</param>
    /// <param name="ipAddress">客户端 IP 地址</param>
    /// <returns>刷新结果，包含新的 Access Token 和 Refresh Token</returns>
    Task<RefreshTokenResult> RefreshTokenAsync(string refreshToken, string? ipAddress);

    /// <summary>
    /// 撤销 Token
    /// </summary>
    /// <param name="refreshToken">要撤销的 Refresh Token</param>
    /// <param name="ipAddress">客户端 IP 地址</param>
    /// <returns>异步任务</returns>
    Task RevokeTokenAsync(string refreshToken, string? ipAddress);

    /// <summary>
    /// 撤销用户的所有 Token
    /// </summary>
    /// <param name="userId">用户ID</param>
    /// <param name="ipAddress">客户端 IP 地址</param>
    /// <returns>异步任务</returns>
    Task RevokeAllUserTokensAsync(int userId, string? ipAddress);

    #endregion
}
