package com.ruoyi.common.core.domain;

import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.TableField;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.ruoyi.common.annotation.Excel;
import com.ruoyi.common.constant.DeletedEnum;
import com.ruoyi.common.utils.JWTUtil;
import com.ruoyi.common.utils.SecurityUtils;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.io.Serializable;
import java.util.Date;
import java.util.List;

/**
 * Entity双控系统基类
 *
 * @author ruoyi
 */
@Data
public class GnhzBaseEntity implements Serializable
{


    private static final long serialVersionUID = 8887499842971074427L;
    /** 删除标识：0正常，1已删除 */
    @Excel(name = "删除标识：0正常，1已删除")
    @ApiModelProperty(value = "删除标识：0正常，1已删除",hidden = true)
    @TableField(value = "is_del")
    private Integer isDel;

    /** 创建时间 */
    @JsonFormat(pattern = "yyyy-MM-dd")
    @Excel(name = "创建时间", width = 30, dateFormat = "yyyy-MM-dd")
    @ApiModelProperty(value = "创建时间",hidden = true)
    @TableField(value = "create_date", fill = FieldFill.INSERT)
    private Date createDate;

    /** 创建人ID */
    @Excel(name = "创建人ID")
    @ApiModelProperty(value = "创建人ID",hidden = true)
    @TableField(value = "create_user_id", fill = FieldFill.INSERT)
    private Long createUserId;

    /** 更新时间 */
    @JsonFormat(pattern = "yyyy-MM-dd")
    @Excel(name = "更新时间", width = 30, dateFormat = "yyyy-MM-dd")
    @ApiModelProperty(value = "更新时间",hidden = true)
    @TableField(value = "update_date", fill = FieldFill.UPDATE)
    private Date updateDate;

    /** 更新人 */
    @Excel(name = "更新人")
    @ApiModelProperty(value = "更新人",hidden = true)
    @TableField(value = "update_user_id", fill = FieldFill.UPDATE)
    private Long updateUserId;

    /** 企业编码 */
    @Excel(name = "企业编码")
    @ApiModelProperty(value = "企业编码",hidden = true)
    @TableField(value = "company_code")
    private String companyCode;



    @Excel(name = "区域名称")
    @ApiModelProperty(value = "区域名称",hidden = true)
    @TableField(exist = false)
    private String areaName;

    @ApiModelProperty(value = "区域ID",hidden = true)
    @Excel(name = "区域ID")
    @TableField(exist = false)
    private Long areaId;

    @Excel(name = "管控对象名称")
    @ApiModelProperty(value = "区域名称",hidden = true)
    @TableField(exist = false)
    private String hazardName;


    @Excel(name = "分析单元名称")
    @ApiModelProperty(value = "分析单元名称",hidden = true)
    @TableField(exist = false)
    private String riskUnitName;


    @Excel(name = "风险事件名称")
    @ApiModelProperty(value = "风险事件名称",hidden = true)
    @TableField(exist = false)
    private String riskEventName;


    @Excel(name = "风险事件内容")
    @ApiModelProperty(value = "风险事件内容",hidden = true)
    @TableField(exist = false)
    private String riskEventContent;

    @Excel(name = "管控措施描述")
    @ApiModelProperty(value = "管控措施描述",hidden = true)
    @TableField(exist = false)
    private String riskMeasureDesc;

    @Excel(name = "隐患排查内容(风险管控措施表)")
    @ApiModelProperty(value = "隐患排查内容(风险管控措施表)",hidden = true)
    @TableField(exist = false)
    private String troubleshootContentRiskMeasure;

    @Excel(name = "隐患排查内容(排查要求Task表)")
    @ApiModelProperty(value = "隐患排查内容(排查要求Task表)",hidden = true)
    @TableField(exist = false)
    private String troubleshootContentTask;

//    @Excel(name = "APP账号数据隔离，登录用户ID")
    @ApiModelProperty(value = "APP账号数据隔离，登录用户ID",hidden = true)
    @TableField(exist = false)
    private Long dataUserId;


//    @Excel(name = "APP账号数据隔离，登录用户岗位ID")
    @ApiModelProperty(value = "APP账号数据隔离，登录用户岗位ID",hidden = true)
    @TableField(exist = false)
    private List<Long> postIdList;


    public void setCreateDefault(){
        this.setCreateUserId(SecurityUtils.getUserId());
        this.setCreateDate(new Date());
        this.setUpdateUserId(SecurityUtils.getUserId());
        this.setUpdateDate(new Date());
        this.setIsDel(DeletedEnum.VALID.getValue());
        this.setCompanyCode(SecurityUtils.getUserCompanyCode());

    }

    public void setCreateDefaultForApp(){
        this.setCreateUserId(Long.parseLong(JWTUtil.getUserId()));
        this.setCreateDate(new Date());
        this.setUpdateUserId(Long.parseLong(JWTUtil.getUserId()));
        this.setUpdateDate(new Date());
        this.setIsDel(DeletedEnum.VALID.getValue());
        this.setCompanyCode(JWTUtil.getCompanyCode());

    }

    public void setUpdateDefaultForApp(){
        this.setUpdateUserId(Long.parseLong(JWTUtil.getUserId()));
        this.setUpdateDate(new Date());
    }

    public void setUpdateDefault(){
        this.setUpdateUserId(SecurityUtils.getUserId());
        this.setUpdateDate(new Date());
    }
}
