package com.haha.common.enums;

import lombok.Getter;

/**
 * 新品申请状态枚举
 */
@Getter
public enum ApplyStatus {

    DRAFT(0, "待提交"),
    PENDING(1, "审核中"),
    APPROVED(2, "已通过"),
    REJECTED(3, "已拒绝");

    private final int code;
    private final String description;

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

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

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

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

    public static String getDescription(Integer code) {
        ApplyStatus status = fromCode(code);
        return status != null ? status.description : "未知";
    }
}
