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.
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.
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:
-
Create a Feira Livre
To create a new Feira Livre, access the following endpoint:
... 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" }
-
Find Feiras Livres
To find Feiras Livres by using search filters, access the following endpoint:
... 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.
-
Update a existing Feira Livre
To update a Feira Livre, access the following endpoint with the desired Feira Livre ID as a Path Param:
... 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" }
-
Delete a Feira Livre
To delete a Feira Livre, access the following endpoint with the desired Feira Livre ID as a Path Param:
-
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
-
Log Files: After running the application, the log files can be found in the
application.log
file, located in root directory of the project.