package com.ningdatech.pmapi.projectlib.enumeration;

import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import org.apache.commons.lang3.StringUtils;

import java.util.Objects;

/**
 *
 * 预警填报类型枚举
 * @author CMM
 * @since 2023/02/24 16:14
 */
@Getter
@NoArgsConstructor
@AllArgsConstructor
public enum WarningOperationTypeEnum {
    /**
     * 预警实施类型枚举
     */
    CHUYAN(1, "项目初验",ProjectStatusEnum.UNDER_CONSTRUCTION.getCode()),
    ZHONGYAN(2, "项目终验",ProjectStatusEnum.TO_BE_FINALLY_INSPECTED.getCode());

    private Integer code;
    private String desc;

    //对应的 待提交时的项目状态
    private Integer projectStutas;

    public static String getDescByCode(Integer code) {
        if (Objects.isNull(code)) {
            return StringUtils.EMPTY;
        }
        for (WarningOperationTypeEnum t : WarningOperationTypeEnum.values()) {
            if (code.equals(t.getCode())) {
                return t.desc;
            }
        }
        return StringUtils.EMPTY;
    }

    public static WarningOperationTypeEnum getByCode(Integer code) {
        if (Objects.isNull(code)) {
            return null;
        }
        for (WarningOperationTypeEnum t : WarningOperationTypeEnum.values()) {
            if (code.equals(t.getCode())) {
                return t;
            }
        }
        return null;
    }
}
