package com.lesingle.creation.common.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * 有效状态枚举
 */
@Getter
@AllArgsConstructor
public enum ValidStateEnum {

    VALID(1, "有效"),
    INVALID(2, "失效");

    private final Integer code;
    private final String desc;

    public static ValidStateEnum getByCode(Integer code) {
        if (code == null) {
            return VALID;
        }
        for (ValidStateEnum state : values()) {
            if (state.getCode().equals(code)) {
                return state;
            }
        }
        return VALID;
    }
}
