import request from "@/utils/request.js";

/**
 * @description 获取系统人脸列表
 * @params pageNum, pageSize
 * @returns data
 */
export function personPhotoList(pageNum, pageSize, sendType) {
  return request({
    url: `api/personPhoto/list?pageNum=${pageNum}&pageSize=${pageSize}&sendType=${sendType}`,
    method: 'get'
  })
}

/**
 * @description 获取个人人脸列表
 * @params pageNum, pageSize
 * @returns data
 */
export function personPhotoUserListList(pageNum, pageSize, sendType) {
  return request({
    url: `api/personPhoto/userList?pageNum=${pageNum}&pageSize=${pageSize}&sendType=${sendType}`,
    method: 'get'
  })
}

/**
 * @description 保存图片
 * @params data
 * @returns data
 */
export function awsImgUpload(data) {
  return request({
    url: `/api/upload/awsImgUpload`,
    method: 'post',
    data
  })
}
/**
 * @description 上传图片
 * @params data
 * @returns data
 */
export function saveImgApi(data) {
  return request({
    url: `/api/personPhoto/save`,
    method: 'post',
    data
  })
}

/**
 * @description 删除图片
 * @params id
 * @returns data
 */
export function delImgApi(id) {
  return request({
    url: `api/personPhoto/del?id=${id}`,
    method: 'get',
  })
}

/**
 * @description 检测图片是否敏感(百度)
 * @params id
 * @returns data
 */
export function baiduPhotoApi(data) {
  const formData = new FormData();
  formData.append('file', data);
  return request({
    url: 'api/personPhoto/baiduPhoto',
    method: 'post',
    data: formData,
    headers: {
      'Content-Type': 'application/form-data'
    }
  });

}

/**
 * @description 检测人脸(邃芒)
 * @params id
 * @returns data
 */
export function checkFaceApi(data) {
  const formData = new FormData();
  formData.append('file', data);
  return request({
    url: 'api/personPhoto/checkPhoto',
    method: 'post',
    data: formData,
    headers: {
      'Content-Type': 'application/form-data'
    }
  });

}

/**
 * @description 上传音频
 * @params data
 * @returns data
 */
export function videoUpload(data) {
  return request({
    url: `api/video/upload`,
    method: 'post',
    data
  })
}

/**
 * @description 获取音频上传进度
 * @params videoId
 * @returns data
 */
export function uploadProgressApi(videoId) {
  return request({
    url: `api/video/uploadProgress?videoId=${videoId}`,
    method: 'GET',
  })
}

/**
 * @description 保存音频
 * @params videoId
 * @returns data
 */
export function saveAudioApi(data) {
  return request({
    url: `/api/voiceMaterial/save`,
    method: 'post',
    data
  })
}


/**
 * @description 获取语言
 * @params 
 * @returns data
 */
export function voiceTotalApi() {
  return request({
    url: `api/voiceMould/voiceTotal`,
    method: 'GET',
  })
}

/**
 * @description 获取声音列表
 * @params id
 * @returns data
 */
export function chooseTypeApi(id) {
  return request({
    url: `api/voiceMould/chooseType/?id=${id}`,
    method: 'GET',
  })
}

/**
 * @description 试听
 * @params id
 * @returns data
 */
// export function previewAudioApi(genTxt, voiceId, voiceStyle) {
//   return request({
//     url: `api/voiceMould/preview?genTxt=${genTxt}&voiceId=${voiceId}&voiceStyle=${voiceStyle}`,
//     method: 'GET',
//   })
// }
export function previewAudioApi(gen_txt, voice_id, voice_style) {
  return request({
    url: `api/voiceMould/preview`,
    method: 'POST',
    data: { gen_txt, voice_id, voice_style }
  })
}

/**
 * @description 保存生成视频数据
 * @params data
 * @returns data
 */
export function saveOrUpdateApi(data) {
  return request({
    url: `/api/userPhotoVideo/saveOrUpdate`,
    method: 'POST',
    data
  })
}

/**
 * @description 生成视频
 * @params data
 * @returns data
 */
export function createVideoApi(data) {
  return request({
    url: `/api/userPhotoVideo/createVideo`,
    method: 'POST',
    data
  })
}


/**
 * @description 根据作品id查询作品信息
 * @params data
 * @returns data
 */
export function findByIdApi(id) {
  return request({
    url: `/api/userPhotoVideo/findById?id=${id}`,
    method: 'get',
  })
}

/**
 * @description 获取音乐列表
 * @params pageNum,pageSize
 * @returns data
 */
export function musicListSystemApi(pageNum, pageSize) {
  return request({
    url: `api/userPhotoVideo/music?pageNum=${pageNum}&pageSize=${pageSize}&type=1`,
    method: 'get',
  })
}
/**
 * @description 获取音乐列表
 * @params pageNum,pageSize
 * @returns data
 */
export function musicListPersonApi(pageNum, pageSize) {
  return request({
    url: `api/userPhotoVideo/userMusic?pageNum=${pageNum}&pageSize=${pageSize}&type=3`,
    method: 'get',
  })
}

/**
 * @description 保存音乐
 * @params videoId
 * @returns data
 */
export function saveMusicApi(data) {
  return request({
    url: `/api/userPhotoVideo/save`,
    method: 'post',
    data
  })
}

/**
 * @description 保存音乐
 * @params videoId
 * @returns data
 */
export function delMusicApi(id) {
  return request({
    url: `api/userPhotoVideo/delete?id=${id}`,
    method: 'get',

  })
}