Giter Site home page Giter Site logo

ajaynegi45 / library-api Goto Github PK

View Code? Open in Web Editor NEW
11.0 2.0 4.0 60 KB

Spring Boot RESTful API that allows users to manage a collection of books. Users can perform various CRUD (Create, Read, Update, Delete) operations on books using this API.

License: MIT License

Java 72.63% HTML 27.37%
java library-management-system mysql restful-api springboot springdatajpa hacktoberfest

library-api's Introduction

Library-API Project ๐Ÿ“š

This project is a simple Spring Boot application that provides a RESTful API for managing books. It allows users to perform CRUD (Create, Read, Update, Delete) operations on books using the API. It adding new books, updating existing ones, searching for books, and deleting books.

Project Structure ๐Ÿ“‚

The project consists of several components, each serving a specific purpose:

  1. Controller: Defines the RESTful endpoints for handling book-related requests. It interacts with the Service to perform various operations.

  2. Service: Contains the business logic for book-related operations. It interacts with the DAO to access the database.

  3. DAO: Provides access to the database using Spring Data JPA. It extends the JpaRepository interface to enable CRUD operations.

  4. Entities: Represents the entity (model) for a book. It is annotated with @Entity to indicate it's a JPA entity and corresponds to a database table.


API Endpoints ๐Ÿ”—

API Collection Documentation on Postman for testing API

Add Book ๐Ÿ“—

Add a new book to the database.

  • URL: POST /addBook
  • Request Body:
    {
      "bookName": "Book Title",
      "authorName": "Author Name",
      "bookPrice": 29.99,
      "stockQuantity": 50
    }
  • Response:
    • 201 Created: Book added successfully
    • 409 CONFLICT: if there is a conflict (e.g., book not able to store ).
    • 500 INTERNAL_SERVER_ERROR: if there is an internal server error.

Update Book ๐Ÿ“˜

Update an existing book's details by providing the book ID.

  • URL: PUT /updatebook/{bookid}
  • Request Body:
    {
      "bookName": "Updated Book Name",
      "authorName": "Updated Author Name",
      "bookPrice": "Updated Book Price",
      "stockQuantity": "Updated Stock Quantity"
    }
  • Response:
    • 202 Accepted: Book updated successfully
    • 404 Not Found: Book with the given ID not found


GET Book ๐Ÿ“”

Endpoint Method URL Request Parameter Response
Get All Books GET /getAllBooks None List of BookEntity objects
Get Book by ID GET /getBookById/{id} id (Path parameter) BookEntity object
Get Books by Name Starting With GET /bookNameStartWith/{bookName} bookName (Path parameter) List of BookEntity objects
Get Books by Name Ending With GET /bookNameEndWith/{bookName} bookName (Path parameter) List of BookEntity objects
Get Books by Name Containing GET /bookNameContain/{bookName} bookName (Path parameter) List of BookEntity objects


DELETE Book ๐Ÿ“•

Endpoint Method URL Request Parameter Response
Delete Book by ID DELETE /deleteBookById/{id} id (Path parameter) 202 Accepted : Book deleted successfully

OR

404 Not Found : Book with the given ID not found
Delete Book by Name DELETE /deleteBookByName/{bookName} bookName (Path parameter) 202 Accepted : Books deleted successfully

OR

404 Not Found : No books found with the given name
Delete Books by Author DELETE /deleteAllByAuthor/{authorName} authorName (Path parameter) 202 Accepted : Books deleted successfully

OR

404 Not Found : No books found with the given author name

How to Run the Project ๐Ÿ’จ

  1. Ensure you have Java and MySQL installed on your system.
  2. Clone or download the project from the repository.
  3. Import the project into your preferred IDE (e.g., Eclipse, IntelliJ).
  4. Set up the MySQL database and update the database configurations in the application.properties file (not provided in the code).
  5. Build and run the project using the IDE or by running mvn spring-boot:run command from the project root directory.

Technologies Used ๐ŸŒ



โ€ผ๏ธ Important Note โ€ผ๏ธ

  • You need to set up the database and make sure the application properties are correctly configured to run the project successfully.

Upcoming Update

Adding more features, error handling, authentication, and security measures.

Contributing ๐Ÿค—

Feel free to explore and use these project. If you encounter any issues or have suggestions for improvements, please feel free to contribute or reach out for assistance.

Contributions are always welcome! โœจ

See contributing.md for ways to get started.

Please adhere to this project's code_of_conduct.md.

Contact Information ๐Ÿ“ง

If you have any questions or would like to connect, please don't hesitate to reach out. I'd be more than happy to chat and learn from your experiences too.

Email: contact me

Thankyou โค๏ธ

Thank you for taking the time to explore my project. I hope you find them informative and useful in your journey to learn Java and enhance your programming skills. Your support and contributions are highly appreciated. Happy coding! โœจ

Authors

  • ๐Ÿ™๐Ÿปโ€โ™‚๏ธ @ajaynegi45

Contributors

  • ๐Ÿ™๐Ÿปโ€โ™‚๏ธ @LewisRye

library-api's People

Contributors

ajaynegi45 avatar lewisrye avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

library-api's Issues

Adding API cURLs/Swagger

For the sake of convenience of API testing & maintainence, we can do the following:

  1. Add cURLs for all the APIs to the README of this project
  2. Add Swagger integration for auto documentation.

I would be happy to do any (or both) if you agree.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.