package com.seer.teach.user.entity;

import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.seer.teach.common.entity.BaseEntity;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Getter;
import lombok.Setter;

import java.time.LocalDateTime;

/**
 * <p>
 * 用户第三方认证表（状态增强版）
 * </p>
 *
 * @author Wang
 * @since 2025-08-10 17:42:43
 */
@Getter
@Setter
@TableName("za_user_auth")
@Schema(name = "ZaUserAuthEntity对象", description = "用户第三方认证表（状态增强版）")
public class UserAuthEntity extends BaseEntity {

    private static final long serialVersionUID = 1L;

    @Schema(description = "关联的用户ID")
    @TableField("user_id")
    private Integer userId;

    @Schema(description = "提供商: wechat,alipay,apple,phone")
    @TableField("provider")
    private String provider;

    @Schema(description = "认证类型: wechat_mini(微信小程序),wechat_mp(公众号),alipay_mini(支付宝小程序),phone_sms(短信验证)")
    @TableField("auth_type")
    private String authType;

    @Schema(description = "平台用户唯一ID")
    @TableField("open_id")
    private String openId;

    @Schema(description = "跨平台统一ID(如微信union_id)")
    @TableField("union_id")
    private String unionId;

    @Schema(description = "应用ID")
    private String appId;

    @Schema(description = "访问令牌(加密存储)")
    @TableField("access_token")
    private String accessToken;

    @Schema(description = "刷新令牌(加密存储)")
    @TableField("refresh_token")
    private String refreshToken;

    @Schema(description = "令牌过期时间")
    @TableField("token_expires_at")
    private LocalDateTime tokenExpiresAt;

    @Schema(description = "扩展凭证(如小程序session_key)")
    @TableField("credential_json")
    private String credentialJson;

    @Schema(description = "用户资料原始JSON")
    @TableField("profile_json")
    private String profileJson;

    @Schema(description = "是否绑定: 1=是, 0=否（解绑后保留记录）")
    @TableField("is_bound")
    private Boolean isBound;

    @Schema(description = "是否已验证: 1=是, 0=否（如手机号未验证）")
    @TableField("is_verified")
    private Boolean isVerified;

    @Schema(description = "状态: 1=正常, 0=禁用, -1=已删除")
    @TableField("`status`")
    private Integer status;

    @Schema(description = "登录次数统计")
    @TableField("login_count")
    private Integer loginCount;

    @Schema(description = "最后登录时间")
    @TableField("last_login_at")
    private LocalDateTime lastLoginAt;

}