import { defHttp } from '@jdlinker/func';

export const queryCollector = (data: any) =>
  defHttp.post({
    url: `/data-collect/collector/_query/no-paging?paging=false`,
    data
  });

export const queryCollectorTree = (data: any) =>
  defHttp.post({
    url: `/data-collect/collector/_detail/no-paging?paging=false`,
    data
  });

export const queryChannelNoPaging = () => defHttp.post({ url: `/data-collect/channel/_query/no-paging` });

export const save = (data: any) => defHttp.post({ url: `/data-collect/collector`, data });

export const update = (id: string, data: any) => defHttp.put({ url: `/data-collect/collector/${id}`, data });

export const remove = (id: string) => defHttp.delete({ url: `/data-collect/collector/${id}` });

export const queryPoint = (data: any) => defHttp.post({ url: `/data-collect/point/_query`, data });

export const _validateField = (id: string, data?: any) => defHttp.get({ url: `/data-collect/point/${id}/_validate`, data });

export const queryCodecProvider = () => defHttp.get({ url: `/things/collector/codecs` });

export const updatePoint = (id: string, data: any) => defHttp.put({ url: `/data-collect/point/${id}`, data });

export const savePointBatch = (data: any) => defHttp.patch({ url: `/data-collect/point`, data });

export const savePoint = (data: any) => defHttp.post({ url: `/data-collect/point`, data });

export const batchDeletePoint = (data: any) => defHttp.post({ url: `/data-collect/point/batch/_delete`, data });

export const removePoint = (id: string) => defHttp.delete({ url: `/data-collect/point/${id}` });

export const readPoint = (collectorId: string, data: string[]) =>
  defHttp.post({
    url: `/data-collect/collector/${collectorId}/points/_read`,
    data
  });

export const writePoint = (collectorId: string, data: string[]) =>
  defHttp.post({
    url: `/data-collect/collector/${collectorId}/points/_write`,
    data
  });

export const queryPointNoPaging = (data: any) => defHttp.post({ url: `/data-collect/point/_query/no-paging`, data });

export const scanOpcUAList = (data: any) =>
  defHttp.get({
    url: `/data-collect/opc/channel/${data.id}/nodes?nodeId=${data?.nodeId || ''}`
  });

export const queryTypeList = () => defHttp.get({ url: `/data-collect/opc/data-types` });

export const getProviders = () => defHttp.get({ url: '/data-collect/channel/gateway/codec/providers' });

export const getStates = () => defHttp.get({ url: '/dictionary/running-state/items' });
