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 = "AuditStateEnum", description = "审核状态-枚举")
public enum AuditStateEnum {
    /**
     * 待审核
     */
    AUDIT(1, "待审核"),

    /**
     * 审核成功
     */
    AUDIT_SUCCESS(2, "审核成功"),

    /**
     * 审核失败
     */
    AUDIT_FAIL(3, "审核失败");

    /**
     * code
     */
    private Integer code;

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

    public String getDesc() {
        return desc;
    }

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

    @ApiModelProperty(value = "编码", allowableValues = "1，2，3", example = "1")
    public Integer getCode() {
        return this.code;
    }

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

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

}
