package com.yunfeiyun.agmp.common.core.domain.entity;

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

import com.yunfeiyun.agmp.common.constant.Constants;
import com.yunfeiyun.agmp.common.core.domain.BaseEntity;
import com.yunfeiyun.agmp.common.xss.Xss;
import com.yunfeiyun.agmp.common.core.domain.model.IBaseUser;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import com.yunfeiyun.agmp.common.annotation.Excel;
import com.yunfeiyun.agmp.common.annotation.Excel.Type;
import com.yunfeiyun.agmp.common.annotation.Excels;

/**
 * 用户对象 sysUser
 * 
 * @author 杨晓辉
 */
public class SysUser extends BaseEntity implements IBaseUser
{
    private static final long serialVersionUID = 1L;

    /** 用户ID */
    @Excel(name = "用户序号", prompt = "用户编号")
    private String userId;

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

    /** 用户账号 */
    @Excel(name = "登录名称")
    private String userLoginname;

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

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

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

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

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


    /** 密码 */
    private String userLoginpwd;

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

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

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

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


    /** 用户创建者 */
    @Excel(name = "用户创建者")
    private String userCreator;

    /** 用户创建时间 */
    @Excel(name = "用户创建时间")
    private String userCreateddate;

    /** 用户更新者 */
    @Excel(name = "用户更新者")
    private String userModifier;

    /** 用户更新时间 */
    @Excel(name = "用户更新时间")
    private String userModifieddate;

    /** 用户备注 */
    @Excel(name = "用户备注")
    private String userRemark;


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

    /** 角色对象 */
    private List<SysRole> roles;

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

    /** 岗位组 */
    private Long[] postIds;

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

    /** 角色权限字符串 */
    private String roleKey;

    /** 系统id */
    private String sysId;

    /** 门户Userid */
    private String ptsUserid;

    public String getRoleKey() {
        return roleKey;
    }

    public void setRoleKey(String roleKey) {
        this.roleKey = roleKey;
    }

    public String getSysId() {
        return sysId;
    }

    public void setSysId(String sysId) {
        this.sysId = sysId;
    }

    public String getPtsUserid() {
        return ptsUserid;
    }

    public void setPtsUserid(String ptsUserid) {
        this.ptsUserid = ptsUserid;
    }



    public SysUser()
    {

    }

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

    public String getUserId()
    {
        return userId;
    }

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

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

    public static boolean isAdmin(String userId)
    {
        return userId != null && Constants.ADMIN_KEY.equals(userId);
    }

    public String getDeptId()
    {
        return deptId;
    }

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

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

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

    @Xss(message = "用户账号不能包含脚本字符")
    @NotBlank(message = "用户账号不能为空")
    @Size(min = 0, max = 30, message = "用户账号长度不能超过30个字符")
    public String getUserLoginname()
    {
        return userLoginname;
    }

    public void setUserLoginname(String userLoginname)
    {
        this.userLoginname = userLoginname;
    }

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

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

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

    public void setUserMobile(String userMobile)
    {
        this.userMobile = userMobile;
    }

    public String getUserSex()
    {
        return userSex;
    }

    public void setUserSex(String userSex)
    {
        this.userSex = userSex;
    }


    public String getUserAvatar()
    {
        return userAvatar;
    }

    public void setUserAvatar(String userAvatar)
    {
        this.userAvatar = userAvatar;
    }


    public String getUserLoginpwd()
    {
        return userLoginpwd;
    }

    public void setUserLoginpwd(String userLoginpwd)
    {
        this.userLoginpwd = userLoginpwd;
    }

    public String getUserLockstatus()
    {
        return userLockstatus;
    }

    public void setUserLockstatus(String userLockstatus)
    {
        this.userLockstatus = userLockstatus;
    }

    public String getUserDelstatus()
    {
        return userDelstatus;
    }

    public void setUserDelstatus(String userDelstatus)
    {
        this.userDelstatus = userDelstatus;
    }

    public String getUserLastloginip()
    {
        return userLastloginip;
    }

    public void setUserLastloginip(String userLastloginip)
    {
        this.userLastloginip = userLastloginip;
    }

    public String getUserLastlogindate()
    {
        return userLastlogindate;
    }

    public void setUserLastlogindate(String userLastlogindate)
    {
        this.userLastlogindate = userLastlogindate;
    }

    public SysDept getDept()
    {
        return dept;
    }

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

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

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

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

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

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

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

    public String getRoleId()
    {
        return roleId;
    }

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


    public String getUserCreator()
    {
        return userCreator;
    }

    public void setUserCreator(String userCreator)
    {
        this.userCreator = userCreator;
    }

    public String getUserCreateddate()
    {
        return userCreateddate;
    }

    public void setUserCreateddate(String userCreateddate)
    {
        this.userCreateddate = userCreateddate;
    }

    public String getUserModifier()
    {
        return userModifier;
    }

    public void setUserModifier(String userModifier)
    {
        this.userModifier = userModifier;
    }

    public String getUserModifieddate()
    {
        return userModifieddate;
    }

    public void setUserModifieddate(String userModifieddate)
    {
        this.userModifieddate = userModifieddate;
    }

    public String getUserRemark()
    {
        return userRemark;
    }

    public void setUserRemark(String userRemark)
    {
        this.userRemark = userRemark;
    }

    @Override
    public String toString() {
        return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
            .append("userId", getUserId())
            .append("deptId", getDeptId())
            .append("userLoginname", getUserLoginname())
            .append("userName", getUserName())
            .append("userEmail", getUserEmail())
            .append("userMobile", getUserMobile())
            .append("userSex", getUserSex())
            .append("userLoginpwd", getUserLoginpwd())
            .append("userLockstatus", getUserLockstatus())
            .append("userDelstatus", getUserDelstatus())
            .append("userLastloginip", getUserLastloginip())
            .append("userLastlogindate", getUserLastlogindate())
            .append("userCreator", getUserCreator())
            .append("userCreateddate", getUserCreateddate())
            .append("userModifier", getUserModifier())
            .append("userModifieddate", getUserModifieddate())
            .append("userRemark", getUserRemark())
            .append("dept", getDept())
            .toString();
    }
}
