package com.xy.utils.enums;


import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.ToString;

/**
 * 设备缺货状态 1 缺货 2 不缺货
 *
 * @author 谭斌
 */
@Getter
@ToString
@AllArgsConstructor
public enum DeviceStockStatus {


    LACK(1, "缺货"),
    ENOUGH(2, "不缺货");

    /**
     * 编码值
     */
    private Integer code;

    /**
     * 描述
     */
    private String description;


    /**
     * 通过code获取enum
     *
     * @param code
     * @return
     */
    public static DeviceStockStatus getEnumByCode(Integer code) {
        DeviceStockStatus[] values = values();
        for (DeviceStockStatus value : values) {
            if (value.getCode().equals(code)) {
                return value;
            }
        }
        return null;
    }
}
