import http from '@/api'
import { DictTypeForm, DictTypeVO, DictTypeQuery } from '@/api/interface/system/type'
/**
 * @name 查询字典类型列表
 * @param query 参数
 * @returns 返回列表
 */
export const listDictApi = (query: DictTypeQuery) => {
  return http.get<DictTypeVO[]>('/system/dict/type/list', query, { loading: false })
}

/**
 * @name 查询字典类型详细
 * @param dictId dictId
 * @returns returns
 */
export const getDictApi = (dictId: string | number) => {
  return http.get<any>(`/system/dict/type/${dictId}`)
}

/**
 * @name 新增字典类型
 * @param data data
 * @returns returns
 */
export const addDictApi = (data: DictTypeForm) => {
  return http.post<any>('/system/dict/type', data, { loading: false })
}

/**
 * @name 修改字典类型
 * @param data data
 * @returns returns
 */
export const updateDictApi = (data: DictTypeForm) => {
  return http.put<any>('/system/dict/type', data, { loading: false })
}

/**
 * @name 删除字典类型
 * @param dictId dictId
 * @returns returns
 */
export const delDictApi = (id: string | number | Array<string | number>) => {
  return http.delete<any>(`/system/dict/type/${id}`)
}

/**
 * @name 导出数据
 * @returns returns
 */
export const exportApi = (data: any) => {
  return http.downloadPost('/system/dict/type/export', data)
}
/**
 * @name 刷新字典缓存
 * @returns returns
 */
export const refreshCacheApi = () => {
  return http.delete<any>(`system/dict/type/refreshCache`)
}

/**
 * @name 获取字典选择框列表
 * @returns returns
 */
export const optionSelectApi = () => {
  return http.get<any>(`/system/dict/type/option/select`)
}
