import { get, post } from '../../http'

/**
 * @description: 获取系统字典类型树
 * @return {*}
 */
const getDictTypeTree = async () => {
  return await get<any>('/sysDictType/tree')
}

/**
 * @description: 获取系统字典类型分页表
 * @param {*} params
 * @return {*}
 */
const getDictTypePage = async (params: Record<string, any>) => {
  return await get<any>('/sysDictType/page', params)
}

/**
 * @description: 修改字典类型状态
 * @param {*} data
 * @return {*}
 */
const changeDictTypeStatus = async (data: Record<string, any>) => {
  return await post<any>('/sysDictType/changeStatus', data)
}

/**
 * @description: 修改字典值状态
 * @param {*} data
 * @return {*}
 */
const changeDictDataStatus = async (data: Record<string, any>) => {
  return await post<any>('/sysDictData/changeStatus', data)
}

/**
 * @description: 删除字典类型
 * @param {*} data
 * @return {*}
 */
const delDictType = async (data: Record<string, any>) => {
  return await post<any>('/sysDictType/delete', data)
}

/**
 * @description: 删除字典值
 * @param {*} data
 * @return {*}
 */
const delDictData = async (data: Record<string, any>) => {
  return await post<any>('/sysDictData/delete', data)
}

/**
 * @description: 增加字典类型
 * @param {*} data
 * @return {*}
 */
const addDictType = async (data: Record<string, any>) => {
  return await post<any>('/sysDictType/add', data)
}

/**
 * @description: 增加字典值
 * @param {*} data
 * @return {*}
 */
const addDictData = async (data: Record<string, any>) => {
  return await post<any>('/sysDictData/add', data)
}

/**
 * @description: 编辑字典类型
 * @param {*} data
 * @return {*}
 */
const editDictType = async (data: Record<string, any>) => {
  return await post<any>('/sysDictType/edit', data)
}

/**
 * @description: 编辑字典值
 * @param {*} data
 * @return {*}
 */
const editDictData = async (data: Record<string, any>) => {
  return await post<any>('/sysDictData/edit', data)
}

/**
 * @description: 根据code查询字典集合
 * @param {*} data
 * @return {*}
 */
const getListSysDictData = async (code: string) => {
  return await get<any>(`/sysDictType/listSysDictData/${code}`)
}

/**
 * @description: 查询字典集合
 * @param {*} params
 * @return {*}
 */
const getSysDictDataList = async (params: Record<string, any>) => {
  return await get<any>('/sysDictData/list', params)
}

/**
 * @description: 查询字典类型详情
 * @param {*} data
 * @return {*}
 */
const getDictTypeDetail = async (params: Record<string, any>) => {
  return await get<any>('/sysDictType/detail', params)
}

/**
 * @description: 查询字典值详情
 * @param {*} data
 * @return {*}
 */
const getDictDataDetail = async (params: Record<string, any>) => {
  return await get<any>('/sysDictData/detail', params)
}

/**
 * @description: 批量修改字典值集合
 * @param {*} data
 * @return {*}
 */
const putDictDataSaveList = async (data: Record<string, any>) => {
  return await post<any>('/sysDictData/saveList', data)
}

const dictManagementApi = {
  getDictTypeTree,
  getDictTypePage,
  changeDictTypeStatus,
  changeDictDataStatus,
  delDictType,
  delDictData,
  addDictType,
  addDictData,
  editDictType,
  editDictData,
  getListSysDictData,
  getSysDictDataList,
  getDictTypeDetail,
  getDictDataDetail,
  putDictDataSaveList,
}

export default dictManagementApi
