This document provides a comprehensive guide to setting up, running, and interacting with the application. The application is a library management system that allows users to manage books and patrons, as well as borrow and return books.
Before you begin, ensure you have the following installed:
- Java 17
- Apache Maven
- Git
- Clone the repository:
git clone https://github.com/EmanSaeed331/Spring-Library-managment-sys cd your-repository
-
Build the application:
mvn clean install
-
Run the application:
mvn spring-boot:run
The application will start on
http://localhost:8080
.
-
Get Book by ID
- Endpoint:
GET /api/books/{id}
- Response:
{ "id": 1, "title": "Test title", "author": "Test author", "isbn": "1234567890", "publishedDate": "2022", "available": true, "borrowingRecords": [] }
- Endpoint:
-
Get All Books
- Endpoint:
GET /api/books
- Response: Array of books.
- Endpoint:
-
Add Book
- Endpoint:
POST /api/books
- Request Body:
{ "title": "New Book", "author": "Author Name", "isbn": "0987654321", "publishedDate": "2023", "available": true }
- Response: 201 Created
- Endpoint:
-
Update Book
- Endpoint:
PUT /api/books/{id}
- Request Body: Same as Add Book
- Response: 200 OK
- Endpoint:
-
Get Patron by ID
- Endpoint:
GET /api/patrons/{id}
- Response:
{ "id": 1, "name": "Patron Name", "email": "patron@example.com", "borrowedBooks": [] }
- Endpoint:
-
Get All Patrons
- Endpoint:
GET /api/patrons
- Response: Array of patrons.
- Endpoint:
-
Add Patron
- Endpoint:
POST /api/patrons
- Request Body:
{ "name": "New Patron", "email": "newpatron@example.com" }
- Response: 201 Created
- Endpoint:
-
Update Patron
- Endpoint:
PUT /api/patrons/{id}
- Request Body: Same as Add Patron
- Response: 200 OK
- Endpoint:
-
Borrow Book
- Endpoint:
POST /borrow/{bookId}/patron/{patronId}
- Response: 201 Created, "Book Borrowed Successfully"
- Endpoint:
-
Return Book
- Endpoint:
PUT /return/{bookId}/patron/{patronId}
- Response: 200 OK, "Book Returned Successfully"
- Endpoint: