import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { StorageLocationVO, StorageLocationForm, StorageLocationQuery } from '@/api/warehouse/storageLocation/types';

/**
 * 查询库位管理列表
 * @param query
 * @returns {*}
 */

export const listLocation = (query?: StorageLocationQuery): AxiosPromise<StorageLocationVO[]> => {
  return request({
    url: '/warehouse/storageLocation/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询库位管理详细
 * @param id
 */
export const getLocation = (id: string | number): AxiosPromise<StorageLocationVO> => {
  return request({
    url: '/warehouse/storageLocation/' + id,
    method: 'get'
  });
};

/**
 * 新增库位管理
 * @param data
 */
export const addLocation = (data: StorageLocationForm) => {
  return request({
    url: '/warehouse/storageLocation',
    method: 'post',
    data: data
  });
};

/**
 * 修改库位管理
 * @param data
 */
export const updateLocation = (data: StorageLocationForm) => {
  return request({
    url: '/warehouse/storageLocation',
    method: 'put',
    data: data
  });
};

/**
 * 删除库位管理
 * @param id
 */
export const delLocation = (id: string | number | Array<string | number>) => {
  return request({
    url: '/warehouse/storageLocation/' + id,
    method: 'delete'
  });
};
