package com.dgtly.system.domain;

import java.util.Date;
import java.util.List;
import java.util.Map;
import javax.validation.constraints.*;

import com.dgtly.common.core.domain.Ztree;
import com.fasterxml.jackson.annotation.JsonFormat;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import com.dgtly.common.annotation.Excel;
import com.dgtly.common.annotation.Excel.ColumnType;
import com.dgtly.common.annotation.Excel.Type;
import com.dgtly.common.annotation.Excels;
import com.dgtly.common.core.domain.BaseEntity;

/**
 * 用户对象 sys_user
 *
 * @author dgtly
 */
public class SysUser extends BaseEntity
{
    private static final long serialVersionUID = 1L;

    /** 用户ID */
    @Excel(name = "用户序号", cellType = ColumnType.NUMERIC, prompt = "用户编号")
    private Long userId;

    /** 公司ID */
    @Excel(name = "公司编号", type = Type.IMPORT)
    private Long companyId;

    /** 部门ID */
    @Excel(name = "部门编号", type = Type.IMPORT)
    private Long deptId;

    /** 部门父ID */
    private Long parentId;

    /** 角色ID */
    private Long roleId;

    /** 登录名称 */
    @Excel(name = "登录名称")
    private String loginName;

    /** 用户名称 */
    @Excel(name = "用户名称")
    private String userName;

    /** 用户邮箱 */
    @Excel(name = "用户邮箱")
    private String email;

    /** 手机号码 */
    @Excel(name = "手机号码")
    private String phonenumber;

    /** 用户性别 */
    @Excel(name = "用户性别", readConverterExp = "0=男,1=女,2=未知")
    private String sex;

    /** 用户头像 */
    private String avatar;

    /** 密码 */
    private String password;

    /** 盐加密 */
    private String salt;

    /** 帐号状态（0正常 1停用） */
    @Excel(name = "帐号状态", readConverterExp = "0=正常,1=停用")
    private String status;

    /** 删除标志（0代表存在 2代表删除） */
    private String delFlag;

    /** 最后登陆IP */
    @Excel(name = "最后登陆IP", type = Type.EXPORT)
    private String loginIp;

    /** 最后登陆时间 */
    @Excel(name = "最后登陆时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss", type = Type.EXPORT)
    private Date loginDate;

    /** 部门对象 */
    @Excels({
        @Excel(name = "部门名称", targetAttr = "deptName", type = Type.EXPORT),
        @Excel(name = "部门负责人", targetAttr = "leader", type = Type.EXPORT)
    })
    private SysDept dept;

    private SysCompany company;

    private List<SysRole> roles;

    /** 角色组 */
    private Long[] roleIds;

    /** 岗位组 */
    private Long[] postIds;
    /** 证件类型 */
    private String idType;
    /** 证件号 */
    private String idNumber;
    /** 注册后id */
    private String accountId;
    /** 是否认证 */
    private String isAuthentication;
    /** 更新时间 */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date personAttestationTime;
    /** 接受认证的手机号 */
    private String receiveUrlMobileNo;
    /** 用户销售信息扩展 */
    private SysUserExt  sysUserExt;
    /** 用户销售信息扩展 */
    private List<SysUserExt>  sysUserExtLsit;
    /** 是否收货人 0否 1是*/
    private String  isConsignee;
    /** 自主下单是否授权(0否1是)*/
    private String  isIndependently;
    /**自提是否授权 0否1是*/
    private String isSelfDelivery;
    /*企业认证状态0未认证1已认证*/
    private String isOrgAuthentication;
    /*企业认证时间*/
    private Date orgAttestationTime;

    /** 是否同步 */
    private String  isSync;

    /**
     * 订单在线权限
     */
    private List<Ztree>  author;

    /** 用户权限 TUC*/
    private String  authorType;
    //2离职
    private String quit;

    //门店账号标识 1门店账号 0非门店账号
    private String  isShopAccount;

    //大区
    private String officeName;

    //销售部
    private String subOfficeName;

    //销售部编码
    private String subOfficeCode;

    //公司名称
    private String companyName;


    /** 雇员id */
    private String sapEmployeeId;

    /** 是否刷新供应商标识*/
    private String isRefreshProvider;


    //应用类型对应关系
    private List<Map<String,Object> >loginTypeList;
   //门店对应关系
    private List<Map<String,Object> >loginTypeInfo;

    public String getSapEmployeeId() {
        return sapEmployeeId;
    }

    public void setSapEmployeeId(String sapEmployeeId) {
        this.sapEmployeeId = sapEmployeeId;
    }

    public void setLoginTypeInfo(List<Map<String, Object>> loginTypeInfo) {
        this.loginTypeInfo = loginTypeInfo;
    }

    public List<Map<String, Object>> getLoginTypeInfo() {
        return loginTypeInfo;
    }

