package com.zcloud.basic.info.domain.model;

import cn.hutool.core.collection.CollUtil;
import com.alibaba.cola.domain.Entity;
import com.alibaba.cola.exception.BizException;
import com.jjb.saas.framework.domain.model.BaseE;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.apache.commons.lang.StringUtils;

import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.Date;
import java.util.List;

/**
* web-domain
* @Author SondonYong
* @Date 2025-10-31 09:50:29
*/
@Data
@Entity
@EqualsAndHashCode(callSuper = true)
public class UserQualificationInfoE extends BaseE {
    //主键
    private Long id;
    //业务主键id
    private String userQualificationinfoId;
    //企业id
    private Long corpinfoId;
    //用户id
    private Long userId;
    //资质名称
    private String qualificationName;
    //证书编号
    private String certificateNo;

    // 资质类型,1-特种作业证书,2-安全人员证书
    private Integer qualificationinfoType;
    // 证书作业类别-字典编码
    private String qualificationinfoCategory;
    // 证书作业类别名称
    private String qualificationinfoCategoryName;
    // 操作项目-字典编码(特种有,安全没有)
    private String operatingProject;
    // 操作项目名称(特种有,安全没有)
    private String operatingProjectName;


    //是否删除
    private String deleteEnum;
    //租户id
    private Long tenantId;
    //组织id
    private Long orgId;
    //版本号
    private Integer version;
    //创建时间
    private LocalDateTime createTime;
    //修改时间
    private LocalDateTime updateTime;
    //创建人id
    private Long createId;
    //修改人id
    private Long updateId;
    //创建人
    private String createName;
    //修改人
    private String updateName;
    //备注
    private String remarks;
    //环境
    private String env;

    // 验重
    public void checkNull(int size){
        if(size > 0){
            throw new BizException("该证书编号重复");
        }
    }

    // 校验特种作业证书是否有操作项目
    public void checkOperatingProject(UserQualificationInfoE entity){
        if(entity == null){
            throw new BizException("对象不能为空。");
        }
        if(entity.getQualificationinfoType() == 1){
            if(StringUtils.isEmpty(entity.getOperatingProject()) || StringUtils.isEmpty(entity.getOperatingProjectName())){
                throw new BizException("操作项目不能为空。");
            }
        }
    }
}

