package cn.iocoder.yudao.module.llm.enums;

import cn.hutool.core.util.ObjUtil;
import cn.iocoder.yudao.framework.common.core.IntArrayValuable;
import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Arrays;

@Getter
@AllArgsConstructor
public enum ModelDeployConstantEnum implements IntArrayValuable {
    MODEL_DEPLOY_PENDING(1,"pending"),
    MODEL_DEPLOY_RUNNING(2,"running"),
    MODEL_DEPLOY_SUCCESS(2,"success"),
    MODEL_DEPLOY_FAILED(3,"failed");
    public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(ModelDeployConstantEnum::getStatus).toArray();

    /**
     * 状态值
     */
    private final Integer status;
    /**
     * 状态名
     */
    private final String name;

    @Override
    public int[] array() {
        return ARRAYS;
    }

    public static boolean isEnable(Integer status) {
        return ObjUtil.equal(MODEL_DEPLOY_PENDING.status, status);
    }

    public static boolean isDisable(Integer status) {
        return ObjUtil.equal(MODEL_DEPLOY_RUNNING.status, status);
    }
    public static boolean isDisable1(Integer status) {
        return ObjUtil.equal(MODEL_DEPLOY_SUCCESS.status, status);
    } public static boolean isDisable2(Integer status) {
        return ObjUtil.equal(MODEL_DEPLOY_FAILED.status, status);
    }

    /**
     * 根据 name 返回状态值
     *
     * @param name 状态名
     * @return 状态值，如果未找到则返回 null
     */
    public static Integer getStatusByName(String name) {
        for (ModelDeployConstantEnum status : values()) {
            if (ObjUtil.equal(status.getName(), name)) {
                return status.getStatus();
            }
        }
        return null; // 如果未找到对应的 name，返回 null
    }
}
