using QYZH.InteractiveMagazine.Models.Enum;
using Newtonsoft.Json;
namespace QYZH.InteractiveMagazine.Models.WeChat;
///
/// 微信小程序初次登录输入
///
public class WeChatLoginInput
{
///
/// 微信登录凭证(wx.login 获取的 code)
///
public string Code { get; set; } = string.Empty;
///
/// 手机号获取凭证(getPhoneNumber 按钮回调中的 code,可选)
///
public string? PhoneCode { get; set; }
}
///
/// 微信小程序快捷登录输入(通过 OpenId 登录)
///
public class WeChatQuickLoginInput
{
///
/// 微信OpenId(初次登录后客户端缓存的 OpenId)
///
public string OpenId { get; set; } = string.Empty;
}
///
/// 微信登录输出(含微信用户信息 + 该微信下的 Users 列表)
///
public class WeChatLoginOutput
{
///
/// 访问令牌(基于 WxUser,不绑定具体 User)
///
public string Token { get; set; } = string.Empty;
///
/// 微信用户信息
///
public WxUserInfoOutput WxUser { get; set; } = new();
///
/// 该微信用户下的用户列表
///
public List Users { get; set; } = [];
}
///
/// 微信用户信息输出(WxUser 表数据)
///
public class WxUserInfoOutput
{
///
/// WxUser 主键Id
///
public long Id { get; set; }
///
/// 微信OpenId
///
public string OpenId { get; set; } = string.Empty;
///
/// 微信UnionId
///
public string? UnionId { get; set; }
///
/// 昵称
///
public string? Name { get; set; }
///
/// 头像地址
///
public string? AvatarUrl { get; set; }
///
/// 手机号
///
public string? Phone { get; set; }
}
///
/// 用户输出(Users 表数据,即角色/子用户)
///
public class WxUserOutput
{
///
/// Users 主键Id
///
public long Id { get; set; }
///
/// 关联 WxUserId
///
public long WxUserId { get; set; }
///
/// 昵称
///
public string? NickName { get; set; }
///
/// 头像地址
///
public string? AvatarUrl { get; set; }
///
/// 积分余额
///
public int Points { get; set; }
///
/// 当前成长值
///
public int GrowthPoints { get; set; }
///
/// 用户类型: Normal, VIP
///
public string Type { get; set; } = string.Empty;
///
/// 状态
///
public string Status { get; set; } = string.Empty;
///
/// 是否上次在线用户
///
public bool IsLastOnline { get; set; }
///
/// 创建时间
///
public DateTime CreatedAt { get; set; }
}
///
/// 新增用户输入(在 WxUser 下创建子用户/角色)
///
public class CreateChildUserInput
{
///
/// 昵称
///
public string Name { get; set; } = string.Empty;
///
/// 头像地址(可选)
///
public string? AvatarUrl { get; set; }
}
///
/// 微信切换用户输入
///
public class WeChatSwitchUserInput
{
///
/// 目标用户ID(Users 表 Id)
///
public long UserId { get; set; }
}
///
/// 微信切换用户输出(JWT 基于 WxUser,切换不更换 Token)
///
public class WeChatSwitchUserOutput
{
///
/// 当前切换的用户详情
///
public WxUserOutput User { get; set; } = new();
}
// ========== 微信 API 响应 DTO(不变) ==========
///
/// 微信 code2session 接口响应
///
public class WxCode2SessionResponse
{
[JsonProperty("openid")]
public string? OpenId { get; set; }
[JsonProperty("session_key")]
public string? SessionKey { get; set; }
[JsonProperty("unionid")]
public string? UnionId { get; set; }
[JsonProperty("errcode")]
public int ErrCode { get; set; }
[JsonProperty("errmsg")]
public string? ErrMsg { get; set; }
}
///
/// 微信获取手机号接口响应
///
public class WxPhoneNumberResponse
{
[JsonProperty("errcode")]
public int ErrCode { get; set; }
[JsonProperty("errmsg")]
public string? ErrMsg { get; set; }
[JsonProperty("phone_info")]
public WxPhoneInfo? PhoneInfo { get; set; }
}
///
/// 微信手机号信息
///
public class WxPhoneInfo
{
[JsonProperty("phoneNumber")]
public string? PhoneNumber { get; set; }
[JsonProperty("purePhoneNumber")]
public string? PurePhoneNumber { get; set; }
[JsonProperty("countryCode")]
public string? CountryCode { get; set; }
}
///
/// 微信 access_token 接口响应
///
public class WxAccessTokenResponse
{
[JsonProperty("access_token")]
public string? AccessToken { get; set; }
[JsonProperty("expires_in")]
public int ExpiresIn { get; set; }
[JsonProperty("errcode")]
public int ErrCode { get; set; }
[JsonProperty("errmsg")]
public string? ErrMsg { get; set; }
}