package com.sdtool.common.entity.system;

import com.sdtool.common.datas.TokenUserFrom;
import com.sdtool.common.entity.base.BaseEntity;
import com.sdtool.common.entity.mall.MallUser;
import com.sdtool.common.entity.site.TokenUserData;
import com.sweetfish.util.Comment;
import org.rex.db.RColumn;

/**
 *
 */
public class SocialUser extends BaseEntity implements TokenUserData {

    @Comment("")
    @RColumn("id")
    private long id;

    @Comment("")
    @RColumn("iduser")
    private long idUser;

    @Comment("来源=SocialFromKind")
    @RColumn("fromkind")
    private int fromKind;

    @Comment("openId")
    @RColumn("useropenid")
    private String userOpenId;

    @Comment("用户昵称，数据库一定要支持utf8mb4")
    @RColumn("usernickname")
    private String userNickName;

    @Comment("微信使用者的电话，和账号会不同")
    @RColumn("userlinkphone")
    private String userLinkPhone;

    @RColumn("avatarurl")
    @Comment("头像")
    private String avatarUrl;

    @Comment("用户身份")
    @RColumn("useridentity")
    private int userIdentity;

    @Comment("")
    @RColumn("voidflag")
    private int voidFlag;

    private MallUser mallUser;


    public long getId() {
        return id;
    }

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

    @Override
    public long getDeptId() {
        return 0L;
    }

    @Override
    public String getUserName() {
        return this.userNickName;
    }

    @Override
    public String getAccount() {
        if (mallUser == null) {
            return this.userNickName;
        } else {
            return this.mallUser.getLoginAccount();
        }
    }

    @Override
    public String getDeptName() {
        return "";
    }

    @Override
    public int getUserFrom() {
        return TokenUserFrom.MINI_MALL.getValue();
    }

    @Override
    public long getIdBindOrg() {
        if (mallUser == null) {
            return 0L;
        } else {
            return this.mallUser.getId();
        }
    }

    @Override
    public String getBindUserName() {
        if (mallUser == null) {
            return this.userNickName;
        } else {
            return this.mallUser.getUserName();
        }
    }

    @Override
    public String getBindUserLinkPhone() {
        if (mallUser == null) {
            return "";
        } else {
            return this.mallUser.getLoginAccount();
        }
    }

    public long getIdUser() {
        return idUser;
    }

    public void setIdUser(long idUser) {
        this.idUser = idUser;
    }

    public int getFromKind() {
        return fromKind;
    }

    public void setFromKind(int fromKind) {
        this.fromKind = fromKind;
    }

    public String getUserOpenId() {
        return userOpenId;
    }

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

    public String getAvatarUrl() {
        return avatarUrl;
    }

    public void setAvatarUrl(String avatarUrl) {
        this.avatarUrl = avatarUrl;
    }

    public int getUserIdentity() {
        return userIdentity;
    }

    public void setUserIdentity(int userIdentity) {
        this.userIdentity = userIdentity;
    }

    public int getVoidFlag() {
        return voidFlag;
    }

    public void setVoidFlag(int voidFlag) {
        this.voidFlag = voidFlag;
    }

    public String getUserNickName() {
        return userNickName;
    }

    public void setUserNickName(String userNickName) {
        this.userNickName = userNickName;
    }

    public String getUserLinkPhone() {
        return userLinkPhone;
    }

    public void setUserLinkPhone(String userLinkPhone) {
        this.userLinkPhone = userLinkPhone;
    }

    public MallUser getMallUser() {
        return mallUser;
    }

    public void setMallUser(MallUser mallUser) {
        this.mallUser = mallUser;
    }
}
