import request from '@/utils/request';

/**
 * 查询事件列表
 * @param query
 * @returns {*}
 */

export const listEvent = (query) => {
  return request({
    url: '/system/event/list',
    method: 'get',
    params: query
  });
};
export const generateReport = (id, type) => {
  let url = `/system/event/generate/${id}`;
  if (type) {
    url = `/system/event/generate/${id}?type=${type}`;
  }
  return request({
    url,
    method: 'post'
  });
};
export const getEventTypes = () => {
  return request({
    url: '/system/event/types',
    method: 'get'
  });
};

/**
 * 查询事件详细
 * @param id
 */
export const getEvent = (id: string | number) => {
  return request({
    url: '/system/event/' + id,
    method: 'get'
  });
};

/**
 * 新增事件
 * @param data
 */
export const addEvent = (data) => {
  return request({
    url: '/system/event',
    method: 'post',
    data: data
  });
};

/**
 * 修改事件
 * @param data
 */
export const updateEvent = (data) => {
  return request({
    url: '/system/event',
    method: 'put',
    data: data
  });
};

/**
 * 删除事件
 * @param id
 */
export const delEvent = (id: string | number | Array<string | number>) => {
  return request({
    url: '/system/event/' + id,
    method: 'delete'
  });
};
