import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { MealRecipeVO, MealRecipeForm, MealRecipeQuery } from '@/api/patients/dailyMealRecipe/types';

/**
 * 查询日常膳食食谱明细列表
 * @param query
 * @returns {*}
 */

export const listMealRecipe = (query?: MealRecipeQuery): AxiosPromise<MealRecipeVO[]> => {
  return request({
    url: '/patients/dailyMealRecipe/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询日常膳食食谱明细详细
 * @param id
 */
export const getMealRecipe = (id: string | number): AxiosPromise<MealRecipeVO> => {
  return request({
    url: '/patients/dailyMealRecipe/' + id,
    method: 'get'
  });
};

/**
 * 新增日常膳食食谱明细
 * @param data
 */
export const addMealRecipe = (data: MealRecipeForm) => {
  return request({
    url: '/patients/dailyMealRecipe',
    method: 'post',
    data: data
  });
};

/**
 * 修改日常膳食食谱明细
 * @param data
 */
export const updateMealRecipe = (data: MealRecipeForm) => {
  return request({
    url: '/patients/dailyMealRecipe',
    method: 'put',
    data: data
  });
};

/**
 * 删除日常膳食食谱明细
 * @param id
 */
export const delMealRecipe = (id: string | number | Array<string | number>) => {
  return request({
    url: '/patients/dailyMealRecipe/' + id,
    method: 'delete'
  });
};
