import request from '@/utils/request';

export function getList(data) {
  return request({
    url: '/ys/author/select?page=' + data.page + '&size=' + data.size,
    method: 'get',
    data,
  });
}

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

export function doDelete(data) {
  return request({
    url: '/ys/author/delete?id=' + data.id,
    method: 'post',
    data,
  });
}

export function doAdd(data) {
  return request({
    url: '/ys/author/insert',
    method: 'post',
    data,
  });
}

//获取设备列表
export function getDevices(data) {
  let param = '?page=' + data.page + '&size=' + data.size;
  if (data.account != '' && data.account != undefined) {
    param += '&account=' + data.account;
  }
  if (data.sonserName != '' && data.sonserName != undefined) {
    param += '&sonserName=' + data.sonserName;
  }
  if (data.deviceSerial != '' && data.deviceSerial != undefined) {
    param += '&deviceSerial=' + data.deviceSerial;
  }
  if (data.status != 3 && data.status != undefined) {
    param += '&status=' + data.status;
  }
  return request({
    url: '/ys/api/getDevices' + param,
    method: 'get',
    data,
  });
}

//获取播放地址
export function getLiveAddr(data) {
  return request({
    url:
      '/ys/api/getLiveAddr?account=' +
      data.account +
      '&deviceSerial=' +
      data.deviceSerial,
    method: 'get',
    data,
  });
}
//获取播放地址
export function ldDeviceByProjectId(data) {
  return request({
    url: '/ys/api/ldDeviceByProjectId?projectId=' + data.projectId,
    method: 'get',
    data,
  });
}
//萤石设备绑定力鼎站点
export function ysBindDevice(data) {
  return request({
    url:
      '/ys/api/ysBindDevice?ysSerial=' +
      data.ysSerial +
      '&code=' +
      data.code +
      '&account=' +
      data.account,
    method: 'post',
    data,
  });
}
export function capture(data) {
  return request({
    url:
      '/ys/author/capture?account=' +
      data.account +
      '&captureFlag=' +
      data.captureFlag,
    method: 'post',
    data,
  });
}
