import request from '@/axios'
import type { fileList } from './types'
import { REQUEST_BASE } from '@/constants'

export const getFileList = (params: fileList): Promise<IResponse> => {
  return request.get({ url: `${REQUEST_BASE}/file`, params })
}
export const getFileType = (params: fileList = {}): Promise<IResponse> => {
  return request.get({ url: `${REQUEST_BASE}/file/category`, params })
}
export const setFileType = (data: {
  pid?: string | number
  name: string
  file_type: number
}): Promise<IResponse> => {
  return request.post({ url: `${REQUEST_BASE}/file/category`, data })
}
export const delFileType = (id: string | number): Promise<IResponse> => {
  return request.delete({ url: `${REQUEST_BASE}/file/category/${id}` })
}
export const upOnlineFile = (data: { pid: number; images: string }): Promise<IResponse> => {
  return request.post({ url: `${REQUEST_BASE}/file/online/upload`, data })
}
export const delFile = (data: { ids: string }): Promise<IResponse> => {
  return request.post({ url: `${REQUEST_BASE}/file/delete`, data })
}
export const updateFile = (data: { id: number; real_name: string }): Promise<IResponse> => {
  return request.put({ url: `${REQUEST_BASE}/update/${data.id}`, data })
}
