diff --git a/src/main/java/project/bookstore/BookStoreApplication.java b/src/main/java/project/bookstore/BookStoreApplication.java index 497b2b6..9b4f470 100644 --- a/src/main/java/project/bookstore/BookStoreApplication.java +++ b/src/main/java/project/bookstore/BookStoreApplication.java @@ -5,7 +5,6 @@ @SpringBootApplication public class BookStoreApplication { - public static void main(String[] args) { SpringApplication.run(BookStoreApplication.class, args); } diff --git a/src/main/java/project/bookstore/controller/BookController.java b/src/main/java/project/bookstore/controller/BookController.java index 7d5a9fd..39f1e09 100644 --- a/src/main/java/project/bookstore/controller/BookController.java +++ b/src/main/java/project/bookstore/controller/BookController.java @@ -3,7 +3,9 @@ import java.util.List; import lombok.RequiredArgsConstructor; import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; import project.bookstore.dto.BookDto; @@ -23,13 +25,13 @@ public List getAll() { return bookService.findAll(); } - @GetMapping - public BookDto getBookById(Long id) { + @GetMapping("/{id}") + public BookDto getBookById(@PathVariable Long id) { return bookService.getBookById(id); } @PostMapping - public BookDto createBook(CreateBookRequestDto requestBookDto) { + public BookDto createBook(@RequestBody CreateBookRequestDto requestBookDto) { return bookMapper.toDto(bookService.save(requestBookDto)); } } diff --git a/src/main/java/project/bookstore/repository/BookRepository.java b/src/main/java/project/bookstore/repository/BookRepository.java index 3d2dd6f..c08dc94 100644 --- a/src/main/java/project/bookstore/repository/BookRepository.java +++ b/src/main/java/project/bookstore/repository/BookRepository.java @@ -1,7 +1,6 @@ package project.bookstore.repository; import java.util.List; -import project.bookstore.dto.BookDto; import project.bookstore.model.Book; public interface BookRepository {