import request from '@/utils/request';

export function getList(data) {
  let param =
    '?page=' +
    data.page +
    '&size=' +
    data.size +
    '&projectId=' +
    data.projectId;
  if (data.deviceId != '') {
    param += '&deviceId=' + data.deviceId;
  }
  return request({
    url: '/iot/trigger/select' + param,
    method: 'get',
    data,
  });
}

export function doEdit(data) {
  return request({
    url: '/iot/trigger/update',
    method: 'post',
    data,
  });
}

export function doDelete(data) {
  return request({
    url: '/iot/trigger/remove',
    method: 'post',
    data,
  });
}

export function doAdd(data) {
  return request({
    url: '/iot/trigger/insert',
    method: 'post',
    data,
  });
}
//根据触发器id获取触发器详情
export function selectTriggerById(data) {
  return request({
    url: '/iot/trigger/selectTriggerById?triggerId=' + data.triggerId,
    method: 'get',
    data,
  });
}
//获取报警级别列表
export function selectAllAlarmLevel(data) {
  return request({
    url: '/iot/trigger/selectAllAlarmLevel',
    method: 'get',
    data,
  });
}

//获取触发条件列表
export function selectAllTriggerCondition(data) {
  return request({
    url: '/iot/trigger/selectAllTriggerCondition',
    method: 'get',
    data,
  });
}
//获取报警联系人列表
export function selectAllAlarmUser(data) {
  return request({
    url: '/iot/trigger/selectAllAlarmUser',
    method: 'get',
    data,
  });
}
//获取报警方式列表
export function selectAllAlarmType(data) {
  return request({
    url: '/iot/trigger/selectAllAlarmType',
    method: 'get',
    data,
  });
}
//获取要联控的设备列表
export function selectControlDevices(data) {
  return request({
    url: '/iot/trigger/selectDeviceByProjectId?projectId=' + data.projectId,
    method: 'get',
    data,
  });
}
//根据要联控的设备获取传感器列表
export function selectSensorByDeviceId(data) {
  return request({
    url: '/iot/trigger/selectSensorByDeviceId?deviceId=' + data.deviceId,
    method: 'get',
    data,
  });
}
//获取报警信息模板列表
export function selectAllSmsConfig(data) {
  return request({
    url: '/iot/trigger/selectAllSmsConfig',
    method: 'get',
    data,
  });
}
//根据项目id查询设备列表
export function selectDeviceByProjectId(data) {
  return request({
    url: '/iot/trigger/selectDeviceByProjectId?projectId=' + data.projectId,
    method: 'get',
    data,
  });
}
