import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { SiteVO, SiteForm, SiteQuery } from '@/api/smarttrace/site/types';

/**
 * 查询站点列表
 * @param query
 * @returns {*}
 */

export const listSite = (query?: SiteQuery): AxiosPromise<SiteVO[]> => {
  return request({
    url: '/smarttrace/site/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询站点详细
 * @param id
 */
export const getSite = (id: string | number): AxiosPromise<SiteVO> => {
  return request({
    url: '/smarttrace/site/getInfo/' + id,
    method: 'get'
  });
};

/**
 * 新增站点
 * @param data
 */
export const addSite = (data: SiteForm) => {
  return request({
    url: '/smarttrace/site/add',
    method: 'post',
    data: data
  });
};

/**
 * 修改站点
 * @param data
 */
export const updateSite = (data: SiteForm) => {
  return request({
    url: '/smarttrace/site/edit',
    method: 'post',
    data: data
  });
};

/**
 * 删除站点
 * @param id
 */
export const delSite = (id: string | number | Array<string | number>) => {
  return request({
    url: '/smarttrace/site/remove/' + id,
    method: 'get'
  });
};

/**
 *
 * @returns 站点下拉
 */
export const getDeptSite = () => {
  return request({
    url: '/smarttrace/site/getDeptSite',
    method: 'get'
  });
}
