import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { LineInfoForm, LineInfoQuery, LineInfoVO } from './types';

export const listLineInfo = (query?: LineInfoQuery): AxiosPromise<LineInfoVO[]> => {
  return request({
    url: '/lineInfo/list',
    method: 'get',
    params: query
  });
};

export const getLineInfo = (id: string | number): AxiosPromise<LineInfoVO> => {
  return request({
    url: '/lineInfo/' + id,
    method: 'get'
  });
};

export const addLineInfo = (data: LineInfoForm) => {
  return request({
    url: '/lineInfo',
    method: 'post',
    data
  });
};

export const updateLineInfo = (data: LineInfoForm) => {
  return request({
    url: '/lineInfo',
    method: 'put',
    data
  });
};

export const mountLineDevice = (data: LineInfoForm) => {
  return request({
    url: '/lineInfo/mountDevice',
    method: 'post',
    data
  });
};

export const syncLineMountedDevices = () => {
  return request({
    url: '/lineInfo/syncMountedDevices',
    method: 'post'
  });
};

export const delLineInfo = (id: string | number) => {
  return request({
    url: '/lineInfo/' + id,
    method: 'delete'
  });
};
