import { request } from "@umijs/max";

export type DictDataVO = {
  id: number;
  sort: number | undefined;
  label: string;
  value: string;
  dictType: string;
  status: number;
  colorType: string;
  cssClass: string;
  remark: string;
  createTime: Date;
};

export interface DictDataReqVO extends PageParam {
  dictType?: string;
  createTime?: Date;
}

// 查询字典数据（精简)列表
// export const getSimpleDictDataList = () => {
//     return request.get({ url: "/system/dict-data/simple-list" });
//   };

export const getSimpleDictDataList = () => {
  return request("/system/dict-data/simple-list", {
    method: "GET",
  });
};

// 查询字典数据列表
// export const getDictDataPage = (params: PageParam) => {
//     return request.get({ url: "/system/dict-data/page", params });
//   };

export const getDictDataPage = (params: DictDataReqVO) => {
  return request("/system/dict-data/page", {
    method: "GET",
    params,
  });
};

// 查询字典数据详情
// export const getDictData = (id: number) => {
//     return request.get({ url: "/system/dict-data/get?id=" + id });
//   };

export const getDictData = (id: number) => {
  return request("/system/dict-data/get", {
    method: "GET",
    params: { id },
  });
};

// 新增字典数据
// export const createDictData = (data: DictData) => {
//   return request.post({ url: "/system/dict-data/create", data });
// };

export const createDictData = (data: DictDataVO) => {
  return request("/system/dict-data/create", {
    method: "POST",
    data,
  });
};

// 修改字典数据
// export const updateDictData = (data: DictData) => {
//   return request.put({ url: "/system/dict-data/update", data });
// };

export const updateDictData = (data: DictDataVO) => {
  return request("/system/dict-data/update", {
    method: "PUT",
    data,
  });
};

// 删除字典数据
// export const deleteDictData = (id: number) => {
//   return request.delete({ url: "/system/dict-data/delete?id=" + id });
// };

export const deleteDictData = (id: number) => {
  return request("/system/dict-data/delete", {
    method: "DELETE",
    params: { id },
  });
};

// 导出字典类型数据
// export const exportDictData = (params: DictData) => {
//   return request.download({ url: "/system/dict-data/export", params });
// };
export const exportDictData = (params: DictDataVO) => {
  return request("/system/dict-data/export", {
    method: "GET",
    params,
  });
};
