import request from '@/utils/request'
import museumApi from './indexPage.js'
import userApi from './user.js'

// 预约相关接口（需要token）
export const reservationApi = {
  // 创建预约
  createReservation(data) {
    return request({
      url: '/reservation/create',
      method: 'post',
      data,
    })
  },

  // 获取预约列表
  getReservationList(params = {}) {
    return request({
      url: '/reservation/list',
      method: 'get',
      params: {
        pageNum: 1,
        pageSize: 10,
        ...params,
      },
    })
  },

  // 取消预约
  cancelReservation(id) {
    return request({
      url: `/reservation/cancel/${id}`,
      method: 'post',
    })
  },

  // 获取可预约时间段
  getAvailableTimeSlots(date) {
    return request({
      url: '/reservation/time-slots',
      method: 'get',
      params: { date },
    })
  },
}

// 活动报名相关接口（需要token）
export const activityApi = {
  // 报名活动
  registerActivity(activityId, data) {
    return request({
      url: `/activity/register/${activityId}`,
      method: 'post',
      data,
    })
  },

  // 取消报名
  cancelActivity(activityId) {
    return request({
      url: `/activity/cancel/${activityId}`,
      method: 'post',
    })
  },

  // 获取我的报名列表
  getMyActivityList(params = {}) {
    return request({
      url: '/activity/my-list',
      method: 'get',
      params: {
        pageNum: 1,
        pageSize: 10,
        ...params,
      },
    })
  },
}

// 收藏相关接口（需要token）
export const favoriteApi = {
  // 收藏典藏
  favoriteCollection(collectionId) {
    return request({
      url: `/collection/favorite/${collectionId}`,
      method: 'post',
    })
  },

  // 取消收藏
  unfavoriteCollection(collectionId) {
    return request({
      url: `/collection/unfavorite/${collectionId}`,
      method: 'post',
    })
  },

  // 获取收藏列表
  getFavoriteList(params = {}) {
    return request({
      url: '/collection/favorite/list',
      method: 'get',
      params: {
        pageNum: 1,
        pageSize: 10,
        ...params,
      },
    })
  },
}

// 导出所有API
export { museumApi, userApi }

export default {
  museumApi,
  reservationApi,
  userApi,
  activityApi,
  favoriteApi,
}
