import request from '/@/utils/request';

/**
 * 分页查询团员列表
 * @param query
 */
export const fetchList = (query?: any) => {
  return request({
    url: '/stuwork/stuunionleague/page',
    method: 'get',
    params: query
  });
};

/**
 * 新增团员
 * @param data
 */
export const addObj = (data: any) => {
  return request({
    url: '/stuwork/stuunionleague',
    method: 'post',
    data
  });
};

/**
 * 获取详情
 * @param id
 */
export const getDetail = (id: string) => {
  return request({
    url: `/stuwork/stuunionleague/${id}`,
    method: 'get'
  });
};

/**
 * 编辑团员
 * @param data
 */
export const editObj = (data: any) => {
  return request({
    url: '/stuwork/stuunionleague/edit',
    method: 'post',
    data
  });
};

/**
 * 删除团员
 * @param ids
 */
export const delObj = (ids: string[]) => {
  return request({
    url: '/stuwork/stuunionleague',
    method: 'delete',
    data: ids
  });
};

/**
 * 导入团员
 * @param file 文件
 */
export const importExcel = (file: File) => {
  const formData = new FormData();
  formData.append('file', file);
  return request({
    url: '/stuwork/stuunionleague/import',
    method: 'post',
    data: formData,
    headers: {
      'Content-Type': 'multipart/form-data'
    }
  });
};

/**
 * 导出团员
 * @param query 查询参数
 */
export const exportExcel = (query?: any) => {
  return request({
    url: '/stuwork/stuunionleague/export',
    method: 'get',
    params: query,
    responseType: 'blob'
  });
};

/**
 * 获取团员统计信息（全校总数+各学院统计）
 */
export const getStatistics = () => {
  return request({
    url: '/stuwork/stuunionleague/statistics',
    method: 'get'
  });
};

