import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { MealPlanVO, MealPlanForm, MealPlanQuery } from '@/api/patients/dailyMealPlan/types';

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

export const listDailyMealPlan = (query?: MealPlanQuery): AxiosPromise<MealPlanVO[]> => {
  return request({
    url: '/patients/dailyMealPlan/list',
    method: 'get',
    params: query
  });
};

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

/**
 * 新增日常膳食主
 * @param data
 */
export const addMealPlan = (data: MealPlanForm) => {
  return request({
    url: '/patients/dailyMealPlan',
    method: 'post',
    data: data
  });
};

/**
 * 修改日常膳食主
 * @param data
 */
export const updateMealPlan = (data: MealPlanForm) => {
  return request({
    url: '/patients/dailyMealPlan',
    method: 'put',
    data: data
  });
};

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