// 使用模拟服务代替真实请求
import mockService from '@/api/mock/parking-mock-service'
// 查询车位列表
export function listParkingSpace(query) {
    return mockService.listParkingSpace(query)
}

// 查询车位详细
export function getParkingSpace(id) {
    return mockService.getParkingSpace(id)
}

// 新增车位
export function addParkingSpace(data) {
    return mockService.addParkingSpace(data)
}

// 修改车位
export function updateParkingSpace(data) {
    return mockService.updateParkingSpace(data)
}

// 删除车位
export function delParkingSpace(id) {
    return mockService.delParkingSpace(id)
}

// 导出车位
export function exportParkingSpace(query) {
    return mockService.exportParkingSpace(query)
}

// 批量更新车位状态
export function updateParkingSpaceStatus(data) {
    return request({
        url: '/parking/space/status',
        method: 'put',
        data: data
    })
}

// 获取指定楼栋的车位列表
export function listSpaceByBuilding(buildingId) {
    return request({
        url: '/parking/space/building/' + buildingId,
        method: 'get'
    })
}

// 获取空闲车位列表
export function listFreeSpace(query) {
    return request({
        url: '/parking/space/free',
        method: 'get',
        params: query
    })
}

// 车位预约
export function reserveSpace(data) {
    return request({
        url: '/parking/space/reserve',
        method: 'post',
        data: data
    })
}

// 取消预约
export function cancelReservation(spaceId) {
    return request({
        url: '/parking/space/reserve/' + spaceId,
        method: 'delete'
    })
}

// 获取车位占用历史
export function getSpaceHistory(spaceId, query) {
    return request({
        url: '/parking/space/history/' + spaceId,
        method: 'get',
        params: query
    })
}

// 批量导入车位
export function importParkingSpace(file) {
    const formData = new FormData()
    formData.append('file', file)
    return request({
        url: '/parking/space/import',
        method: 'post',
        data: formData,
        headers: {
            'Content-Type': 'multipart/form-data'
        }
    })
}

// 下载车位导入模板
export function downloadTemplate() {
    return request({
        url: '/parking/space/template',
        method: 'get',
        responseType: 'blob'
    })
}