import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { StoreInfoVO, StoreInfoForm, StoreInfoId, StoreInfoIds, StoreInfoQuery } from '@/api/wcs/storeInfo/types';
import type { WcsDropdownQuery } from '@/api/wcs/types';

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

export const listStoreInfo = (query?: StoreInfoQuery): AxiosPromise<StoreInfoVO[]> => {
  return request({
    url: '/wcs/storeInfo/list',
    method: 'get',
    params: query
  });
};

/**
 * 获取仓库信息下拉列表
 * @param query
 */
export const getStoreInfoList = (query?: WcsDropdownQuery<StoreInfoQuery>): AxiosPromise<StoreInfoVO[]> => {
  return request({
    url: '/wcs/storeInfo/getStoreInfoList',
    method: 'get',
    params: query
  });
};

/**
 * 查询仓库信息详细
 * @param objId
 */
export const getStoreInfo = (objId: StoreInfoId): AxiosPromise<StoreInfoVO> => {
  return request({
    url: '/wcs/storeInfo/' + objId,
    method: 'get'
  });
};

/**
 * 批量查询仓库信息详细
 * @param ids
 */
export const getStoreInfoByIds = (ids: StoreInfoIds): AxiosPromise<StoreInfoVO[]> => {
  return request({
    url: '/wcs/storeInfo/listByIds',
    method: 'post',
    data: ids
  });
};

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

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

/**
 * 新增仓库信息
 * @param data
 */
export const addStoreInfo = (data: StoreInfoForm) => {
  return request({
    url: '/wcs/storeInfo',
    method: 'post',
    data: data
  });
};

/**
 * 修改仓库信息
 * @param data
 */
export const updateStoreInfo = (data: StoreInfoForm) => {
  return request({
    url: '/wcs/storeInfo',
    method: 'put',
    data: data
  });
};

/**
 * 删除仓库信息
 * @param objId
 */
export const delStoreInfo = (objId: StoreInfoId | StoreInfoIds) => {
  return request({
    url: '/wcs/storeInfo/' + objId,
    method: 'delete'
  });
};
