import request from '@/utils/request'

// 查询设备注册列表
export function listRegister(query) {
    return request({
        url: '/device/register/list',
        method: 'get',
        params: query
    })
}

// 查询设备注册详细
export function getRegister(id) {
    return request({
        url: '/device/register/' + id,
        method: 'get'
    })
}

// 新增设备注册
export function addRegister(data) {
    return request({
        url: '/device/register',
        method: 'post',
        data: data
    })
}

// 修改设备注册
export function updateRegister(data) {
    return request({
        url: '/device/register',
        method: 'put',
        data: data
    })
}

// 删除设备注册
export function delRegister(id) {
    return request({
        url: '/device/register/' + id,
        method: 'delete'
    })
}

// 设备示教
export function deviceTeach(id) {
    return request({
        url: '/device/profile/' + id,
        method: 'get',
    })
}

// 设备示教参数修改
export function deviceUpdateProfile(data) {
    return request({
        url: '/device/profile/updateProfile',
        method: 'put',
        data: data,
    })
}

// 新增音色
export function createTimbre(data) {
    return request({
        url: '/show/tts/create',
        method: 'post',
        headers: {
            'Content-Type': 'multipart/form-data',
            Authorization: 'eyJhbGciOiJIUzUxMiJ9.eyJsb2dpbl91c2VyX2tleSI6ImFiNmEyY2Y0LWM3MjQtNDgyMy1hM2NiLTk4N2NhZWNmMzZiNCJ9.oq-JVRbQuq_ujQ2V0h2jXC3woHPdMQKhnYJ8ixRm-C6Ez4GqJWyHYgmnkw5dbDyhWGdIUH02uv6XT8UiboHD4g',
            isToken: false
        },
        data: data,
    })
}

// 获取音色
export function getTts() {
    return request({
        url: '/show/tts/query',
        headers: {
            Authorization: 'eyJhbGciOiJIUzUxMiJ9.eyJsb2dpbl91c2VyX2tleSI6ImFiNmEyY2Y0LWM3MjQtNDgyMy1hM2NiLTk4N2NhZWNmMzZiNCJ9.oq-JVRbQuq_ujQ2V0h2jXC3woHPdMQKhnYJ8ixRm-C6Ez4GqJWyHYgmnkw5dbDyhWGdIUH02uv6XT8UiboHD4g',
            isToken: false
        },
        method: 'get',
    })
}

// 生产语料
export function createCorpus(data) {
    return request({
        url: '/show/tts/corpus',
        headers: {
            Authorization: 'eyJhbGciOiJIUzUxMiJ9.eyJsb2dpbl91c2VyX2tleSI6ImFiNmEyY2Y0LWM3MjQtNDgyMy1hM2NiLTk4N2NhZWNmMzZiNCJ9.oq-JVRbQuq_ujQ2V0h2jXC3woHPdMQKhnYJ8ixRm-C6Ez4GqJWyHYgmnkw5dbDyhWGdIUH02uv6XT8UiboHD4g',
            isToken: false
        },
        method: 'post',
        data: data
    })
}

export function getSynthesize(data, config = {}) {
    return request({
        url: '/show/tts/synthesize',
        headers: {
            Authorization: 'eyJhbGciOiJIUzUxMiJ9.eyJsb2dpbl91c2VyX2tleSI6ImFiNmEyY2Y0LWM3MjQtNDgyMy1hM2NiLTk4N2NhZWNmMzZiNCJ9.oq-JVRbQuq_ujQ2V0h2jXC3woHPdMQKhnYJ8ixRm-C6Ez4GqJWyHYgmnkw5dbDyhWGdIUH02uv6XT8UiboHD4g',
            isToken: false
        },
        responseType: 'blob',
        method: 'post',
        data: data
    }, {
        ...config
    })
}

export function createAdvancedCorpus(data) {
    return request({
        url: '/show/tts/corpus/advanced',
        headers: {
            Authorization: 'eyJhbGciOiJIUzUxMiJ9.eyJsb2dpbl91c2VyX2tleSI6ImFiNmEyY2Y0LWM3MjQtNDgyMy1hM2NiLTk4N2NhZWNmMzZiNCJ9.oq-JVRbQuq_ujQ2V0h2jXC3woHPdMQKhnYJ8ixRm-C6Ez4GqJWyHYgmnkw5dbDyhWGdIUH02uv6XT8UiboHD4g',
            isToken: false
        },
        method: 'post',
        data: data
    })
}

export function getAdvancedSynthesize(data, config = {}) {
    return request({
        url: '/show/tts/synthesize/advanced',
        headers: {
            Authorization: 'eyJhbGciOiJIUzUxMiJ9.eyJsb2dpbl91c2VyX2tleSI6ImFiNmEyY2Y0LWM3MjQtNDgyMy1hM2NiLTk4N2NhZWNmMzZiNCJ9.oq-JVRbQuq_ujQ2V0h2jXC3woHPdMQKhnYJ8ixRm-C6Ez4GqJWyHYgmnkw5dbDyhWGdIUH02uv6XT8UiboHD4g',
            isToken: false
        },
        responseType: 'blob',
        method: 'post',
        data: data
    }, {
        ...config
    })
}

export const getFlowById =  (id) => {
    return request.get(import.meta.env.VITE_NODE_RED_URL + '/flow/' + id, {})
}