package cn.aqroid.business.auth.domain;

import java.io.Serializable;

/**
 * API登录用户模型
 * 用于小程序端用户认证
 *
 * @author aqroid
 * @date 2026-01-12
 */
public class ApiLoginUser implements Serializable {

    private static final long serialVersionUID = 1L;

    /** 用户ID（根据userType对应不同表的ID） */
    private Long userId;

    /** 微信openid */
    private String openid;

    /** 微信unionid */
    private String unionid;

    /** 手机号 */
    private String phone;

    /** 昵称 */
    private String nickname;

    /** 头像 */
    private String avatar;

    /** 用户类型: customer-顾客, merchant-商家, player-代练 */
    private String userType;

    /** 租户ID（商家/代练有值） */
    private Long tenantId;

    /** 顾客ID */
    private Long customerId;

    /** 商家ID */
    private Long merchantId;

    /** 代练ID */
    private Long playerId;

    /** JWT Token */
    private String token;

    /** 登录时间（毫秒） */
    private Long loginTime;

    /** 过期时间（毫秒） */
    private Long expireTime;

    /** 微信session_key（用于解密手机号等） */
    private String sessionKey;

    public Long getUserId() {
        return userId;
    }

    public void setUserId(Long userId) {
        this.userId = userId;
    }

    public String getOpenid() {
        return openid;
    }

    public void setOpenid(String openid) {
        this.openid = openid;
    }

    public String getUnionid() {
        return unionid;
    }

    public void setUnionid(String unionid) {
        this.unionid = unionid;
    }

    public String getPhone() {
        return phone;
    }

    public void setPhone(String phone) {
        this.phone = phone;
    }

    public String getNickname() {
        return nickname;
    }

    public void setNickname(String nickname) {
        this.nickname = nickname;
    }

    public String getAvatar() {
        return avatar;
    }

    public void setAvatar(String avatar) {
        this.avatar = avatar;
    }

    public String getUserType() {
        return userType;
    }

    public void setUserType(String userType) {
        this.userType = userType;
    }

    public Long getTenantId() {
        return tenantId;
    }

    public void setTenantId(Long tenantId) {
        this.tenantId = tenantId;
    }

    public Long getCustomerId() {
        return customerId;
    }

    public void setCustomerId(Long customerId) {
        this.customerId = customerId;
    }

    public Long getMerchantId() {
        return merchantId;
    }

    public void setMerchantId(Long merchantId) {
        this.merchantId = merchantId;
    }

    public Long getPlayerId() {
        return playerId;
    }

    public void setPlayerId(Long playerId) {
        this.playerId = playerId;
    }

    public String getToken() {
        return token;
    }

    public void setToken(String token) {
        this.token = token;
    }

    public Long getLoginTime() {
        return loginTime;
    }

    public void setLoginTime(Long loginTime) {
        this.loginTime = loginTime;
    }

    public Long getExpireTime() {
        return expireTime;
    }

    public void setExpireTime(Long expireTime) {
        this.expireTime = expireTime;
    }

    public String getSessionKey() {
        return sessionKey;
    }

    public void setSessionKey(String sessionKey) {
        this.sessionKey = sessionKey;
    }

    /**
     * 判断是否为顾客
     */
    public boolean isCustomer() {
        return "customer".equals(userType);
    }

    /**
     * 判断是否为商家
     */
    public boolean isMerchant() {
        return "merchant".equals(userType);
    }

    /**
     * 判断是否为代练
     */
    public boolean isPlayer() {
        return "player".equals(userType);
    }

    @Override
    public String toString() {
        return "ApiLoginUser{" +
                "userId=" + userId +
                ", openid='" + openid + '\'' +
                ", phone='" + phone + '\'' +
                ", nickname='" + nickname + '\'' +
                ", userType='" + userType + '\'' +
                ", tenantId=" + tenantId +
                ", customerId=" + customerId +
                ", merchantId=" + merchantId +
                ", playerId=" + playerId +
                '}';
    }
}
