import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { VolunteeringVO, VolunteeringForm, VolunteeringQuery } from '@/api/ygpassport/volunteering/types';

/**
 * 查询志愿服务列表
 * @param query
 * @returns {*}
 */

export const listVolunteering = (query?: VolunteeringQuery): AxiosPromise<VolunteeringVO[]> => {
  return request({
    url: '/ygpassport/volunteering/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询志愿服务详细
 * @param id
 */
export const getVolunteering = (id: string | number): AxiosPromise<VolunteeringVO> => {
  return request({
    url: '/ygpassport/volunteering/' + id,
    method: 'get'
  });
};

/**
 * 新增志愿服务
 * @param data
 */
export const addVolunteering = (data: VolunteeringForm) => {
  return request({
    url: '/ygpassport/volunteering',
    method: 'post',
    data: data
  });
};

/**
 * 修改志愿服务
 * @param data
 */
export const updateVolunteering = (data: VolunteeringForm) => {
  return request({
    url: '/ygpassport/volunteering',
    method: 'put',
    data: data
  });
};

/**
 * 删除志愿服务
 * @param id
 */
export const delVolunteering = (id: string | number | Array<string | number>) => {
  return request({
    url: '/ygpassport/volunteering/' + id,
    method: 'delete'
  });
};
