import request from '@/utils/request';
import type { EmsActionResponse, EmsDetailResponse, EmsAlarmActionStepVO, EmsId, EmsIdParam, EmsListResponse, EmsQuery } from '../types';

// 查询报警规则具体措施步骤列表
export function listEmsAlarmActionStep(query?: EmsQuery): Promise<EmsListResponse<EmsAlarmActionStepVO>> {
  return request({
    url: '/ems/base/emsAlarmActionStep/list',
    method: 'get',
    params: query
  });
}

// 查询报警规则具体措施步骤详细
export function getEmsAlarmActionStep(objId: EmsId): Promise<EmsDetailResponse<EmsAlarmActionStepVO>> {
  return request({
    url: '/ems/base/emsAlarmActionStep/' + objId,
    method: 'get'
  });
}

// 根据报警规则ID查询措施步骤列表（包含图片）
export function getEmsAlarmActionStepsByRuleId(ruleObjId: EmsId): Promise<EmsDetailResponse<EmsAlarmActionStepVO[]>> {
  return request({
    url: '/ems/base/emsAlarmActionStep/rule/' + ruleObjId,
    method: 'get'
  });
}

// 根据报警数据信息查询措施步骤列表（包含图片）
export function getEmsAlarmActionStepsByAlarmInfo(monitorId: EmsId, cause: string): Promise<EmsDetailResponse<EmsAlarmActionStepVO[]>> {
  return request({
    url: '/ems/base/emsAlarmActionStep/getByAlarmInfo',
    method: 'post',
    data: {
      monitorId: monitorId,
      cause: cause
    }
  });
}

// 新增报警规则具体措施步骤
export function addEmsAlarmActionStep(data: EmsAlarmActionStepVO): Promise<EmsActionResponse<EmsAlarmActionStepVO>> {
  return request({
    url: '/ems/base/emsAlarmActionStep',
    method: 'post',
    data: data
  });
}

// 修改报警规则具体措施步骤
export function updateEmsAlarmActionStep(data: EmsAlarmActionStepVO): Promise<EmsActionResponse<EmsAlarmActionStepVO>> {
  return request({
    url: '/ems/base/emsAlarmActionStep',
    method: 'put',
    data: data
  });
}

// 删除报警规则具体措施步骤
export function delEmsAlarmActionStep(objId: EmsIdParam): Promise<EmsActionResponse> {
  return request({
    url: '/ems/base/emsAlarmActionStep/' + objId,
    method: 'delete'
  });
}

// 批量保存措施步骤（包含图片信息）
export function batchSaveActionSteps(ruleObjId: EmsId, stepList: EmsAlarmActionStepVO[]): Promise<EmsActionResponse> {
  return request({
    url: '/ems/base/emsAlarmActionStep/batchSave/' + ruleObjId,
    method: 'post',
    data: stepList
  });
}
