Skip to content

API that displays CRUD operations with Brazilian Feiras Livres

Notifications You must be signed in to change notification settings

GracieleDamasceno/api-feiras-livres

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

API Feiras Livres

This API creates, reads, updates and deletes Feiras Livres - a list of Brazilian Street Markets. A .csv from São Paulo Secretaria is imported into the system and used as datasource to populate our database.

Building and using the application

Run the following commands inside the root directory of the project:

mvn clean install package

docker build -t app-0.1.jar .

docker-compose up -d

After those commands, you should have the application up and running at http://localhost:8080/feira-livre.

In order to import the .csv data, execute the following command at the project root directory. This step should be executed after the commands above in order to allow the project to automatically create the database schema.

docker cp src/main/resources/data/DEINFO_AB_FEIRASLIVRES_2014.csv mysql:/var/lib

docker exec -i mysql mysql -u root -proot < import-data.sql

Done! Your database should be populated by now.

Requests and responses

A request file containing all endpoints to be used with your tool of choice (Postman, Insomnia, CURL) is available here.

Basically, the application has four main endpoints:

  1. Create a Feira Livre

    To create a new Feira Livre, access the following endpoint:

    POST http://localhost:8080/feira-livre

    ... and provide something along the lines of the following application/json body:

    {
       "longitude": "-46444519",
       "latitude": "-23519118",
       "setor_censitario": "355030837000160",
       "area_ponderacao": "3550308005200",
       "codigo_distrito": "36",
       "distrito": "JAGUARE",
       "codigo_subprefeitura": "27",
       "subprefeitura": "JAGUARE",
       "regiao5": "Oeste",
       "regiao8": "Oeste 2",
       "nome_feira": "SUPER FEIRA",
       "registro": "7217-6",
       "logradouro": "RUA CENTRAL DO JAGUARE",
       "numero": "S/N",
       "bairro": "VL VERDE",
       "referencia": "PRACA DA TORRE"
    }
  2. Find Feiras Livres

    To find Feiras Livres by using search filters, access the following endpoint:

    GET http://localhost:8080/feira-livre

    ... and add your search filters as request params variables. There's four filters to choose from: distrito, regiao5, nomeFeira, bairro and you can mix and match those params.

    When added the parameters, your requisition should look something like this:

    GET http://localhost:8080/feira-livre?regiao5=Oeste&distrito=JAGUARE

    If no filter is provided, all Feiras Livres are returned.

  3. Update a existing Feira Livre

    To update a Feira Livre, access the following endpoint with the desired Feira Livre ID as a Path Param:

    PUT http://localhost:8080/feira-livre/1

    ... and provide the following application/json body:

     {
         "longitude": "-46444519",
         "latitude": "-23519118",
         "setor_censitario": "355030837000160",
         "area_ponderacao": "3550308005200",
         "codigo_distrito": "36",
         "distrito": "JAGUARE",
         "codigo_subprefeitura": "27",
         "subprefeitura": "JAGUARE",
         "regiao5": "Oeste",
         "regiao8": "Oeste 2",
         "nome_feira": "SUPER FEIRA",
         "registro": "7217-6",
         "logradouro": "RUA CENTRAL DO JAGUARE",
         "numero": "S/N",
         "bairro": "VL VERDE",
         "referencia": "PRACA DA TORRE"
     }
  4. Delete a Feira Livre

    To delete a Feira Livre, access the following endpoint with the desired Feira Livre ID as a Path Param:

    DELETE http://localhost:8080/feira-livre/1

Log files and Code coverage

  1. Code Coverage: to access the report of code coverage generated by JaCoCo, use the following link after running the following Maven lifecycle:

    mvn clean test

  2. Log Files: After running the application, the log files can be found in the application.log file, located in root directory of the project.

About

API that displays CRUD operations with Brazilian Feiras Livres

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published