This project is an API built with Spring Boot and MongoDB to manage users and roles.
- Attributes:
id
: Unique identifier for the user.userName
: User's name.lastName
: User's last name.role
: Role reference
- Attributes:
id
: Unique identifier for the role.name
: Role name.
- Gradle 8+: Gradle Installation Guide
- Docker installed: Docker Installation Guide
- Docker Compose installed: Docker Compose Installation Guide
-
Run the gradle to build jar:
./gradlew bootjar
-
Run the application with Docker Compose:
docker-compose up -d
Access the API at: http://localhost:8080/api/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
- Endpoint:
-
Get User by ID:
- Endpoint:
GET /user/{userId}
- Example:
curl http://localhost:8080/api/user/1
- Endpoint:
-
Get All Users:
- Endpoint:
GET /user
- Example:
curl http://localhost:8080/api/user
- Endpoint:
-
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
- Endpoint:
-
Delete User:
- Endpoint:
DELETE /user/{id}
- Example:
curl -X DELETE http://localhost:8080/api/user/1
- Endpoint:
-
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
- Endpoint:
-
Get Role by ID:
- Endpoint:
GET /role/{roleId}
- Example:
curl http://localhost:8080/role/api/1
- Endpoint:
-
Get All Roles:
- Endpoint:
GET /role
- Example:
curl http://localhost:8080/api/role
- Endpoint:
-
Delete Role:
- Endpoint:
DELETE /role/{id}
- Example:
curl -X DELETE http://localhost:8080/api/role/1
- Endpoint: