package com.haha.common.enums;

import com.haha.common.vo.StatusLabel;

public enum ApplyScopeEnum {

    ALL_SHOP(1, "全部门店", "primary"),
    SPECIFIED_SHOP(2, "指定门店", "warning");

    private final int code;
    private final String label;
    private final String color;

    ApplyScopeEnum(int code, String label, String color) {
        this.code = code;
        this.label = label;
        this.color = color;
    }

    public int getCode() {
        return code;
    }

    public String getLabel() {
        return label;
    }

    public String getColor() {
        return color;
    }

    public StatusLabel getStatusLabel() {
        return new StatusLabel(label, color);
    }

    public static StatusLabel getLabelByCode(Integer code) {
        if (code == null) {
            return StatusLabel.info("未知");
        }
        for (ApplyScopeEnum scope : values()) {
            if (scope.code == code) {
                return scope.getStatusLabel();
            }
        }
        return StatusLabel.info("未知");
    }

    public static ApplyScopeEnum getByCode(Integer code) {
        if (code == null) {
            return null;
        }
        for (ApplyScopeEnum scope : values()) {
            if (scope.code == code) {
                return scope;
            }
        }
        return null;
    }
}
