-
Notifications
You must be signed in to change notification settings - Fork 144
Expand file tree
/
Copy pathBookingController.java
More file actions
35 lines (29 loc) · 1.13 KB
/
BookingController.java
File metadata and controls
35 lines (29 loc) · 1.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
package ru.practicum.shareit.booking.controller;
import jakarta.validation.Valid;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;
import ru.practicum.shareit.booking.dto.BookingDto;
import ru.practicum.shareit.booking.service.BookingService;
/**
* TODO Sprint add-bookings.
*/
@RestController
@RequestMapping(path = "/bookings")
@RequiredArgsConstructor
public class BookingController {
private final BookingService bookingService;
@PostMapping
public BookingDto createBooking(@Valid @RequestBody BookingDto bookingDto,
@RequestHeader("X-Sharer-User-Id") Long bookerId) {
return bookingService.createBooking(bookingDto, bookerId);
}
@PatchMapping("/{bookingId}")
public BookingDto updateBooking(@PathVariable Long bookingId,
@RequestBody BookingDto bookingDto) {
return bookingService.updateBooking(bookingId, bookingDto);
}
@GetMapping("/{bookingId}")
public BookingDto getBookingById(@PathVariable Long bookingId) {
return bookingService.getBookingById(bookingId);
}
}