About | How to use | Resources | Techs | Documentation
The Schedule API
is a REST API designed to manage a user's appointment schedule. It allows users to register and perform CRUD operations on appointments for scheduled days. Users can create, edit, delete, and list tasks, all according to their authenticated and authorized access. The API was developed using Java, Maven, Spring Boot, and PostgreSQL as the database.
First, start the application server with the command:
mvn spring-boot:run
I used the information below for access:
- JDBC URL:
jdbc:postgresql://localhost:5432/my-schedule-db
- Usuário:
postgres
- Senha:
123
Schedule API works with the following tables:
Login
- User Auth (username, password, role...)Users
- Content user data (name, lastname, email...)Schedule
- Content schedule data (userId, description, createdAt...)
- WARNING : There are 2 roles for auth login;
ADMIN
andUSER
. For usePOST
orDELETE
HTTP methods, is required have an account/login withADMIN
role registered on database. For any other HTTP methods, theUSER
role is available for.
POST /auth/register
Registrate a new user credentials with
login
,password
androle
provided in the request body, then checks if thelogin
field already exists in the table.
// URL Example:
POST localhost:8080/auth/register
Response Example
{
"login": "ramirjunior",
"password": "$2a$10$4/JSwYWuKEOTXWISqAmH6e1XYDIrz3Y5.W0xyiksIQu3svtzMHtVS",
"role": "ADMIN"
}
POST /auth/login
Execute the login previosly registered on application. The
login
andpassword
must to be provided in the request body. Returns a bearer token in authentication successful case.
// URL Example:
POST localhost:8080/auth/login
Response Example
{
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzY2hlZHVsZS1hcGkiLCJzdWIiOiJndWVzdCIsImV4cCI6MTY5OTQyNTg1OX0.UFnt5fQKeJWXg_l8-6uyNtrF3gkay2z34GpLzwAHXzk"
}
POST /user
Creates a new user with the data provided in the request body and checks if the user's email already exists in the database.
// URL Example:
POST localhost:8080/user
Response Example
{
"id": "3a056937-d969-45f3-9e9d-1bb3b8be7146",
"name": "Ramir",
"lastname": "Junior"
}
GET /user
Lists all registered users in the database.
// URL Example:
GET localhost:8080/user
Response Example
[
{
"id": "3a056937-d969-45f3-9e9d-1bb3b8be7146",
"name": "Ramir",
"lastname": "Junior"
},
{
"id": "02f1b7e8-7ac7-4c4b-ac92-e940dca5477e",
"name": "Mariana",
"lastname": "Ribeiro"
}
]
GET /user/id
Returns the user found corresponding to the
id
provided in the URI.
// URL Example:
GET localhost:8080/user/02f1b7e8-7ac7-4c4b-ac92-e940dca5477e
Response Example
{
"id": "02f1b7e8-7ac7-4c4b-ac92-e940dca5477e",
"name": "Mariana",
"lastname": "Ribeiro"
}
PUT /user/id
Updates the user corresponding to the id according to the information provided in the request
body
.
// URL Example:
PUT localhost:8080/user/02f1b7e8-7ac7-4c4b-ac92-e940dca5477e
Response Example
{
"id": "02f1b7e8-7ac7-4c4b-ac92-e940dca5477e",
"name": "Mari",
"lastname": "Ribeiro"
}
DELETE /user/id
Deletes the user record corresponding to the provided
id
.
// URL Example:
DELETE localhost:8080/user/02f1b7e8-7ac7-4c4b-ac92-e940dca5477e
Response Example
{
"id": "02f1b7e8-7ac7-4c4b-ac92-e940dca5477e",
"name": "Mariana",
"lastname": "Ribeiro"
}
POST /schedule
Schedules a new appointment with the
description, dateTime
anduserId
provided in the request body, validates if the user exists in the database according touserId
, and also validates if the desired date is a future or current date.
// URL Example:
POST localhost:8080/schedule
Response Example
{
"id": "583a02ff-9541-4484-a6f6-f395cbc5e90d",
"description": "Estudar Custom Validations",
"dateTime": "2023-12-13T09:00:02.0386635",
"user": {
"id": "3a056937-d969-45f3-9e9d-1bb3b8be7146",
"name": "Ramir",
"lastname": "Junior"
}
}
GET /schedule
Returns a list of all appointments registered in the database.
// URL Example:
GET localhost:8080/user
Response Example
[
{
"id": "583a02ff-9541-4484-a6f6-f395cbc5e90d",
"description": "Estudar Custom Validations",
"dateTime": "2023-12-13T09:00:02.0386635",
"user": {
"id": "3a056937-d969-45f3-9e9d-1bb3b8be7146",
"name": "Ramir",
"lastname": "Junior"
}
},
{
"id": "3f660fdb-0a63-4ba2-aabb-27d30d2df328",
"description": "Reunião com o time de desenvolvimento",
"dateTime": "2023-11-30T19:30:00.400832",
"user": {
"id": "02f1b7e8-7ac7-4c4b-ac92-e940dca5477e",
"name": "Mari",
"lastname": "Ribeiro"
}
}
]
Key technologies used in the project:
- Spring Initializr
- Spring Web
- Spring Data JPA
- Spring Security
- Java-Jwt
- Project Lombok
- Flyway
- Model Mapper
Guides on how to use some features concretely.: