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

enum Api {
  getGoafData = '/province/device/getGoafData',
  getGoafHistory = '/province/device/getGoafHistory',
  getGoafList = '/province/device/getGoafList',
}

export function getGoafData(params: any) {
  return defHttp.post({ url: Api.getGoafData, params }, { joinParamsToUrl: true });
}
export function getGoafHistory(params: any) {
  return defHttp.get({ url: Api.getGoafHistory, params }, { joinParamsToUrl: true });
}

export function getGoafSelectOption(params: any) {
  return defHttp.post({ url: Api.getGoafList, params }, { joinParamsToUrl: true }).then((res) => {
    const options = res.map((e) => ({ value: e.id, label: e.devicePos }));
    return {
      options,
      defaultValue: options[0]?.value,
    };
  });
}
