Skip to content

[JITERA] Implement Book Controller with CRUD Operations

chi le requested to merge feat/book-controller-implementation-1758246072 into main

Created by: chi-jitera

Overview

This pull request introduces a new book controller that implements CRUD (Create, Read, Update, Delete) operations for managing books in the application. The controller interacts with the book service to perform the necessary operations and handle responses.

Changes

  1. createBook:

    • Added a method to create a new book. It accepts the book data from the request body and returns the created book with a 201 status code. If an error occurs, it responds with a 400 status code and the error message.
  2. getAllBooks:

    • Implemented a method to retrieve all books. It calls the book service to fetch the list of books and returns them in the response.
  3. getBookById:

    • Added a method to fetch a specific book by its ID. It handles errors by returning a 404 status code if the book is not found.
  4. updateBook:

    • Implemented a method to update an existing book. It takes the book ID from the request parameters and the updated data from the request body. It returns the updated book or a 400 status code in case of an error.
  5. deleteBook:

    • Added a method to delete a book by its ID. It returns a success message or a 404 status code if the book is not found.

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

Merge request reports