Skip to content

[JITERA] Implement Book Controller with CRUD Operations

Created by: chi-jitera

Overview

This pull request implements the book controller for managing book-related operations in the application. It includes the creation, retrieval, updating, deletion, and searching of books.

Changes

  1. createBook:

    • Added a method to create a new book. It uses the bookService.createBook method and returns a 201 status with the created book data or a 400 status with an error message if the creation fails.
  2. getAllBooks:

    • Implemented a method to retrieve all books. It calls bookService.getAllBooks and returns the list of books in JSON format.
  3. getBookById:

    • Added a method to retrieve a specific book by its ID. It uses bookService.getBookById and returns a 404 status with an error message if the book is not found.
  4. updateBook:

    • Implemented a method to update an existing book by its ID. It calls bookService.updateBook and returns the updated book data or a 400 status with an error message if the update fails.
  5. deleteBook:

    • Added a method to delete a book by its ID. It uses bookService.deleteBook and returns a success message or a 404 status with an error message if the book is not found.
  6. searchBooks:

    • Implemented a method to search for books based on query parameters. It calls bookService.searchBooks and returns the search results or a 400 status with an error message if the search fails.

This implementation provides a complete set of CRUD operations for managing books in the application.

Merge request reports