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

export interface DictTypeVO extends PageParam {
  id: number;
  name: string;
  type: string;
  status: number;
  remark: string;
  createTime: Date;
}

export interface DictReqVO extends PageParam {
  name?: string;
  status?: number;
  type?: string;
  createTime?: Date;
}

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

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

// 查询字典列表
// export const getDictTypePage = (
//     params: DictReq
//   ): Promise<PageResult<DictType[]>> => {
//     return request.get({ url: "/system/dict-type/page", params });
//   };

export const getDictTypePage = (params: PageParam) => {
  return request("/system/dict-type/page", {
    method: "GET",
    params,
  });
};

// // 查询字典详情
// export const getDictType = (id?: number) => {
//   return request.get({ url: "/system/dict-type/get?id=" + id });
// };
export const getDictType = (id: number) => {
  return request("/system/dict-type/get", {
    method: "GET",
    params: { id },
  });
};

// 新增字典
// export const createDictType = (data: DictType) => {
//   return request.post({ url: "/system/dict-type/create", data });
// };

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

// 修改字典
// export const updateDictType = (data: DictType) => {
//   return request.put({ url: "/system/dict-type/update", data });
// };

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

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

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

// 导出字典类型
// export const exportDictType = (params: DictType) => {
//   return request.download({ url: "/system/dict-type/export", params });
// };

export const exportDictType = (params: DictTypeVO) => {
  return request("/system/dict-type/export", {
    method: "POST",
    params,
  });
};
