package com.crunii.micro.common.enums;

import com.crunii.micro.common.exception.BusinessException;

/**
 * @author lmlksy
 * @date 2023/11/22 15:26
 */
public enum AuditStatusEnums {
    REJECT(0, "不通过"),
    PASS(1, "通过"),
    WAIT_AUDIT(2, "待审核"),
    PUBLISHED(3, "已公示");

    private final Integer statusCode;
    private final String statusDescription;

    AuditStatusEnums(Integer statusCode, String statusDescription) {
        this.statusCode = statusCode;
        this.statusDescription = statusDescription;
    }

    public Integer getStatusCode() {
        return statusCode;
    }

    public String getStatusDescription() {
        return statusDescription;
    }

    public static String getByCode(Integer code) {
        for (AuditStatusEnums status : values()) {
            if (status.getStatusCode() != null && status.getStatusCode() == code) {
                return status.getStatusDescription();
            }
        }
        return null;
    }
    public static Integer getByDescription(String description) {
        for (AuditStatusEnums status : values()) {
            if (status.getStatusDescription().equals(description)) {
                return status.getStatusCode();
            }
        }
        return null;
    }
}
