import type { EmergencyMaterialModel, EmergencyMaterialListModel } from './model';

import type { BaseResult } from '#/api/base-result';

import { commonExport } from '#/api/helper';
import { requestClient } from '#/api/request';

// API路径常量枚举
enum Api {
  // 导出
  export = '/gasEmergencyMaterial/material/export',
  // 列表查询
  list = '/gasEmergencyMaterial/material/list',
  // 基础路径
  root = '/gasEmergencyMaterial/material',
}

/**
 * 查询场站应急防护列表
 * @param params 查询参数
 * @returns 分页结果
 */
export function emergencyMaterialList(params: any) {
  return requestClient.get<BaseResult<EmergencyMaterialModel[]>>(Api.list, {
    params,
  });
}

/**
 * 获取场站应急防护详细信息
 * @param id 应急防护ID
 * @returns 应急防护详情
 */
export function getEmergencyMaterialDetail(id: string) {
  return requestClient.get<EmergencyMaterialModel>(`${Api.root}/${id}`);
}

/**
 * 新增场站应急防护
 * @param data 应急防护数据
 * @returns 操作结果
 */
export function addEmergencyMaterial(data: EmergencyMaterialModel) {
  return requestClient.post(Api.root, data, {
    successMessageMode: 'message',
  });
}

/**
 * 修改场站应急防护
 * @param data 应急防护数据
 * @returns 操作结果
 */
export function updateEmergencyMaterial(data: EmergencyMaterialModel) {
  return requestClient.put(Api.root, data, {
    successMessageMode: 'message',
  });
}

/**
 * 删除场站应急防护
 * @param ids 应急防护ID数组
 * @returns 操作结果
 */
export function deleteEmergencyMaterial(ids: string[]) {
  return requestClient.delete(`${Api.root}/${ids.join(',')}`, {
    successMessageMode: 'message',
  });
}

/**
 * 导出场站应急防护列表
 * @param data 导出参数
 * @returns 导出结果
 */
export function exportEmergencyMaterial(data: Partial<EmergencyMaterialModel>) {
  return commonExport(Api.export, data);
}
