package com.ycwl.basic.enums;

/**
 * 人脸视频切片状态枚举
 */
public enum FaceCutStatus {

    /**
     * 正在切片中
     */
    CUTTING(0, "正在切片中"),

    /**
     * 切片已完成
     */
    COMPLETED(1, "切片已完成"),

    /**
     * 等待用户选择模板
     */
    WAITING_USER_SELECT(2, "等待用户选择模板");

    private final int code;
    private final String description;

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

    public int getCode() {
        return code;
    }

    public String getDescription() {
        return description;
    }

    /**
     * 根据code获取枚举
     */
    public static FaceCutStatus fromCode(int code) {
        for (FaceCutStatus status : values()) {
            if (status.code == code) {
                return status;
            }
        }
        throw new IllegalArgumentException("Unknown FaceCutStatus code: " + code);
    }

    /**
     * 根据code获取枚举，如果不存在则返回默认值
     * @param code 状态码
     * @param defaultStatus 默认状态
     * @return 枚举值
     */
    public static FaceCutStatus fromCodeOrDefault(int code, FaceCutStatus defaultStatus) {
        for (FaceCutStatus status : values()) {
            if (status.code == code) {
                return status;
            }
        }
        return defaultStatus;
    }
}
