package com.liangjian.dataplatform.member.entity.po.secondary;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import org.hibernate.annotations.GenericGenerator;

import javax.persistence.*;
import java.util.ArrayList;
import java.util.Date;
import java.util.Map;

/**
 * @Author: 黄子奇
 * @Date: 2019/11/14
 *
 * 手机号、微信用户信息关联表（含有微信用户的信息)
 */
@Entity
@Table(name = "mem_weixin_user_info")
@ApiModel("微信用户信息")
public class WeixinUserInfo {
    @Id
    @GeneratedValue(generator = "metaRelGenerator")
    @GenericGenerator(name = "metaRelGenerator", strategy = "com.liangjian.dataplatform.member.entity.genernator.SnowflakeGenernator")
    private String id;

    @ApiModelProperty("手机密文")
    @Column(name="secret_phone")
    private String secretPhone;

    @ApiModelProperty("是否关注")
    private Integer subscribe;

    private String openid;

    @ApiModelProperty("昵称")
    private String nickname;

    @ApiModelProperty("性别")
    private Integer sex;

    @ApiModelProperty("语言")
    private String language;

    @ApiModelProperty("城市")
    private String city;

    @ApiModelProperty("省份")
    private String province;

    @ApiModelProperty("国家")
    private String country;

    @ApiModelProperty("头像url")
    private String headimgurl;

    @ApiModelProperty("关注时间")
    @Column(name = "subscribe_time")
    private Integer subscribeTime;

    @ApiModelProperty("取关时间")
    @Column(name = "unsubscribe_time")
    private Integer unsubscribeTime;

    @ApiModelProperty("备注")
    private String remark;

    private Integer groupid;

    @Column(name = "tagid_list")
    private String tagidList;

    @Column(name = "subscribe_scene")
    private String subscribeScene;

    @Column(name = "qr_scene")
    private Integer qrScene;

    @Column(name = "qr_scene_str")
    private String qrSceneStr;

    private String unionid;

    @ApiModelProperty("积分")
    private Integer point = 0;

    @ApiModelProperty("积分变动时间")
    @Column(name = "point_update_date")
    private Date pointUpdateDate;

    @ApiModelProperty("成长值")
    private Integer growth = 0;

    @ApiModelProperty("成长值变动时间")
    @Column(name = "growth_update_date")
    private Date growthUpdateDate;

    @ApiModelProperty("收货人")
    @Column(name = "consignee")
    private String consignee;

    @ApiModelProperty("版本号")
    @Column(name = "version")
    private Long version = 0L;

    public static WeixinUserInfo fromMap(Map<String,Object> map) {
        WeixinUserInfo info = new WeixinUserInfo();
        info.subscribe = (Integer) map.get("subscribe");
        info.openid = (String) map.get("openid");
        info.nickname = (String) map.get("nickname");
        info.sex = (Integer) map.get("sex");
        info.language = (String) map.get("language");
        info.city = (String) map.get("city");
        info.province = (String) map.get("province");
        info.country = (String) map.get("country");
        info.headimgurl = (String) map.get("headimgurl");
        info.subscribeTime = (Integer) map.get("subscribe_time");
        info.unsubscribeTime = (Integer) map.get("unsubscribe_time");
        info.remark = (String) map.get("remark");
        info.groupid = (Integer) map.get("groupid");
        info.tagidList = map.getOrDefault("tagid_list",new ArrayList<>()).toString();
        info.subscribeScene = (String) map.get("subscribe_scene");
        info.qrScene = (Integer) map.get("qr_scene");
        info.qrSceneStr = (String) map.get("qr_scene_str");
        info.unionid = (String) map.get("unionid");
        info.consignee = (String) map.get("consignee");
        return info;
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getSecretPhone() {
        return secretPhone;
    }

    public void setSecretPhone(String secretPhone) {
        this.secretPhone = secretPhone;
    }

    public Integer getSubscribe() {
        return subscribe;
    }

    public void setSubscribe(Integer subscribe) {
        this.subscribe = subscribe;
    }

    public String getOpenid() {
        return openid;
    }

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

    public String getNickname() {
        return nickname;
    }

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

    public Integer getSex() {
        return sex;
    }

    public void setSex(Integer sex) {
        this.sex = sex;
    }

    public String getLanguage() {
        return language;
    }

    public void setLanguage(String language) {
        this.language = language;
    }

    public String getCity() {
        return city;
    }

    public void setCity(String city) {
        this.city = city;
    }

    public String getProvince() {
        return province;
    }

    public void setProvince(String province) {
        this.province = province;
    }

    public String getCountry() {
        return country;
    }

    public void setCountry(String country) {
        this.country = country;
    }

    public String getHeadimgurl() {
        return headimgurl;
    }

    public void setHeadimgurl(String headimgurl) {
        this.headimgurl = headimgurl;
    }

    public Integer getSubscribeTime() {
        return subscribeTime;
    }

    public void setSubscribeTime(Integer subscribeTime) {
        this.subscribeTime = subscribeTime;
    }

    public String getRemark() {
        return remark;
    }

    public void setRemark(String remark) {
        this.remark = remark;
    }

    public Integer getGroupid() {
        return groupid;
    }

    public void setGroupid(Integer groupid) {
        this.groupid = groupid;
    }

    public String getTagidList() {
        return tagidList;
    }

    public void setTagidList(String tagidList) {
        this.tagidList = tagidList;
    }

    public String getSubscribeScene() {
        return subscribeScene;
    }

    public void setSubscribeScene(String subscribeScene) {
        this.subscribeScene = subscribeScene;
    }

    public Integer getQrScene() {
        return qrScene;
    }

    public void setQrScene(Integer qrScene) {
        this.qrScene = qrScene;
    }

    public String getQrSceneStr() {
        return qrSceneStr;
    }

    public void setQrSceneStr(String qrSceneStr) {
        this.qrSceneStr = qrSceneStr;
    }

    public String getUnionid() {
        return unionid;
    }

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

    public Integer getUnsubscribeTime() {
        return unsubscribeTime;
    }

    public void setUnsubscribeTime(Integer unsubscribeTime) {
        this.unsubscribeTime = unsubscribeTime;
    }

    public Integer getPoint() {
        return point;
    }

    public void setPoint(Integer point) {
        this.point = point;
    }

    public Date getPointUpdateDate() {
        return pointUpdateDate;
    }

    public void setPointUpdateDate(Date pointUpdateDate) {
        this.pointUpdateDate = pointUpdateDate;
    }

    public Integer getGrowth() {
        return growth;
    }

    public void setGrowth(Integer growth) {
        this.growth = growth;
    }

    public Date getGrowthUpdateDate() {
        return growthUpdateDate;
    }

    public void setGrowthUpdateDate(Date growthUpdateDate) {
        this.growthUpdateDate = growthUpdateDate;
    }

    public String getConsignee() {
        return consignee;
    }

    public void setConsignee(String consignee) {
        this.consignee = consignee;
    }

    public Long getVersion() {
        return version;
    }

    public void setVersion(Long version) {
        this.version = version;
    }
}
