import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { FlowDetailVO, FlowDetailForm, FlowDetailQuery } from '@/api/sense/flowDetail/types';

/**
 * 查询流量明细列表
 * @param query
 * @returns {*}
 */

export const listFlowDetail = (query?: FlowDetailQuery): AxiosPromise<FlowDetailVO[]> => {
  return request({
    url: '/sense/flowDetail/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询流量明细详细
 * @param id
 */
export const getFlowDetail = (id: string | number): AxiosPromise<FlowDetailVO> => {
  return request({
    url: '/sense/flowDetail/' + id,
    method: 'get'
  });
};

/**
 * 新增流量明细
 * @param data
 */
export const addFlowDetail = (data: FlowDetailForm) => {
  return request({
    url: '/sense/flowDetail',
    method: 'post',
    data: data
  });
};

/**
 * 修改流量明细
 * @param data
 */
export const updateFlowDetail = (data: FlowDetailForm) => {
  return request({
    url: '/sense/flowDetail',
    method: 'put',
    data: data
  });
};

/**
 * 删除流量明细
 * @param id
 */
export const delFlowDetail = (id: string | number | Array<string | number>) => {
  return request({
    url: '/sense/flowDetail/' + id,
    method: 'delete'
  });
};
// 获取流量前3的路段流量折线图数据
export const lineCharts = () => {
  return request({
    url: '/sense/flowDetail/lineCharts',
    method: 'get',
  });
};
