import httpClient from '@/utils/http';

import {
  ControllerCreateDictionaryTypeRequest,
  ControllerResponse,
  ControllerUpdateDictionaryTypeRequest,
  ModelDictionaryType
} from './data-contracts';
export default {
  /**
   * @description 创建新的数据字典类型
   */
  typesCreate: (type: ControllerCreateDictionaryTypeRequest) => {
    return httpClient.post<
      ControllerResponse & {
        data?: ModelDictionaryType;
      }
    >(`/dictionary/types`, { params: type });
  },
  /**
   * @description 获取所有数据字典类型
   */
  typesList: () => {
    return httpClient.get<
      ControllerResponse & {
        data?: ModelDictionaryType[];
      }
    >(`/dictionary/types`);
  },
  /**
   * @description 根据ID获取数据字典类型详情
   */
  typesDetail: (id: number) => {
    return httpClient.get<
      ControllerResponse & {
        data?: ModelDictionaryType;
      }
    >(`/dictionary/types/${id}`);
  },
  /**
   * @description 根据ID更新数据字典类型
   */
  typesUpdate: (id: number, type: ControllerUpdateDictionaryTypeRequest) => {
    return httpClient.put<
      ControllerResponse & {
        data?: ModelDictionaryType;
      }
    >(`/dictionary/types/${id}`, { params: type });
  },
  /**
   * @description 根据ID删除数据字典类型
   */
  typesDelete: (id: number) => {
    return httpClient.delete<
      ControllerResponse & {
        data?: string;
      }
    >(`/dictionary/types/${id}`);
  }
};
