package com.fs.aiSoundReplication.exception;

import lombok.Getter;

@Getter
public enum ErrorCodeEnum {
    SUCCESS(0, "成功"),
    BAD_REQUEST_ERROR(1001, "请求参数有误"),
    AUDIO_UPLOAD_ERROR(1101, "音频上传失败"),
    ASR_ERROR(1102, "ASR转写失败"),
    SID_ERROR(1103, "SID声纹检测失败"),
    SID_FAIL_ERROR(1104, "声纹检测未通过"),
    GET_AUDIO_DATA_ERROR(1105, "获取音频数据失败"),
    SPEAKER_ID_DUPLICATION_ERROR(1106, "SpeakerID重复"),
    SPEAKER_ID_NOT_FOUND_ERROR(1107, "SpeakerID未找到"),
    AUDIO_CONVERT_ERROR(1108, "音频转码失败"),
    WER_ERROR(1109, "WER检测错误"),
    AED_ERROR(1111, "AED检测错误"),
    SNR_ERROR(1112, "SNR检测错误"),
    DENOISE_ERROR(1113, "降噪处理失败"),
    AUDIO_QUALITY_ERROR(1114, "音频质量低"),
    ASR_NO_SPEAKER_ERROR(1122, "未检测到人声"),
    UPLOAD_LIMIT_ERROR(1123, "已达上传次数限制"),
    UNKNOWN_ERROR(-1, "未知错误");

    private final Integer code;
    private final String message;

    ErrorCodeEnum(Integer code, String message) {
        this.code = code;
        this.message = message;
    }

    public static ErrorCodeEnum fromCode(Integer code) {
        for (ErrorCodeEnum errorCode : values()) {
            if (errorCode.getCode().equals(code)) {
                return errorCode;
            }
        }
        return UNKNOWN_ERROR;
    }
}
