package com.zhyc.module.work.enums;


/**
 * 业务类型枚举
 */
public enum BizType {

    IMMUNITY(1, "免疫"),
    HEALTH_CARE(2, "保健"),
    TRANSFER_GROUP(3, "转群"),
    WEIGHING(4, "称重"),
    BREEDING(5, "配种"),
    DRY_MILK(6, "干奶"),
    ELIMINATION(7, "淘汰"),
    DISINFECTION(8, "消毒"),
    FEEDING(9, "饲喂");

    private final int code;
    private final String desc;

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

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

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