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

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

/**
 * 新增文明宿舍
 * @param data
 */
export const addObj = (data: any) => {
  return request({
    url: '/stuwork/rewarddorm',
    method: 'post',
    data
  });
};

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

/**
 * 编辑文明宿舍
 * @param data
 */
export const editObj = (data: any) => {
  return request({
    url: '/stuwork/rewarddorm/edit',
    method: 'post',
    data
  });
};

/**
 * 删除文明宿舍
 * @param ids
 */
export const delObj = (ids: string[]) => {
  return request({
    url: '/stuwork/rewarddorm/delete',
    method: 'post',
    data: ids
  });
};

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

