package com.ruoyi.common.core.domain.entity;

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

import com.alibaba.fastjson.JSONObject;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.ruoyi.common.core.domain.dto.SchoolGradeClassesDto;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import com.ruoyi.common.annotation.Excel;
import com.ruoyi.common.annotation.Excel.ColumnType;
import com.ruoyi.common.annotation.Excel.Type;
import com.ruoyi.common.annotation.Excels;
import com.ruoyi.common.core.domain.BaseEntity;
import com.ruoyi.common.xss.Xss;

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

    private String customSchoolName;
    private String customClassName;
    private Boolean isK9Sensitive;
    private Integer gaokaoYear;

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

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

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

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

    /** 用户邮箱 */
    @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 password2;

    /** 帐号状态（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 List<SysRole> roles;

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

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

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

    private String userType;

    private Long currentRoleId;

    private SchoolGradeClassesDto school;

    /** 是否显示提前批 */
    private Integer isPreEnrollSupport;
    private Integer isBind;
    private Integer scoreLock;

    /** 学校 */
//    @Excel(name = "学校")
    private Long schoolId;

    /** 年级 */
//    @Excel(name = "年级")
    private Long gradeId;

    /** 班级ID */
//    @Excel(name = "班级ID")
    private Long classId;
    private Long cardId;

    /** 班级/入学年份 */
