package com.cool.store.enums;

/**
 * @Author suzhuhong
 * @Date 2025/6/24 10:46
 * @Version 1.0
 */
public enum ViolationEnum {

    COOLING_TIME_EXCEEDED(1, "冷却时间小于15分钟或大于25分钟未放入冷藏柜"),
    STORAGE_TIME_EXCEEDED(2, "冰箱内取出时间距离预炸完成时间超过24小时"),;


    private final int code;
    private final String description;

    ViolationEnum(int code, String description) {
        this.code = code;
        this.description = description;
    }

    public int getCode() {
        return code;
    }

    public String getDescription() {
        return description;
    }

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

    /**
     * 根据code获取描述
     */
    public static String getDescriptionByCode(int code) {
        ViolationEnum violation = getByCode(code);
        return violation != null ? violation.description : "";
    }
}
