import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { NutritionSettingVO, NutritionSettingForm, NutritionSettingQuery } from '@/api/patients/nutritionSetting/types';

/**
 * 查询营养设定列表
 * @param query
 * @returns {*}
 */

export const listSetting = (query?: NutritionSettingQuery): AxiosPromise<NutritionSettingVO[]> => {
  return request({
    url: '/patients/nutritionSetting/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询营养设定详细
 * @param id
 */
export const getSetting = (id: string | number): AxiosPromise<NutritionSettingVO> => {
  return request({
    url: '/patients/nutritionSetting/' + id,
    method: 'get'
  });
};

/**
 * 新增营养设定
 * @param data
 */
export const addSetting = (data: NutritionSettingForm) => {
  return request({
    url: '/patients/nutritionSetting',
    method: 'post',
    data: data
  });
};

/**
 * 修改营养设定
 * @param data
 */
export const updateSetting = (data: NutritionSettingForm) => {
  return request({
    url: '/patients/nutritionSetting',
    method: 'put',
    data: data
  });
};

/**
 * 删除营养设定
 * @param id
 */
export const delSetting = (id: string | number | Array<string | number>) => {
  return request({
    url: '/patients/nutritionSetting/' + id,
    method: 'delete'
  });
};

/**
 * 计算
 * @param data
 */
export const recalculateValue = (data: NutritionSettingForm) => {
  return request({
    url: '/patients/nutritionSetting/recalculate',
    method: 'post',
    data: data
  });
};
