import { ResPage, Dict } from "@/api/interface/index";
import { PORT1 } from "@/api/config/servicePort";
import http from "@/api";

/**
 * @name 字典管理模块
 */
// 获取字典类型列表
export const getDictList = (params: Dict.ReqDictParams) => {
  return http.get<ResPage<Dict.ResDictList>>(PORT1 + `/system/dict/type/list`, params);
};

// 新增字典类型
export const addDict = (params: Partial<Dict.ResDictList>) => {
  return http.post(PORT1 + `/system/dict/type`, params);
};

// 编辑字典类型
export const editDict = (params: Partial<Dict.ResDictList>) => {
  return http.put(PORT1 + `/system/dict/type`, params);
};

// 删除字典类型
export const deleteDict = (ids: string[]) => {
  return http.delete(PORT1 + `/system/dict/type/${ids.join(",")}`);
};

// 刷新缓存
export const refreshDict = () => {
  return http.delete(PORT1 + `/system/dict/type/refreshCache`);
};

// 获取字典数据列表
export const getDictDataList = (params: Dict.ReqDictDataParams) => {
  return http.get<ResPage<Dict.ResDictDataList>>(PORT1 + `/system/dict/data/list`, params);
};

// 新增字典数据
export const addDictData = (params: Partial<Dict.ResDictDataList>) => {
  return http.post(PORT1 + `/system/dict/data`, params);
};

// 编辑字典数据
export const editDictData = (params: Partial<Dict.ResDictDataList>) => {
  return http.put(PORT1 + `/system/dict/data`, params);
};

// 删除字典数据
export const deleteDictData = (ids: string[]) => {
  return http.delete(PORT1 + `/system/dict/data/${ids.join(",")}`);
};
