package com.agileboot.common.core.enums.common;

import com.agileboot.common.core.enums.DictionaryEnum;
import com.agileboot.common.core.enums.dictionary.CssTag;
import com.agileboot.common.core.enums.dictionary.Dictionary;
import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * 除非表有特殊指明的话，一般用这个枚举代表 status字段
 *
 * @author valarchie
 */
@Dictionary(name = "common.status")
@Getter
@AllArgsConstructor
public enum StatusEnum implements DictionaryEnum<Integer> {
    /**
     * 开关状态
     */
    ENABLE(1, "正常", CssTag.PRIMARY),
    DISABLE(0, "停用", CssTag.DANGER);

    private final Integer value;
    private final String desc;
    private final String cssTag;

    public static Integer getDescByValue(Integer value) {
        for (StatusEnum item : StatusEnum.values()) {
            if (item.value.equals(value)) {
                return item.value;
            }
        }
        return null;
    }

}