    public void setLoginTypeList(List<Map<String, Object>> loginTypeList) {
        this.loginTypeList = loginTypeList;
    }

    public List<Map<String, Object>> getLoginTypeList() {
        return loginTypeList;
    }

    public String getCompanyName() {
        return companyName;
    }

    public String getSubOfficeCode() {
        return subOfficeCode;
    }

    public void setSubOfficeCode(String subOfficeCode) {
        this.subOfficeCode = subOfficeCode;
    }

    public void setCompanyName(String companyName) {
        this.companyName = companyName;
    }

    private String shopType;

    public String getQuit(){return  quit;}

    public String getShopType() {
        return shopType;
    }

    public void setShopType(String shopType) {
        this.shopType = shopType;
    }

    public String getIsShopAccount() {
        return isShopAccount;
    }

    public void setIsShopAccount(String isShopAccount) {
        this.isShopAccount = isShopAccount;
    }

    public  void setQuit(String quit){this.quit=quit;}
    public String getAuthorType() {
        return authorType;
    }

    public void setAuthorType(String authorType) {
        this.authorType = authorType;
    }

    public String getIsRefreshProvider() {
        return isRefreshProvider;
    }

    public void setIsRefreshProvider(String isRefreshProvider) {
        this.isRefreshProvider = isRefreshProvider;
    }

    //    /** 所属销售组织等级 详见字典（sales_level） */
//    private String salesLevel;
//
//    /** 所属销售组织名称 */
//    private String orgName;
//
//    /**  所属销售组织code */
//    private  String  orgCode;

    public SysUser()
    {

    }

    public String getIsSelfDelivery() {
        return isSelfDelivery;
    }

    public String getOfficeName() {
        return officeName;
    }

    public void setOfficeName(String officeName) {
        this.officeName = officeName;
    }

    public String getSubOfficeName() {
        return subOfficeName;
    }

    public void setSubOfficeName(String subOfficeName) {
        this.subOfficeName = subOfficeName;
    }

    public void setIsSelfDelivery(String isSelfDelivery) {
        this.isSelfDelivery = isSelfDelivery;
    }

    public String getIsIndependently() {
        return isIndependently;
    }

    public void setIsIndependently(String isIndependently) {
        this.isIndependently = isIndependently;
    }

    public List<Ztree> getAuthor() {
        return author;
    }

    public void setAuthor(List<Ztree> author) {
        this.author = author;
    }

    public SysUser(Long userId)
    {
        this.userId = userId;
    }

    public Long getCompanyId() {
        return companyId;
    }

    public void setCompanyId(Long companyId) {
        this.companyId = companyId;
    }

    public Long getUserId()
    {
        return userId;
    }

    public void setUserId(Long userId)
    {
        this.userId = userId;
    }

    public boolean isAdmin()
    {
        return isAdmin(this.userId);
    }

    public static boolean isAdmin(Long userId)
    {
        return userId != null && 1L == userId;
    }

    public Long getDeptId()
    {
        return deptId;
    }

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

    public Long getParentId()
    {
        return parentId;
    }

    public void setParentId(Long parentId)
    {
        this.parentId = parentId;
    }

    public Long getRoleId()
    {
        return roleId;
    }

    public void setRoleId(Long roleId)
    {
        this.roleId = roleId;
    }

    @NotBlank(message = "登录账号不能为空")
    @Size(min = 0, max = 30, message = "登录账号长度不能超过30个字符")
    public String getLoginName()
    {
        return loginName;
    }

    public void setLoginName(String loginName)
    {
        this.loginName = loginName;
    }

    @Size(min = 0, max = 30, message = "用户昵称长度不能超过30个字符")
    public String getUserName()
    {
        return userName;
    }

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

    @Email(message = "邮箱格式不正确")
    @Size(min = 0, max = 50, message = "邮箱长度不能超过50个字符")
    public String getEmail()
    {
        return email;
    }

    public void setEmail(String email)
    {
        this.email = email;
    }

    @Size(min = 0, max = 11, message = "手机号码长度不能超过11个字符")
    public String getPhonenumber()
    {
        return phonenumber;
    }

    public void setPhonenumber(String phonenumber)
    {
        this.phonenumber = phonenumber;
    }

    public String getSex()
    {
        return sex;
    }

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

    public String getAvatar()
    {
        return avatar;
    }

    public void setAvatar(String avatar)
    {
        this.avatar = avatar;
    }

    public String getPassword()
    {
        return password;
    }

    public void setPassword(String password)
    {
        this.password = password;
    }

    public String getSalt()
    {
        return salt;
    }

    public void setSalt(String salt)
    {
        this.salt = salt;
    }

    public String getStatus()
    {
        return status;
    }

    public void setStatus(String status)
    {
        this.status = status;
    }

    public String getDelFlag()
    {
        return delFlag;
    }

    public void setDelFlag(String delFlag)
    {
        this.delFlag = delFlag;
    }

