import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { FoodIngredientVO, FoodIngredientForm, FoodIngredientQuery } from '@/api/system/foodIngredient/types';

/**
 * 查询食材管理列表
 * @param query
 * @returns {*}
 */

export const listFoodIngredient = (query?: FoodIngredientQuery): AxiosPromise<FoodIngredientVO[]> => {
  return request({
    url: '/system/foodIngredient/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询食材管理详细
 * @param foodIngredientId
 */
export const getFoodIngredient = (foodIngredientId: string | number): AxiosPromise<FoodIngredientVO> => {
  return request({
    url: '/system/foodIngredient/' + foodIngredientId,
    method: 'get'
  });
};

/**
 * 新增食材管理
 * @param data
 */
export const addFoodIngredient = (data: FoodIngredientForm) => {
  return request({
    url: '/system/foodIngredient',
    method: 'post',
    data: data
  });
};

/**
 * 修改食材管理
 * @param data
 */
export const updateFoodIngredient = (data: FoodIngredientForm) => {
  return request({
    url: '/system/foodIngredient',
    method: 'put',
    data: data
  });
};

/**
 * 删除食材管理
 * @param foodIngredientId
 */
export const delFoodIngredient = (foodIngredientId: string | number | Array<string | number>) => {
  return request({
    url: '/system/foodIngredient/' + foodIngredientId,
    method: 'delete'
  });
};
