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

/**
 * 根据班级代码查询宿舍学生数量
 * @param classCode 班级代码
 */
export const fearchStuNumByClassCode = (classCode: string | number) => {
  return request({
    url: '/stuwork/dormroomstudent/fearchStuNumByClassCode',
    method: 'get',
    params: { classCode },
  });
};

/**
 * 查询空宿舍列表
 * @param buildingNo 楼号
 */
export const queryEmptyRoomWithBuildingNo = (buildingNo: string) => {
	return request({
		url: '/stuwork/dormroomstudent/queryEmptyRoomWithBuildingNo',
		method: 'get',
		params: { buildingNo }
	});
};

/**
 * 查询空几人宿舍列表
 * @param buildingNo 楼号
 * @param roomType 空几人（1-5）
 */
export const queryEmtryRoomDetail = (buildingNo: string, roomType: string) => {
	return request({
		url: '/stuwork/dormroomstudent/queryEmtryRoomDetail',
		method: 'get',
		params: { buildingNo, roomType }
	});
};

/**
 * 查询异常住宿学生列表
 */
export const queryStudentAbnormal = () => {
	return request({
		url: '/stuwork/dormroomstudent/queryStudentAbnormal',
		method: 'get'
	});
};

/**
 * 分页查询住宿学生列表
 */
export const fetchList = (query?: any) => {
	return request({
		url: '/stuwork/dormroomstudent/page',
		method: 'get',
		params: query
	});
};

/**
 * 新增住宿学生
 */
export const addObj = (data: any) => {
	return request({
		url: '/stuwork/dormroomstudent',
		method: 'post',
		data
	});
};

/**
 * 转宿
 */
export const editObj = (data: any) => {
	return request({
		url: '/stuwork/dormroomstudent/edit',
		method: 'post',
		data
	});
};

/**
 * 退宿
 */
export const delObjs = (ids: string[]) => {
	return request({
		url: '/stuwork/dormroomstudent/delete',
		method: 'post',
		data: ids
	});
};

/**
 * 获取床位号列表
 * @param roomNo 宿舍号
 */
export const fearchRoomStuNum = (roomNo: string) => {
	return request({
		url: '/stuwork/dormroomstudent/fearchRoomStuNum',
		method: 'get',
		params: { roomNo }
	});
};

/**
 * 互换宿舍（文档：sourceSutNo / targetStuNO）
 */
export const exchangeRoom = (data: { sourceSutNo: string; targetStuNO: string }) => {
	return request({
		url: '/stuwork/dormroomstudent/exchangeRoom',
		method: 'post',
		data
	});
};

/**
 * 打印宿舍卡（按房间号获取打印数据）
 */
export const printDormRoomData = (roomNo: string) => {
	return request({
		url: '/stuwork/dormroomstudent/printDormRoomData',
		method: 'get',
		params: { roomNo }
	});
};

/**
 * 空 n 人宿舍导出
 */
export const exportEmptyPeopleRoomExcel = (data?: any) => {
	return request({
		url: '/stuwork/dormroomstudent/exportEmptyPeopleRoomExcel',
		method: 'post',
		data: data || {},
		responseType: 'blob'
	});
};

