package com.haha.common.enums;

public enum ProductAuditStatus {

    APPROVED(1, "已通过"),
    REJECTED(2, "已拒绝"),
    LISTED(3, "已上架");

    private final int code;
    private final String description;

    ProductAuditStatus(int code, String description) {
        this.code = code;
        this.description = description;
    }

    public int getCode() {
        return code;
    }

    public String getDescription() {
        return description;
    }

    public static ProductAuditStatus fromCode(Integer code) {
        if (code == null) {
            return null;
        }
        for (ProductAuditStatus status : values()) {
            if (status.code == code) {
                return status;
            }
        }
        return null;
    }

    public static boolean isRejected(Integer code) {
        return code != null && code == REJECTED.code;
    }
}
