package com.liquidnet.service.sweet.dto.vo;

import com.liquidnet.service.adam.dto.vo.AdamLoginInfoVo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;

@ApiModel(value = "WechatAppletLoginInfoVo", description = "小程序登录响应（含旧版兼容字段）")
public class WechatAppletLoginInfoVo extends AdamLoginInfoVo {
    private static final long serialVersionUID = 1L;

    @ApiModelProperty("兼容旧版，同 userInfo.uid")
    private String userId;
    @ApiModelProperty("兼容旧版，同 wechatOpenid")
    private String openId;
    @ApiModelProperty("兼容旧版，同 wechatUnionid")
    private String unionId;
    @ApiModelProperty("兼容旧版")
    private String getPhoneNumber;
    @ApiModelProperty("兼容旧版")
    private String getPurePhoneNumber;
    @ApiModelProperty("兼容旧版")
    private String getCountryCode;

    public String getUserId() {
        return userId;
    }

    public void setUserId(String 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 getGetPhoneNumber() {
        return getPhoneNumber;
    }

    public void setGetPhoneNumber(String getPhoneNumber) {
        this.getPhoneNumber = getPhoneNumber;
    }

    public String getGetPurePhoneNumber() {
        return getPurePhoneNumber;
    }

    public void setGetPurePhoneNumber(String getPurePhoneNumber) {
        this.getPurePhoneNumber = getPurePhoneNumber;
    }

    public String getGetCountryCode() {
        return getCountryCode;
    }

    public void setGetCountryCode(String getCountryCode) {
        this.getCountryCode = getCountryCode;
    }

    public static WechatAppletLoginInfoVo wrap(AdamLoginInfoVo loginInfo, String phoneNumber,
                                               String purePhoneNumber, String countryCode,
                                               String openId, String unionId) {
        WechatAppletLoginInfoVo vo = new WechatAppletLoginInfoVo();
        vo.setToken(loginInfo.getToken());
        vo.setUserInfo(loginInfo.getUserInfo());
        vo.setUserMemberVo(loginInfo.getUserMemberVo());
        vo.setWechatOpenid(loginInfo.getWechatOpenid());
        vo.setWechatUnionid(loginInfo.getWechatUnionid());
        if (null != loginInfo.getUserInfo()) {
            vo.setUserId(loginInfo.getUserInfo().getUid());
        }
        vo.setOpenId(openId);
        vo.setUnionId(unionId);
        vo.setGetPhoneNumber(phoneNumber);
        vo.setGetPurePhoneNumber(purePhoneNumber);
        vo.setGetCountryCode(countryCode);
        return vo;
    }
}
