import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { EnteralNutritionTemplateVO, EnteralNutritionTemplateForm, EnteralNutritionTemplateQuery } from '@/api/parameter/basicPublicTemplate/enteralNutritionTemplate/types';

/**
 * 查询肠内处方模板列表
 * @param query
 * @returns {*}
 */

export const listEnteralNutritionTemplate = (query?: EnteralNutritionTemplateQuery): AxiosPromise<EnteralNutritionTemplateVO[]> => {
  return request({
    url: '/parameter/basicPublicTemplate/enteralNutritionTemplate/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询肠内处方模板详细
 * @param id
 */
export const getEnteralNutritionTemplate = (id: string | number): AxiosPromise<EnteralNutritionTemplateVO> => {
  return request({
    url: '/parameter/basicPublicTemplate/enteralNutritionTemplate/' + id,
    method: 'get'
  });
};

/**
 * 新增肠内处方模板
 * @param data
 */
export const addEnteralNutritionTemplate = (data: EnteralNutritionTemplateForm) => {
  return request({
    url: '/parameter/basicPublicTemplate/enteralNutritionTemplate',
    method: 'post',
    data: data
  });
};

/**
 * 修改肠内处方模板
 * @param data
 */
export const updateEnteralNutritionTemplate = (data: EnteralNutritionTemplateForm) => {
  return request({
    url: '/parameter/basicPublicTemplate/enteralNutritionTemplate',
    method: 'put',
    data: data
  });
};

/**
 * 查询所有肠内处方模板（不分页）
 * @returns {*}
 */
export const listAllEnteralNutritionTemplate = (): AxiosPromise<EnteralNutritionTemplateVO[]> => {
  return request({
    url: '/parameter/basicPublicTemplate/enteralNutritionTemplate/listAll',
    method: 'get'
  });
};

/**
 * 删除肠内处方模板
 * @param id
 */
export const delEnteralNutritionTemplate = (id: string | number | Array<string | number>) => {
  return request({
    url: '/parameter/basicPublicTemplate/enteralNutritionTemplate/' + id,
    method: 'delete'
  });
};
