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

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

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

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

/**
 * 查询油品损溢设置列表
 * @param params 查询参数
 * @returns 分页结果
 */
export function gainSettingList(params: any) {
  return requestClient.get<BaseResult<GainSettingModel[]>>(Api.list, {
    params,
  });
}

/**
 * 获取油品损溢设置详细信息
 * @param id 油品损溢设置ID
 * @returns 油品损溢设置详情
 */
export function getGainSettingDetail(id: number) {
  return requestClient.get<GainSettingModel>(`${Api.root}/${id}`);
}

/**
 * 新增油品损溢设置
 * @param data 油品损溢设置数据
 * @returns 操作结果
 */
export function addGainSetting(data: GainSettingModel) {
  return requestClient.post(Api.root, data, {
    successMessageMode: 'message',
  });
}

/**
 * 修改油品损溢设置
 * @param data 油品损溢设置数据
 * @returns 操作结果
 */
export function updateGainSetting(data: GainSettingModel) {
  return requestClient.put(Api.root, data, {
    successMessageMode: 'message',
  });
}

/**
 * 删除油品损溢设置
 * @param ids 油品损溢设置ID数组
 * @returns 操作结果
 */
export function deleteGainSetting(ids: number[]) {
  return requestClient.delete(`${Api.root}/${ids.join(',')}`, {
    successMessageMode: 'message',
  });
}

/**
 * 导出油品损溢设置列表
 * @param data 导出参数
 * @returns 导出结果
 */
export function exportGainSetting(data: Partial<GainSettingModel>) {
  return commonExport(Api.export, data);
}
