import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { MaterialinfoVO, MaterialinfoForm, MaterialinfoId, MaterialinfoIds, MaterialinfoQuery } from '@/api/wcs/materialinfo/types';

/**
 * 查询物料信息表列表
 * @param query
 * @returns {*}
 */

export const listMaterialinfo = (query?: MaterialinfoQuery): AxiosPromise<MaterialinfoVO[]> => {
  return request({
    url: '/wcs/materialinfo/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询物料信息表详细
 * @param id
 */
export const getMaterialinfo = (id: MaterialinfoId): AxiosPromise<MaterialinfoVO> => {
  return request({
    url: '/wcs/materialinfo/' + id,
    method: 'get'
  });
};

/**
 * 批量查询物料信息表详细
 * @param ids
 */
export const getMaterialinfoByIds = (ids: MaterialinfoIds): AxiosPromise<MaterialinfoVO[]> => {
  return request({
    url: '/wcs/materialinfo/listByIds',
    method: 'post',
    data: ids
  });
};

/**
 * 统计物料信息表数量
 * @param query
 */
export const countMaterialinfo = (query?: MaterialinfoQuery): AxiosPromise<number> => {
  return request({
    url: '/wcs/materialinfo/count',
    method: 'get',
    params: query
  });
};

/**
 * 判断是否存在符合条件的物料信息表
 * @param query
 */
export const existsMaterialinfo = (query?: MaterialinfoQuery): AxiosPromise<boolean> => {
  return request({
    url: '/wcs/materialinfo/exists',
    method: 'get',
    params: query
  });
};

/**
 * 新增物料信息表
 * @param data
 */
export const addMaterialinfo = (data: MaterialinfoForm) => {
  return request({
    url: '/wcs/materialinfo',
    method: 'post',
    data: data
  });
};

/**
 * 修改物料信息表
 * @param data
 */
export const updateMaterialinfo = (data: MaterialinfoForm) => {
  return request({
    url: '/wcs/materialinfo',
    method: 'put',
    data: data
  });
};

/**
 * 删除物料信息表
 * @param id
 */
export const delMaterialinfo = (id: MaterialinfoId | MaterialinfoIds) => {
  return request({
    url: '/wcs/materialinfo/' + id,
    method: 'delete'
  });
};
