package com.zhyc.module.biosafety.enums;


/**
 * 检疫状态枚举
 */
public enum QuarantineStatus {

    PENDING(0, "送检中"),
    TESTED(1, "已检测");

    private final int code;
    private final String desc;

    QuarantineStatus(int code, String desc) {
        this.code = code;
        this.desc = desc;
    }

    public int getCode() {
        return code;
    }

    public String getDesc() {
        return desc;
    }

    /**
     * 根据code获取描述
     */
    public static String getDescByCode(Integer code) {
        if (code == null) {
            return "";
        }
        for (QuarantineStatus status : values()) {
            if (status.code == code) {
                return status.desc;
            }
        }
        return "";
    }

    /**
     * 根据code获取枚举
     */
    public static QuarantineStatus getByCode(Integer code) {
        if (code == null) {
            return null;
        }
        for (QuarantineStatus status : values()) {
            if (status.code == code) {
                return status;
            }
        }
        return null;
    }

    /**
     * 根据描述获取code
     */
    public static Integer getCodeByDesc(String desc) {
        if (desc == null || desc.trim().isEmpty()) {
            return null;
        }
        for (QuarantineStatus status : values()) {
            if (status.desc.equals(desc)) {
                return status.code;
            }
        }
        return null;
    }
}