import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { EducationTemplateVO, EducationTemplateForm, EducationTemplateQuery } from '@/api/parameter/basicPublicTemplate/nutritionEducationTemplate/types';

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

export const listEducationTemplate = (query?: EducationTemplateQuery): AxiosPromise<EducationTemplateVO[]> => {
    return request({
        url: '/basicPublicTemplate/educationTemplate/list',
        method: 'get',
        params: query
    });
};

/**
 * 查询营养宣教模板详细
 * @param id
 */
export const getEducationTemplate = (id: string | number): AxiosPromise<EducationTemplateVO> => {
    return request({
        url: '/basicPublicTemplate/educationTemplate/' + id,
        method: 'get'
    });
};

/**
 * 新增营养宣教模板
 * @param data
 */
export const addEducationTemplate = (data: EducationTemplateForm) => {
    return request({
        url: '/basicPublicTemplate/educationTemplate',
        method: 'post',
        data: data
    });
};

/**
 * 修改营养宣教模板
 * @param data
 */
export const updateEducationTemplate = (data: EducationTemplateForm) => {
    return request({
        url: '/basicPublicTemplate/educationTemplate',
        method: 'put',
        data: data
    });
};

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