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

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

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

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

/**
 * 编辑活动
 * @param data
 */
export const editObj = (data: any) => {
  return request({
    url: '/stuwork/activityinfo',
    method: 'put',
    data
  });
};

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

/**
 * 导入子项目
 * @param id 活动ID
 * @param file 文件
 */
export const importSub = (id: string, file: File) => {
  const formData = new FormData();
  formData.append('file', file);
  return request({
    url: `/stuwork/activityinfo/importSub/${id}`,
    method: 'post',
    data: formData,
    headers: {
      'Content-Type': 'multipart/form-data'
    }
  });
};

