package com.haha.common.enums;

public enum RecognizeConsumeType {

    NO_CONSUME(1, "无消费"),
    CONSUMED(0, "有消费");

    private final int code;
    private final String description;

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

    public int getCode() {
        return code;
    }

    public String getDescription() {
        return description;
    }

    public static RecognizeConsumeType fromCode(Integer code) {
        if (code == null) {
            return null;
        }
        for (RecognizeConsumeType type : values()) {
            if (type.code == code) {
                return type;
            }
        }
        return null;
    }

    public static boolean isNoConsume(Integer code) {
        return code != null && code == NO_CONSUME.code;
    }
}
