package cn.estsh.i3plus.pojo.platform.bean;

import cn.estsh.i3plus.pojo.base.bean.BaseBean;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiParam;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import javax.persistence.Transient;
import java.util.List;

/**
 * @Description : 账号登陆表
 * @Reference :
 * @Author : alwaysfrin
 * @CreateDate : 2018-10-11 11:02
 * @Modify:
 **/
@Data
@Entity
@DynamicInsert
@DynamicUpdate
@EqualsAndHashCode(callSuper = true)
@Table(name="SYS_USER")
@Api(value="账号登陆表",description = "账号登陆系统账户。")
public class SysUser extends BaseBean {

    private static final long serialVersionUID = 3721769401146979123L;
    @Column(name="USER_INFO_ID")
    @ApiParam(value ="人员ID" , example = "-1")
    @JsonSerialize(using = ToStringSerializer.class)
    private Long userInfoId;

    @Column(name="LANGUAGE_CODE")
    @ApiParam(value ="用户语言")
    private String languageCode;

    @Column(name="USER_NAME_RDD")
    @ApiParam(value ="用户名称" , access ="账号名称")
    private String userName;

    @Column(name="USER_LOGIN_NAME")
    @ApiParam(value ="登陆名称" , access ="登陆名称")
    private String userLoginName;

    @Column(name="USER_EMP_NO")
    @ApiParam(value ="工号")
    private String userEmpNo;

    @Deprecated // 废弃密码新 , 使用ID作为密码信息, 改密码作为数据传输使用
    @Column(name="USER_LOGIN_PASSWORD")
    @ApiParam(value ="登陆密码")
    private String userLoginPassword;

    @Column(name="USER_LOGIN_PASSWORD_ID")
    @ApiParam(value ="密码ID" , example = "-1")
    @JsonSerialize(using = ToStringSerializer.class)
    private Long userLoginPasswordId;

    @Column(name="USER_TYPE")
    @ApiParam(value ="账号类型（枚举，待定）" , example ="-1")
    private Integer userType;

    @Column(name="USER_EMAIL")
    @ApiParam(value ="邮箱" , access ="邮箱")
    private String userEmail;

    @Column(name="USER_PHONE")
    @ApiParam(value ="手机号" , access ="手机号")
    private String userPhone;

    @Column(name="USER_WECHAT_NO")
    @ApiParam(value ="微信号")
    private String userWeChatNo;

    @Column(name="USER_STATUS")
    @ApiParam(value ="账号状态(枚举：1正常,2冻结使用,3账号异常,4离职，5服务到期)" , example ="-1")
    private Integer userStatus;

    @Column(name="USER_LOGIN_NUM")
    @ApiParam(value ="登录次数",example = "0")
    private Integer userLoginNum;

    @Deprecated
    @Column(name="USER_LOGIN_LAST_DATE_TIME")
    @ApiParam(value ="账号最后登录时间")
    private String userLoginLastDateTime;

/********************************** 关系信息 ********************************/

    @Column(name="DEPARTMENT_ID")
    @ApiParam(value ="部门ID" , example ="-1")
    @JsonSerialize(using = ToStringSerializer.class)
    private Long departmentId;

    @Column(name="ORGANIZE_ID")
    @ApiParam(value ="组织ID" , example = "0")
    @JsonSerialize(using = ToStringSerializer.class)
    private Long organizeId;


/********************************** 冗余信息 ********************************/

    @Column(name="DEPARTMENT_NAME_RDD")
    @ApiParam(value ="部门名称" , access ="部门名称")
    private String departmentNameRdd;

    @Column(name="ORGANIZE_NAME_RDD")
    @ApiParam(value ="组织名称" , access ="组织名称")
    private String organizeNameRdd;

//    @Lob
//    @Column(name="ROLE_NAMES_RDD")
//    @ApiParam(value ="角色名称集合")
//    private String roleNamesRdd;
//
//    @Lob
//    @Column(name="DEPARTMENT_NAMES_RDD")
//    @ApiParam(value ="部门名称集合")
//    private String departmentNamesRdd;
//
//    @Lob
//    @Column(name="ORGANIZE_NAMES_RDD")
//    @ApiParam(value ="组织名称集合")
//    private String organizeNamesRdd;

/********************************** 非数据库信息 ********************************/

    @Transient
    @ApiParam(value ="用户部门信息")
    private SysDepartment department;

    @Transient
    @ApiParam(value ="用户组织信息")
    private SysOrganize organize;

    @Transient
    @ApiParam(value ="账号所有操作组织信息")
    private List<SysOrganize> organizeList;

    @Transient
    @ApiParam(value ="账号所有操作部门 Id 集合")
    private List<String> departmentIdList;

    @Transient
    @ApiParam(value ="账号所有操作部门信息")
    private List<SysDepartment> departmentList;

    @Transient
    @ApiParam(value ="角色ID" , example = "0")
    @JsonSerialize(using = ToStringSerializer.class)
    private Long roleId;

    @Transient
    @ApiParam(value ="角色ID集合" , example = "0")
    @JsonSerialize(using = ToStringSerializer.class)
    private List<String> roleIdList;

    @Transient
    @ApiParam(value ="账号所有角色信息")
    private List<SysRole> roleList;

    @Transient
    @ApiParam(value ="账号所有操作权限信息")
    private List<SysMenu> menuList;

    /*** test ***/
//    @Lob
//    @Basic(fetch=FetchType.LAZY)
//    @Column(name = "CONTENT", columnDefinition = "BLOB")
//    private byte[] content;
//
//    @Lob
//    @Basic(fetch=FetchType.LAZY)
//    @Column(name="REMARK", columnDefinition="CLOB")
//    private String remark;
}
