import { requestClient } from '#/api/request';

export namespace BookingApi {
  /** 预订列表查询参数 */
  export interface ListParams {
    page?: number;
    limit?: number;
    classroom_id?: number;
    booking_date?: string;
    status?: number;
    student_id?: number;
    type?: string;
  }

  /** 预订信息 */
  export interface BookingInfo {
    id?: number;
    booking_no?: string | null;
    classroom_id?: number;
    seat_number?: string;
    user_id?: number | null;
    user_name?: string | null;
    booking_date?: string;
    start_time?: string;
    end_time?: string;
    purpose?: string | null;
    status?: number;
    remark?: string | null;
    create_time?: string;
    update_time?: string;
    seat_row_index?: number;
    seat_col_index?: number;
    student_id?: number;
    classroom_name?: string;
    time_range?: string;
    [key: string]: any;
  }

  /** 同意座位变更申请参数 */
  export interface ApproveParams {
    id: number;
  }

  /** 拒绝座位变更申请参数 */
  export interface RejectParams {
    id: number;
    reason: string;
  }
}

/**
 * 获取预订列表
 * GET /api/admin/booking/list
 */
export async function getBookingListApi(params?: BookingApi.ListParams) {
  // 使用 responseReturn: 'body' 获取完整响应体
  return requestClient.get<any>('/api/admin/booking/list', {
    params,
    responseReturn: 'body',
  });
}

/**
 * 同意座位变更申请
 * POST /api/admin/booking/approve
 */
export async function approveBookingApi(data: BookingApi.ApproveParams) {
  return requestClient.post('/api/admin/booking/approve', data);
}

/**
 * 拒绝座位变更申请
 * POST /api/admin/booking/reject
 */
export async function rejectBookingApi(data: BookingApi.RejectParams) {
  return requestClient.post('/api/admin/booking/reject', data);
}

