import request from '@/request'
import type * as TYPE from './types'

/**
 * 获取设备列表
  @param pageNo 当前页码
  @param pageSize 页面大小
  @param clientId 设备ID
  @param devName 设备名称
  @param online 设备状态：0-离线，1-在线
  @param createTimeStart 起始时间 格式yyyy-MM-dd
  @param createTimeEnd 结束时间 格式yyyy-MM-dd
 */
export const getDeviceList = (
  params: TYPE.DeviceListParams
): Promise<ResponseData<TYPE.DeviceListData>> => {
  return request.post('/device/queryDevList', params)
}

/**
 * 获取设备详情
 */
export const getDeviceDetail = (
  params: TYPE.DeviceDetailParams
): Promise<ResponseData<TYPE.Device[]>> => {
  return request.post('/s/wxxcx/index/queryList', params)
}

/**
 * 添加设备
 */
export const addDevice = (params: TYPE.AddDeviceParams): Promise<ResponseData<TYPE.Device[]>> => {
  return request.post(`/device/addOneDevice`, params)
}

/**
 * 删除设备
 */
export const deleteDevice = (
  params: TYPE.DeleteDeviceParams
): Promise<ResponseData<TYPE.Device[]>> => {
  return request.post('/s/wxxcx/index/deleteDevice', params)
}

/**
 * 批量导入设备
 */
export const uploadDevInfo = (
  params: TYPE.UploadDevInfoParams
): Promise<ResponseData<TYPE.Device[]>> => {
  return request.post('/s/wxxcx/index/uploadDevInfo', params)
}

/**
 * 获取设备详情
 * @param devId 设备ID
 */
export const getDeviceDetailByDevId = (params: {
  devId: string
}): Promise<ResponseData<TYPE.DeviceDetailData>> => {
  return request.get('/device/query', { params })
}

/**
 * 更新设备信息
 */
export const updateDevice = (
  params: TYPE.UpdateDeviceParams
): Promise<ResponseData<TYPE.Device[]>> => {
  return request.post('device/updateDevice', params)
}
