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

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

// 字典数据 VO
export type DictDataVO = {
  id: number | undefined;
  sort: number | undefined;
  label: string;
  value: string;
  dictType: string; 
  colorType: string;
  cssClass: string;
  remark: string;
  status?: number; // 字典管理状态：0=开启，1=关闭
  createTime: Date;
};

// 字典数据管理 API
export const dictDataApi = {
  // 查询字典数据（精简）列表
  getSimpleDictDataList: async () => {
    return await axiosInstance.get('/system/dict-data/simple-list');
  },

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

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

  // 新增字典数据
  createDictData: async (data: DictDataVO) => {
    return await axiosInstance.post('/system/dict-data/create', data);
  },

  // 修改字典数据
  updateDictData: async (data: DictDataVO) => {
    return await axiosInstance.put('/system/dict-data/update', data);
  },

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

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

