import axiosInstance from '../utils/axios';

// 分页参数类型
export interface PageParam {
  pageNo?: number;
  pageSize?: number;
  [key: string]: any;
}

// 字典类型 VO
export type DictTypeVO = {
  id: number | undefined;
  name: string;
  type: string;
  status: number;
  remark: string;
  createTime: Date;
};

// 字典类型管理 API
export const dictTypeApi = {
  // 查询字典（精简）列表
  getSimpleDictTypeList: async () => {
    return await axiosInstance.get('/system/dict-type/list-all-simple');
  },

  // 查询字典列表
  getDictTypePage: async (params?: PageParam) => {
    return await axiosInstance.get('/system/dict-type/page', { params });
  },

  // 查询字典详情
  getDictType: async (id: number) => {
    return await axiosInstance.get(`/system/dict-type/get?id=${id}`);
  },

  // 新增字典
  createDictType: async (data: DictTypeVO) => {
    return await axiosInstance.post('/system/dict-type/create', data);
  },

  // 修改字典
  updateDictType: async (data: DictTypeVO) => {
    return await axiosInstance.put('/system/dict-type/update', data);
  },

  // 删除字典
  deleteDictType: async (id: number) => {
    return await axiosInstance.delete(`/system/dict-type/delete?id=${id}`);
  },

  // 导出字典类型
  exportDictType: async (params?: PageParam) => {
    return await axiosInstance.get('/system/dict-type/export', { params, responseType: 'blob' });
  },
};

