import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { LocationInfoVO, LocationInfoForm, LocationInfoId, LocationInfoIds, LocationInfoQuery } from '@/api/wcs/locationInfo/types';

/**
 * 查询库位信息列表
 * @param query
 * @returns {*}
 */

export const listLocationInfo = (query?: LocationInfoQuery): AxiosPromise<LocationInfoVO[]> => {
  return request({
    url: '/wcs/locationInfo/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询库位信息详细
 * @param objId
 */
export const getLocationInfo = (objId: LocationInfoId): AxiosPromise<LocationInfoVO> => {
  return request({
    url: '/wcs/locationInfo/' + objId,
    method: 'get'
  });
};

/**
 * 批量查询库位信息详细
 * @param ids
 */
export const getLocationInfoByIds = (ids: LocationInfoIds): AxiosPromise<LocationInfoVO[]> => {
  return request({
    url: '/wcs/locationInfo/listByIds',
    method: 'post',
    data: ids
  });
};

/**
 * 统计库位信息数量
 * @param query
 */
export const countLocationInfo = (query?: LocationInfoQuery): AxiosPromise<number> => {
  return request({
    url: '/wcs/locationInfo/count',
    method: 'get',
    params: query
  });
};

/**
 * 判断是否存在符合条件的库位信息
 * @param query
 */
export const existsLocationInfo = (query?: LocationInfoQuery): AxiosPromise<boolean> => {
  return request({
    url: '/wcs/locationInfo/exists',
    method: 'get',
    params: query
  });
};

/**
 * 新增库位信息
 * @param data
 */
export const addLocationInfo = (data: LocationInfoForm) => {
  return request({
    url: '/wcs/locationInfo',
    method: 'post',
    data: data
  });
};

/**
 * 修改库位信息
 * @param data
 */
export const updateLocationInfo = (data: LocationInfoForm) => {
  return request({
    url: '/wcs/locationInfo',
    method: 'put',
    data: data
  });
};

/**
 * 删除库位信息
 * @param objId
 */
export const delLocationInfo = (objId: LocationInfoId | LocationInfoIds) => {
  return request({
    url: '/wcs/locationInfo/' + objId,
    method: 'delete'
  });
};
