import http from '@/api'
import { OssConfigForm, OssConfigQuery, OssConfigVO } from '@/api/interface/system/ossConfig'
/**
 * @name 查询对象存储配置列表
 * @param query 参数
 * @returns 返回列表
 */
export const listOssConfigApi = (query: OssConfigQuery) => {
  return http.get<OssConfigVO[]>('/resource/oss/config/list', query, { loading: true })
}

/**
 * @name 查询对象存储配置详细
 * @param ossConfigId ossConfigId
 * @returns returns
 */
export const getOssConfigApi = (ossConfigId: string | number) => {
  return http.get<OssConfigVO>(`/resource/oss/config/${ossConfigId}`)
}

/**
 * @name 新增对象存储配置
 * @param data data
 * @returns returns
 */
export const addOssConfigApi = (data: OssConfigForm) => {
  return http.post<any>('/resource/oss/config', data, { loading: false })
}

/**
 * @name 修改对象存储配置
 * @param data data
 * @returns returns
 */
export const updateOssConfigApi = (data: OssConfigForm) => {
  return http.put<any>('/resource/oss/config', data, { loading: false })
}
/**
 * @name 对象存储状态修改
 * @param data data
 * @returns returns
 */
export const changeOssConfigStatusApi = (data: { ossConfigId: string | number; version: number; status: string; configKey: string }) => {
  return http.put<any>('/resource/oss/config/changeStatus', data, { loading: false })
}

/**
 * @name 删除对象存储配置
 * @param ossConfigId ossConfigId
 * @returns returns
 */
export const delOssConfigApi = (ossConfigId: string | number | Array<string | number>) => {
  return http.delete<any>(`/resource/oss/config/${ossConfigId}`)
}

/**
 * @name 下载模板
 * @returns returns
 */
export const importTemplateApi = () => {
  return http.downloadPost('/resource/oss/config/importTemplate', {})
}
