import http from '@/utils/http'
import { AppDispatch } from '@/store'

/**
 * 藏品附件 -根据附件id拿列表
 */
export const API_getFileListByIds = (ids: string[]) => {
  return http.post('cms/file/getList', ids)
}

/**
 * 藏品附件 -获取藏品附件列表
 */
export const API_getFileList = (data: any): any => {
  return async (dispatch: AppDispatch) => {
    const res = await http.post(`cms/good/file/page`, data)
    if (res.code === 0) {
      const obj = {
        list: res.data.records,
        total: res.data.total
      }

      dispatch({ type: 'C4/getList', payload: obj })
    }
  }
}

/**
 * 藏品附件 -下载记录
 */
export const API_getFileLog = (fileId: number) => {
  return http.get(`cms/good/file/log/${fileId}`)
}

/**
 * 藏品附件 -根据附件id批量下载附件
 */
export const API_downloadFiles = (ids: number[]) => {
  return http.post('cms/good/file/downloadBatchZip', ids)
}

/**
 * 藏品附件 -真删除附件
 */
export const API_delFiles = (ids: number[]) => {
  return http.post('cms/file/removes', ids)
}
