package cn.aqroid.business.auth.domain;

/**
 * 微信登录会话信息
 *
 * @author aqroid
 * @date 2026-01-12
 */
public class WxSession {

    /** 用户唯一标识 */
    private String openid;

    /** 会话密钥 */
    private String sessionKey;

    /** 用户在开放平台的唯一标识符（需要绑定开放平台） */
    private String unionid;

    /** 错误码 */
    private Integer errcode;

    /** 错误信息 */
    private String errmsg;

    public String getOpenid() {
        return openid;
    }

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

    public String getSessionKey() {
        return sessionKey;
    }

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

    public String getUnionid() {
        return unionid;
    }

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

    public Integer getErrcode() {
        return errcode;
    }

    public void setErrcode(Integer errcode) {
        this.errcode = errcode;
    }

    public String getErrmsg() {
        return errmsg;
    }

    public void setErrmsg(String errmsg) {
        this.errmsg = errmsg;
    }

    /**
     * 判断是否成功
     */
    public boolean isSuccess() {
        return errcode == null || errcode == 0;
    }

    @Override
    public String toString() {
        return "WxSession{" +
                "openid='" + openid + '\'' +
                ", sessionKey='" + sessionKey + '\'' +
                ", unionid='" + unionid + '\'' +
                ", errcode=" + errcode +
                ", errmsg='" + errmsg + '\'' +
                '}';
    }
}