    public String getLoginIp()
    {
        return loginIp;
    }

    public void setLoginIp(String loginIp)
    {
        this.loginIp = loginIp;
    }

    public Date getLoginDate()
    {
        return loginDate;
    }

    public void setLoginDate(Date loginDate)
    {
        this.loginDate = loginDate;
    }

    public SysDept getDept()
    {
        if (dept == null)
        {
            dept = new SysDept();
        }
        return dept;
    }

    public SysCompany getCompany() {
        return company;
    }

    public void setCompany(SysCompany company) {
        this.company = company;
    }

    public void setDept(SysDept dept)
    {
        this.dept = dept;
    }

    public List<SysRole> getRoles()
    {
        return roles;
    }

    public void setRoles(List<SysRole> roles)
    {
        this.roles = roles;
    }

    public Long[] getRoleIds()
    {
        return roleIds;
    }

    public void setRoleIds(Long[] roleIds)
    {
        this.roleIds = roleIds;
    }

    public Long[] getPostIds()
    {
        return postIds;
    }

    public void setPostIds(Long[] postIds)
    {
        this.postIds = postIds;
    }

    private String workAddr;

    private String workSchedul;

    private String addrNum;

    private String schedulDetail;

    public String getWorkAddr() {
        return workAddr;
    }

    public void setWorkAddr(String workAddr) {
        this.workAddr = workAddr;
    }

    public String getWorkSchedul() {
        return workSchedul;
    }

    public void setWorkSchedul(String workSchedul) {
        this.workSchedul = workSchedul;
    }

    public String getAddrNum() {
        return addrNum;
    }

    public void setAddrNum(String addrNum) {
        this.addrNum = addrNum;
    }

    public String getSchedulDetail() {
        return schedulDetail;
    }

    public void setSchedulDetail(String schedulDetail) {
        this.schedulDetail = schedulDetail;
    }


    public SysUserExt getSysUserExt() {
        return sysUserExt;
    }

    public void setSysUserExt(SysUserExt sysUserExt) {
        this.sysUserExt = sysUserExt;
    }

    public String getIdType() {
        return idType;
    }

    public void setIdType(String idType) {
        this.idType = idType;
    }

    public String getIdNumber() {
        return idNumber;
    }

    public void setIdNumber(String idNumber) {
        this.idNumber = idNumber;
    }

    public String getAccountId() {
        return accountId;
    }

    public void setAccountId(String accountId) {
        this.accountId = accountId;
    }

    public String getIsAuthentication() {
        return isAuthentication;
    }

    public void setIsAuthentication(String isAuthentication) {
        this.isAuthentication = isAuthentication;
    }

    public Date getPersonAttestationTime() {
        return personAttestationTime;
    }

    public void setPersonAttestationTime(Date personAttestationTime) {
        this.personAttestationTime = personAttestationTime;
    }

    public String getReceiveUrlMobileNo() {
        return receiveUrlMobileNo;
    }

    public void setReceiveUrlMobileNo(String receiveUrlMobileNo) {
        this.receiveUrlMobileNo = receiveUrlMobileNo;
    }

    public String getIsConsignee() {
        return isConsignee;
    }

    public void setIsConsignee(String isConsignee) {
        this.isConsignee = isConsignee;
    }

    public String getIsOrgAuthentication() {
        return isOrgAuthentication;
    }

    public void setIsOrgAuthentication(String isOrgAuthentication) {
        this.isOrgAuthentication = isOrgAuthentication;
    }

    public Date getOrgAttestationTime() {
        return orgAttestationTime;
    }

    public void setOrgAttestationTime(Date orgAttestationTime) {
        this.orgAttestationTime = orgAttestationTime;
    }

    public List<SysUserExt> getSysUserExtLsit() {
        return sysUserExtLsit;
    }

    public void setSysUserExtLsit(List<SysUserExt> sysUserExtLsit) {
        this.sysUserExtLsit = sysUserExtLsit;
    }

    public String getIsSync() {
        return isSync;
    }

    public void setIsSync(String isSync) {
        this.isSync = isSync;
    }

    @Override
    public String toString() {
        return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
            .append("userId", getUserId())
            .append("deptId", getDeptId())
            .append("companyId", getDeptId())
            .append("loginName", getLoginName())
            .append("userName", getUserName())
            .append("email", getEmail())
            .append("phonenumber", getPhonenumber())
            .append("sex", getSex())
            .append("avatar", getAvatar())
            .append("password", getPassword())
            .append("salt", getSalt())
            .append("status", getStatus())
            .append("delFlag", getDelFlag())
            .append("loginIp", getLoginIp())
            .append("loginDate", getLoginDate())
            .append("createBy", getCreateBy())
            .append("createTime", getCreateTime())
            .append("updateBy", getUpdateBy())
            .append("updateTime", getUpdateTime())
            .append("remark", getRemark())
            .append("dept", getDept())
            .toString();
    }


}


