package com.sdtool.common.entity.site;

import com.sdtool.common.datas.TokenUserFrom;
import com.sweetfish.convert.ConvertColumn;
import com.sweetfish.util.Comment;

/**
 * Created by jlutt on 2020-07-27
 * 登录用户通用信息
 * 和LoginUser不同，取出其简单信息加上分库分表信息
 * 为保证token签名正确，需要对字段增加ConvertColumn注解，保证序列号json的数据相同
 *
 * @author jlutt
 */
@SuppressWarnings("unused")
public class ERPTokenUser {

    @Comment("工厂key")
    @ConvertColumn(name = "supplierCode", index = 1)
    private long supplierCode;

    @Comment("数据源")
    @ConvertColumn(name = "dataSourceId", index = 2)
    private String dataSourceId;

    @Comment("用户id，新系统要求所有能登录的档案取同一id")
    @ConvertColumn(name = "id", index = 3)
    private long id;

    @Comment("部门id")
    @ConvertColumn(name = "deptId", index = 4)
    private long deptId;

    @Comment("用户名称")
    @ConvertColumn(name = "userName", index = 5)
    private String userName;

    @Comment("账号")
    @ConvertColumn(name = "account", index = 6)
    private String account;

    @Comment("部门名称")
    @ConvertColumn(name = "deptName", index = 7)
    private String deptName;

    @Comment("工厂名称")
    @ConvertColumn(name = "supplierName", index = 8)
    private String supplierName;

    @Comment("超时时间")
    @ConvertColumn(name = "expireTime", index = 9)
    private long expireTime;

    @Comment("用户来源或类型")
    @ConvertColumn(name = "userFrom", index = 10)
    private int userFrom;

    @Comment("三方账号绑定对应的档案id，比如小程序用户对应的MallUser")
    @ConvertColumn(name = "idBindOrg", index = 11)
    private long idBindOrg;

    @Comment("三方账号绑定对应的档案")
    @ConvertColumn(name = "bindUserName", index = 12)
    private String bindUserName;

    @Comment("三方账号绑定对应的档案")
    @ConvertColumn(name = "bindUserLinkPhone", index = 13)
    private String bindUserLinkPhone;

    @Comment("三方账号OpenId")
    @ConvertColumn(name = "userOpenId", index = 14)
    private String userOpenId;

    public ERPTokenUser() {
    }

    public ERPTokenUser(long id, String userName) {
        this.id = id;
        this.userName = userName;
        this.userFrom = TokenUserFrom.PC_ERP_ADMIN.getValue();
    }

    public <T extends TokenUserData> ERPTokenUser(T userInfo) {
        this.id = userInfo.getId();
        this.deptId = userInfo.getDeptId();
        this.userName = userInfo.getUserName();
        this.account = userInfo.getAccount();
        this.deptName = userInfo.getDeptName();
        this.userFrom = userInfo.getUserFrom();
        this.idBindOrg = userInfo.getIdBindOrg();
        this.bindUserName = userInfo.getBindUserName();
        this.bindUserLinkPhone = userInfo.getBindUserLinkPhone();
        this.userOpenId = userInfo.getUserOpenId();
    }

    public long getSupplierCode() {
        return supplierCode;
    }

    public void setSupplierCode(long supplierCode) {
        this.supplierCode = supplierCode;
    }

    public long getId() {
        return id;
    }

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

    public long getExpireTime() {
        return expireTime;
    }

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

    public String getDataSourceId() {
        return dataSourceId;
    }

    public void setDataSourceId(String dataSourceId) {
        this.dataSourceId = dataSourceId;
    }

    public long getDeptId() {
        return deptId;
    }

    public void setDeptId(long deptId) {
        this.deptId = deptId;
    }

    public String getUserName() {
        return userName;
    }

    public void setUserName(String userName) {
        this.userName = userName;
    }

    public String getAccount() {
        return account;
    }

    public void setAccount(String account) {
        this.account = account;
    }

    public String getDeptName() {
        return deptName;
    }

    public void setDeptName(String deptName) {
        this.deptName = deptName;
    }

    public String getSupplierName() {
        return supplierName;
    }

    public void setSupplierName(String supplierName) {
        this.supplierName = supplierName;
    }

    public int getUserFrom() {
        return userFrom;
    }

    public void setUserFrom(int userFrom) {
        this.userFrom = userFrom;
    }

    public long getIdBindOrg() {
        return idBindOrg;
    }

    public void setIdBindOrg(long idBindOrg) {
        this.idBindOrg = idBindOrg;
    }

    public String getBindUserName() {
        return bindUserName;
    }

    public void setBindUserName(String bindUserName) {
        this.bindUserName = bindUserName;
    }

    public String getBindUserLinkPhone() {
        return bindUserLinkPhone;
    }

    public void setBindUserLinkPhone(String bindUserLinkPhone) {
        this.bindUserLinkPhone = bindUserLinkPhone;
    }

    public String getUserOpenId() {
        return userOpenId;
    }

    public void setUserOpenId(String userOpenId) {
        this.userOpenId = userOpenId;
    }
}