//    @Excel(name = "学年")
    private Integer year;

    private String provinceName;
    private String cityName;
    private String areaName;
    private String schoolName;

    private String newgaokaoType;
    private String mode;//[物理,化学,生物]对应groupId
    private Integer groupId;
    private Integer score;
    private Integer seatInput;
    private List<String> provinceNames;
    private JSONObject voluntaryParam;
    private String examType;
    private String examMajor;
    private String examMajorName;
    private Boolean enableAuthModify;

    public Integer getIsPreEnrollSupport() {
        return isPreEnrollSupport;
    }

    public void setIsPreEnrollSupport(Integer isPreEnrollSupport) {
        this.isPreEnrollSupport = isPreEnrollSupport;
    }

    /** 创建时间 */
    @JsonFormat(pattern = "yyyy-MM-dd")
    private Date outDate;

    public String getExamType() {
        return examType;
    }

    public void setExamType(String examType) {
        this.examType = examType;
    }

    public String getCustomSchoolName() {
        return customSchoolName;
    }

    public void setCustomSchoolName(String customSchoolName) {
        this.customSchoolName = customSchoolName;
    }

    public String getCustomClassName() {
        return customClassName;
    }

    public void setCustomClassName(String customClassName) {
        this.customClassName = customClassName;
    }

    public Integer getGaokaoYear() {
        return gaokaoYear;
    }

    public void setGaokaoYear(Integer gaokaoYear) {
        this.gaokaoYear = gaokaoYear;
    }

    public JSONObject getVoluntaryParam() {
        return voluntaryParam;
    }

    public void setVoluntaryParam(JSONObject voluntaryParam) {
        this.voluntaryParam = voluntaryParam;
    }

    public Date getOutDate() {
        return outDate;
    }

    public void setOutDate(Date outDate) {
        this.outDate = outDate;
    }

    public List<String> getProvinceNames() {
        return provinceNames;
    }

    public SysUser setProvinceNames(List<String> provinceNames) {
        this.provinceNames = provinceNames;
        return this;
    }

    public Integer getScoreLock() {
        return scoreLock;
    }

    public SysUser setScoreLock(Integer scoreLock) {
        this.scoreLock = scoreLock;
        return this;
    }

    public String getMode() {
        return mode;
    }

    public void setMode(String mode) {
        this.mode = mode;
    }

    public Long getCardId() {
        return cardId;
    }

    public void setCardId(Long cardId) {
        this.cardId = cardId;
    }

    public String getProvinceName() {
        return provinceName;
    }

    public void setProvinceName(String provinceName) {
        this.provinceName = provinceName;
    }

    public String getCityName() {
        return cityName;
    }

    public void setCityName(String cityName) {
        this.cityName = cityName;
    }

    public String getAreaName() {
        return areaName;
    }

    public void setAreaName(String areaName) {
        this.areaName = areaName;
    }

    public String getSchoolName() {
        return schoolName;
    }

    public void setSchoolName(String schoolName) {
        this.schoolName = schoolName;
    }

    public SysUser()
    {

    }

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

    public String getNewgaokaoType() {
        return newgaokaoType;
    }

    public void setNewgaokaoType(String newgaokaoType) {
        this.newgaokaoType = newgaokaoType;
    }

    public Long getSchoolId() {
        return schoolId;
    }

    public void setSchoolId(Long schoolId) {
        this.schoolId = schoolId;
    }

    public Long getGradeId() {
        return gradeId;
    }

    public void setGradeId(Long gradeId) {
        this.gradeId = gradeId;
    }

    public Long getClassId() {
        return classId;
    }

    public void setClassId(Long classId) {
        this.classId = classId;
    }

    public Integer getYear() {
        return year;
    }

    public void setYear(Integer year) {
        this.year = year;
    }

    public Integer getIsBind() {
        return isBind;
    }

    public SysUser setIsBind(Integer isBind) {
        this.isBind = isBind;
        return this;
    }

    public SchoolGradeClassesDto getSchool() {
        return school;
    }

    public void setSchool(SchoolGradeClassesDto school) {
        this.school = school;
    }

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

    public Long getUserId()
    {
        return userId;
    }

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

    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;
    }

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

    public void setNickName(String nickName)
    {
        this.nickName = nickName;
    }

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

    // TODO MF 如何标识待定
    public String getCode()
    {
        return String.valueOf(userId);
    }

    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 SysUser setPhonenumber(String phonenumber)
    {
        this.phonenumber = phonenumber;
        return this;
    }

    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 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()
    {
        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 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;
    }

    public Long getRoleId()
    {
        return roleId;
    }

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

    public String getUserType() {
        return userType;
    }

    public void setUserType(String userType) {
        this.userType = userType;
    }

    public Long getCurrentRoleId() {
        return currentRoleId;
    }

    public void setCurrentRoleId(Long currentRoleId) {
        this.currentRoleId = currentRoleId;
    }

    public String getPassword2() {
        return password2;
    }

    public void setPassword2(String password2) {
        this.password2 = password2;
    }

    public Integer getGroupId() {
        return groupId;
    }

    public void setGroupId(Integer groupId) {
        this.groupId = groupId;
    }

    public Integer getScore() {
        return score;
    }

    public void setScore(Integer score) {
        this.score = score;
    }

    public Integer getSeatInput() {
        return seatInput;
    }

    public void setSeatInput(Integer seatInput) {
        this.seatInput = seatInput;
    }

    public Boolean getIsK9Sensitive() {
        return isK9Sensitive;
    }

    public void setIsK9Sensitive(Boolean isK9Sensitive) {
        this.isK9Sensitive = isK9Sensitive;
    }

    public String getExamMajor() {
        return examMajor;
    }

    public void setExamMajor(String examMajor) {
        this.examMajor = examMajor;
    }

    public String getExamMajorName() {
        return examMajorName;
    }

    public void setExamMajorName(String examMajorName) {
        this.examMajorName = examMajorName;
    }

    public Boolean getEnableAuthModify() {
        return enableAuthModify;
    }

    public void setEnableAuthModify(Boolean enableAuthModify) {
        this.enableAuthModify = enableAuthModify;
    }

    @Override
    public String toString() {
        return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
            .append("userId", getUserId())
            .append("deptId", getDeptId())
            .append("userName", getUserName())
            .append("nickName", getNickName())
            .append("email", getEmail())
            .append("phonenumber", getPhonenumber())
            .append("sex", getSex())
            .append("avatar", getAvatar())
            .append("password", getPassword())
            .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();
    }
}
