package com.ylx.order.enums;

public enum AuditStatusEnum {
    /**
     * 待审核
     */
    PENDING(0, "待审核"),

    /**
     * 通过
     */
    APPROVED(1, "通过"),

    /**
     * 拒绝
     */
    REJECTED(2, "拒绝");

    private final Integer code;
    private final String desc;

    AuditStatusEnum(Integer code, String desc) {
        this.code = code;
        this.desc = desc;
    }

    public Integer getCode() {
        return code;
    }

    public String getDesc() {
        return desc;
    }

    /**
     * 根据code获取枚举
     * @param code 状态码
     * @return 枚举对象，找不到返回null
     */
    public static AuditStatusEnum fromCode(Integer code) {
        if (code == null) {
            return null;
        }
        for (AuditStatusEnum status : values()) {
            if (status.code.equals(code)) {
                return status;
            }
        }
        return null;
    }
}
