package com.zhyc.module.biosafety.enums;

/**
 * 消毒方式枚举
 */
public enum DisinfectionMethod {

    SPRAY(0, "喷雾"),
    SCATTER(1, "撒布"),
    SOAK(2, "浸泡"),
    FUMIGATE(3, "熏蒸"),
    OTHER(4, "其他");

    private final int code;
    private final String desc;

    DisinfectionMethod(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 (DisinfectionMethod method : values()) {
            if (method.code == code) {
                return method.desc;
            }
        }
        return "";
    }

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

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