import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { EducationVO, EducationForm, EducationQuery } from '@/api/patients/nutritionEducation/types';

/**
 * 查询营养宣教列表
 * @param query
 * @returns {*}
 */

export const listEducation = (query?: EducationQuery): AxiosPromise<EducationVO[]> => {
  return request({
    url: '/patients/nutritionEducation/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询营养宣教详细
 * @param id
 */
export const getEducation = (id: string | number): AxiosPromise<EducationVO> => {
  return request({
    url: '/patients/nutritionEducation/' + id,
    method: 'get'
  });
};

/**
 * 查询模板列表
 * @param query
 * @returns {*}
 */

export const queryTemplateList = () => {
    return request({
        url: '/patients/nutritionEducation/queryTemplateList',
        method: 'get',
    });
};


/**
 * 新增营养宣教
 * @param data
 */
export const addEducation = (data: EducationForm) => {
  return request({
    url: '/patients/nutritionEducation',
    method: 'post',
    data: data
  });
};

/**
 * 修改营养宣教
 * @param data
 */
export const updateEducation = (data: EducationForm) => {
  return request({
    url: '/patients/nutritionEducation',
    method: 'put',
    data: data
  });
};

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