import type { ExtinguisherModel } from './model';

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

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

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

/**
 * 查询灭火器信息列表
 * @param params 查询参数
 * @returns 分页结果
 */
export function extinguisherList(params: any) {
  return requestClient.get<BaseResult<ExtinguisherModel[]>>(Api.list, {
    params,
  });
}

/**
 * 获取灭火器信息详细信息
 * @param id 灭火器信息ID
 * @returns 灭火器信息详情
 */
export function getExtinguisherDetail(id: number) {
  return requestClient.get<ExtinguisherModel>(`${Api.root}/${id}`);
}

/**
 * 新增灭火器信息
 * @param data 灭火器信息数据
 * @returns 操作结果
 */
export function addExtinguisher(data: ExtinguisherModel) {
  return requestClient.post(Api.root, data, {
    successMessageMode: 'message',
  });
}

/**
 * 修改灭火器信息
 * @param data 灭火器信息数据
 * @returns 操作结果
 */
export function updateExtinguisher(data: ExtinguisherModel) {
  return requestClient.put(Api.root, data, {
    successMessageMode: 'message',
  });
}

/**
 * 删除灭火器信息
 * @param ids 灭火器信息ID数组
 * @returns 操作结果
 */
export function deleteExtinguisher(ids: number[]) {
  return requestClient.delete(`${Api.root}/${ids.join(',')}`, {
    successMessageMode: 'message',
  });
}

/**
 * 导出灭火器信息列表
 * @param data 导出参数
 * @returns 导出结果
 */
export function exportExtinguisher(data: Partial<ExtinguisherModel>) {
  return commonExport(Api.export, data);
}
