import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { LocationForm, LocationId, LocationIds, LocationQuery, LocationVO } from './types';

export const listLocation = (query?: LocationQuery): AxiosPromise<LocationVO[]> => {
  return request({ url: '/wcs/location/list', method: 'get', params: query });
};

export const getLocation = (locationId: LocationId): AxiosPromise<LocationVO> => {
  return request({ url: '/wcs/location/' + locationId, method: 'get' });
};

export const addLocation = (data: LocationForm) => {
  return request({ url: '/wcs/location', method: 'post', data });
};

export const updateLocation = (data: LocationForm) => {
  return request({ url: '/wcs/location', method: 'put', data });
};

export const delLocation = (locationId: LocationId | LocationIds) => {
  return request({ url: '/wcs/location/' + locationId, method: 'delete' });
};
