import { http } from '@/utils/http'
import type { AttachmentEntity } from '@/types/file'
import type { ListType, ListResponseType } from '@/types/list'
import { parseQueryValues } from '@/utils'

/** 附件信息_列表 */
export const getAttachmentListApi = (
  params: Partial<AttachmentEntity>,
  page: Partial<ListType>,
) => {
  return http.get<ListResponseType<AttachmentEntity>>('/api/query/list?pagevalue=97', {
    ...page,
    ...parseQueryValues(params),
  })
}

/**
 * 新增图片并返回id
 */
export const addImageApi = (data: { file: File }) => {
  return http.post<any>('/api/attachment/addimg?pagevalue=93', {
    ...data,
  })
}

/**
 * 添加附件记录并返回路径
 */
export const addAttachmentApi = (data: { id: number }) => {
  return http.post<any>('/api/attachment/addtopath?pagevalue=94', {
    ...data,
  })
}

/**
 * 删除附件记录
 */
export const deleteAttachmentApi = (data: { id: number }) => {
  return http.post<any>('/api/attachment/del?pagevalue=95', {
    ...data,
  })
}

/**
 * 更新附件记录
 */
export const updateAttachmentApi = (data: { id: number }) => {
  return http.post<any>('/api/attachment/up?pagevalue=96', {
    ...data,
  })
}
