package com.ningdatech.carapi.archives.enums;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;

/**
 * 审核状态
 *
 * @author PoffyZhang
 */
@Getter
@AllArgsConstructor
@NoArgsConstructor
@ApiModel(value = "IsRandomEnum", description = "随机试卷-枚举")
public enum IsRandomEnum {
    /**
     * 非随机试卷
     */
    NOT_RANDOM_PAPER(0, "否"),

    /**
     * 随机试卷
     */
    RANDOM_PAPER(1, "是");

    /**
     * code
     */
    private Integer code;

    /**
     * 描述
     */
    private String desc;

    public String getDesc() {
        return desc;
    }

    public void setDesc(String desc) {
        this.desc = desc;
    }

    @ApiModelProperty("编码")
    public Integer getCode() {
        return this.code;
    }

    public static String getDescByCode(int code) {
        for (IsRandomEnum isRandomEnum : IsRandomEnum.values()) {
            if (isRandomEnum.getCode() == code) {
                return isRandomEnum.getDesc();
            }
        }
        return null;
    }

    public boolean eq(String val) {
        return this.name().equals(val);
    }

}
