import http from '@/api'
import { DictDataForm, DictDataQuery, DictDataVO } from '@/api/interface/system/data'
/**
 * @name 查询字典数据列表
 * @param query 参数
 * @returns 返回列表
 */
export const listDataApi = (query: DictDataQuery) => {
  return http.get<DictDataVO[]>('/system/dict/data/list', query, { loading: true })
}

/**
 * @name 查询字典数据详细
 * @param dictCode dictCode
 * @returns returns
 */
export const getDataApi = (dictCode: string | number) => {
  return http.get<DictDataVO>(`/system/dict/data/${dictCode}`)
}

/**
 * @name 根据字典类型查询字典数据信息
 * @param dictType dictType
 * @returns returns
 */
export const getDictsApi = (dictType: string) => {
  return http.get<DictDataVO[]>(`/system/dict/data/type/${dictType}`)
}

/**
 * @name 新增字典数据
 * @param data data
 * @returns returns
 */
export const addDataApi = (data: DictDataForm) => {
  return http.post<any>('/system/dict/data', data, { loading: false })
}

/**
 * @name 修改字典数据
 * @param data data
 * @returns returns
 */
export const updateDataApi = (data: DictDataForm) => {
  return http.put<any>('/system/dict/data', data, { loading: false })
}

/**
 * @name 删除字典数据
 * @param dictCode dictCode
 * @returns returns
 */
export const delDataApi = (id: string | number | Array<string | number>) => {
  return http.delete<any>(`/system/dict/data/${id}`)
}

/**
 * @name 导出数据
 * @returns returns
 */
export const exportApi = (data: any) => {
  return http.downloadPost('/system/dict/data/export', data)
}
