Skip to content

01Rian/api-mongo-spring-boot

Repository files navigation

User and Role Management API

Description

This project is an API built with Spring Boot and MongoDB to manage users and roles.

Entities

User

  • Attributes:
    • id: Unique identifier for the user.
    • userName: User's name.
    • lastName: User's last name.
    • role: Role reference

Role

  • Attributes:
    • id: Unique identifier for the role.
    • name: Role name.

Prerequisites

How to Run the Application

  1. Run the gradle to build jar:

    ./gradlew bootjar
  2. Run the application with Docker Compose:

    docker-compose up -d

API Endpoints

Access the API at: http://localhost:8080/api/user

Users (User)

  • Create User:

    • Endpoint: POST /user
    • Body: JSON containing user attributes.
    • Example:
      curl -X POST -H "Content-Type: application/json" -d '{"userName":"john_doe","lastName":"Doe","role":{"id":"1","roleName":"admin"}}' http://localhost:8080/api/user
  • Get User by ID:

    • Endpoint: GET /user/{userId}
    • Example:
      curl http://localhost:8080/api/user/1
  • Get All Users:

    • Endpoint: GET /user
    • Example:
      curl http://localhost:8080/api/user
  • Update User:

    • Endpoint: PUT /user
    • Body: JSON containing updated user attributes.
    • Example:
      curl -X PUT -H "Content-Type: application/json" -d '{"id":"1","userName":"updated_user","lastName":"Updated","role":{"id":"1","roleName":"admin"}}' http://localhost:8080/api/user
  • Delete User:

    • Endpoint: DELETE /user/{id}
    • Example:
      curl -X DELETE http://localhost:8080/api/user/1

Roles (Role)

  • Create Role:

    • Endpoint: POST /role
    • Body: JSON containing role attributes.
    • Example:
      curl -X POST -H "Content-Type: application/json" -d '{"roleName":"admin"}' http://localhost:8080/api/role
  • Get Role by ID:

    • Endpoint: GET /role/{roleId}
    • Example:
      curl http://localhost:8080/role/api/1
  • Get All Roles:

    • Endpoint: GET /role
    • Example:
      curl http://localhost:8080/api/role
  • Delete Role:

    • Endpoint: DELETE /role/{id}
    • Example:
      curl -X DELETE http://localhost:8080/api/role/1

Front-End

About

Rest API Create With Spring Boot 3, MongoDB and Docker

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published