import { defHttp } from '/@/utils/http/axios';

import { ErrorMessageMode } from '/#/axios';

/**
 * @description:设备列表
 */
export function getDevices(params, mode: ErrorMessageMode = 'modal') {
  return defHttp.get(
    {
      url: '/api/devices',
      params,
    },
    {
      errorMessageMode: mode,
    },
  );
}
/**
 * @description:设备类型
 */
export function getDeviceTypes(mode: ErrorMessageMode = 'modal') {
  return defHttp.get(
    {
      url: '/api/device-types',
    },
    {
      errorMessageMode: mode,
    },
  );
}
/**
 * @description:添加设备
 */
export function createDevice(data, mode: ErrorMessageMode = 'modal') {
  return defHttp.post(
    {
      url: '/api/devices',
      data,
    },
    {
      errorMessageMode: mode,
    },
  );
}
/**
 * @description:更新设备
 */
export function updateDevice(device, data, mode: ErrorMessageMode = 'modal') {
  return defHttp.put(
    {
      url: `/api/devices/${device}`,
      data,
    },
    {
      errorMessageMode: mode,
    },
  );
}
/**
 * @description:删除设备
 */
export function deleteDevice(device, mode: ErrorMessageMode = 'modal') {
  return defHttp.delete(
    {
      url: `/api/devices/${device}`,
    },
    {
      errorMessageMode: mode,
    },
  );
}
/**
 * @description:基地数据列表
 */
export function getAgriculturalBasic(
  params = { per_page: 999999, page: 1 },
  mode: ErrorMessageMode = 'modal',
) {
  return defHttp.get(
    {
      url: '/api/agricultural-basic',
      params,
    },
    {
      errorMessageMode: mode,
    },
  );
}
