package com.xunmei.system.api.domain;

import java.util.Date;
import java.util.List;

import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;

import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.annotation.IdType;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import com.xunmei.common.core.web.domain.BaseEntity;
import org.bouncycastle.util.Fingerprint;

/**
 * 用户管理对象 sys_user
 *
 * @author xunmei
 * @date 2023-08-09
 */
@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
@TableName("sys_user")
@ApiModel(value = "SysUser对象" , description = "【请填写功能名称】")
public class SysUser extends BaseEntity {
    private static final long serialVersionUID = 1L;

    /**
     * $column.columnComment
     */
    @TableId
    @JsonSerialize(using = ToStringSerializer.class)
    private Long id;

    /**
     * 部门
     */
    @ApiModelProperty(value = "部门")
    private Long deptId;

    /**
     * 启用/禁用
     */
    @ApiModelProperty(value = "启用/禁用")
    private String isLock;

    /**
     * 岗位
     */
    @ApiModelProperty(value = "岗位")
    private Long jobId;

    /**
     * 用户名
     */
    @ApiModelProperty(value = "用户名")
    private String username;

    /**
     * 姓名
     */
    @ApiModelProperty(value = "姓名")
    private String name;

    /**
     * 机构
     */
    @ApiModelProperty(value = "机构")
    private Long orgId;

    /**
     * 手机
     */
    @ApiModelProperty(value = "手机")
    private String phone;

    /**
     * 修改人名称
     */
    @ApiModelProperty(value = "修改人名称")
    private String modifiedName;

    /**
     * 最后修改人id
     */
    @ApiModelProperty(value = "最后修改人id")
    private Long modifiedId;

    /**
     * 密码
     */
    @ApiModelProperty(value = "密码")
    private String password;

    /**
     * 盐值
     */
    @ApiModelProperty(value = "盐值")
    private String salt;

    /**
     * 删除
     */
    @ApiModelProperty(value = "删除")
    private Integer deleted;

    /**
     * 登录IP
     */
    @ApiModelProperty(value = "登录IP")
    private String lastIp;

    /**
     * 登录时间
     */
    @JsonFormat(pattern = "yyyy-MM-dd")
    @ApiModelProperty(value = "登录时间" )
    private Date lastTime;

    /**
     * 机构名称
     */
    @ApiModelProperty(value = "机构名称")
    private String orgName;

    /**
     * 机构路径
     */
    @ApiModelProperty(value = "机构路径")
    private String orgPath;

    /**
     * 头像
     */
    @ApiModelProperty(value = "头像")
    private String image;

    /**
     * 身份证
     */
    @ApiModelProperty(value = "身份证")
    private String card;

    /**
     * 性别
     */
    @ApiModelProperty(value = "性别")
    private String gender;

    /**
     * 工号
     */
    @ApiModelProperty(value = "工号")
    private String jobNumber;

    /**
     * 备注
     */
    @ApiModelProperty(value = "备注")
    private String note;

    /**
     * 是否签署 0未签署 1已签署
     */
    @ApiModelProperty(value = "是否签署 0未签署 1已签署")
    private String isSign;

    /**
     * 签署时间
     */
    @JsonFormat(pattern = "yyyy-MM-dd")
    @ApiModelProperty(value = "签署时间" )
    private Date signTime;

    /**
     * 签署协议
     */
    @ApiModelProperty(value = "签署协议")
    private Long agreementId;

    /**
     * 协议版本
     */
    @ApiModelProperty(value = "协议版本")
    private String signVersion;

    /**
     * 0：待审批，1：审批通过，2：审批不通过
     */
    @ApiModelProperty(value = "0：待审批，1：审批通过，2：审批不通过")
    private Long approveStatus;

    /**
     * 是否锁定,0:未锁定.1:已锁定
     */
    @ApiModelProperty(value = "是否锁定,0:未锁定.1:已锁定")
    private String locked;

    /**
     * 来源
     */
    @ApiModelProperty(value = "来源,0:系统添加.1:fjnx同步")
    private Integer source;

    /**
     * 同步人员的编码
     */
    @ApiModelProperty(value = "同步人员的编码")
    private String code;


    /** 机构对象 */
    @TableField(exist = false)
    private Org org;

    @TableField(exist = false)
    private Long[] roleIds;

    @TableField(exist = false)
    private List<SysRole> roles;
    public boolean isAdmin()
    {
        return isAdmin(this.getId());
    }
    public static boolean isAdmin(Long userId)
    {
        return userId != null && 1L == userId;
    }
    @Override
    public String toString() {
        return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)


                .append("id" , getId())


                .append("deptId" , getDeptId())


                .append("isLock" , getIsLock())


                .append("jobId" , getJobId())


                .append("username" , getUsername())


                .append("name" , getName())


                .append("orgId" , getOrgId())


                .append("phone" , getPhone())


                .append("createTime" , getCreateTime())


                .append("modifiedName" , getModifiedName())


                .append("updateTime" , getUpdateTime())


                .append("modifiedId" , getModifiedId())


                .append("password" , getPassword())


                .append("salt" , getSalt())


                .append("deleted" , getDeleted())


                .append("lastIp" , getLastIp())


                .append("lastTime" , getLastTime())


                .append("orgName" , getOrgName())


                .append("orgPath" , getOrgPath())


                .append("image" , getImage())


                .append("card" , getCard())


                .append("gender" , getGender())


                .append("jobNumber" , getJobNumber())


                .append("note" , getNote())


                .append("isSign" , getIsSign())


                .append("signTime" , getSignTime())


                .append("agreementId" , getAgreementId())


                .append("signVersion" , getSignVersion())


                .append("approveStatus" , getApproveStatus())


                .append("locked" , getLocked())


                .append("createBy" , getCreateBy())


                .append("updateBy" , getUpdateBy())
                .toString();
    }
}
