Skip to content

Project for practicing springboot with tests, services and deployment.

License

Notifications You must be signed in to change notification settings

RamirJunior/schedule-project

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

29 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SCHEDULE API REST
Java | Spring Security | PostgreSQL

About   |    How to use   |    Resources   |    Techs   |    Documentation   


About 👋

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.

How to Use 🚀

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

Resources:pick:

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...)

Regarding Login, you can access the following routes:

  • WARNING : There are 2 roles for auth login; ADMIN and USER. For use POSTor DELETE HTTP methods, is required have an account/login with ADMIN role registered on database. For any other HTTP methods, the USER role is available for.
  • POST /auth/register

Registrate a new user credentials with login, password and role provided in the request body, then checks if the login 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 and password 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"
}

Regarding Users, you can access the following routes:

  • 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"
}

Regarding Schedule, you can access the following routes:

  • POST /schedule

Schedules a new appointment with the description, dateTime and userIdprovided in the request body, validates if the user exists in the database according to userId, 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"
        }
    }
]

Techs 💻

Key technologies used in the project:

Documentation:book:

Guides on how to use some features concretely.:

About

Project for practicing springboot with tests, services and deployment.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages