https://github.com/thallyta-castro-cv/cities-api-java
Neste projeto foi desenvolvido uma API Rest de consulta de cidades do Brasil com dados comparativos em Java, SpringBoot e SpringData.
https://github.com/thallyta-castro-cv/cities-api-java
hibernate java postgres postgresql spring-boot spring-data sql
Last synced: about 2 months ago
JSON representation
Neste projeto foi desenvolvido uma API Rest de consulta de cidades do Brasil com dados comparativos em Java, SpringBoot e SpringData.
- Host: GitHub
- URL: https://github.com/thallyta-castro-cv/cities-api-java
- Owner: thallyta-castro-cv
- Created: 2021-11-01T20:50:08.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2022-02-06T15:56:04.000Z (over 4 years ago)
- Last Synced: 2025-08-25T23:35:59.484Z (10 months ago)
- Topics: hibernate, java, postgres, postgresql, spring-boot, spring-data, sql
- Language: Java
- Homepage:
- Size: 68.4 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Desafio API para consulta de cidades do Brasil com Java

# Sobre o projeto
Projeto desenvolvido para o bootcamp Quality Assurence Beginner #3 da Everis NTT Data.
Neste projeto foi desenvolvido uma API Rest de consulta de cidades do Brasil com dados comparativos em Java, SpringBoot e SpringData.
# Tecnologias Utilizadas
##### Framework do Projeto
- [Spring Initializr](https://start.spring.io/ "Spring Initializr")
- **Project:** Gradle Project
- **Language:** Java
##### Project Metadata
- **Group:** com.github.thallytacastrocv
- **Artifact:** cities-api
- **Name:** cities-api
- **Description:** Demo Project for Spring Boot
- **Package name:** com.github.thallytacastrocv.cities-api
- **Packaging:** Jar
- **Java:** 8
# Requisitos para desenvolvimento do projeto
* Linux
* Git
* Java 8
* Docker
* IntelliJ Community
* Heroku CLI
### Spring Boot
* [https://start.spring.io/](https://start.spring.io/)
+ Java 8
+ Gradle Project
+ Jar
+ Spring Web
+ Spring Data JPA
+ PostgreSQL Driver
### Spring Data
* [jpa.query-methods](https://docs.spring.io/spring-data/jpa/docs/current/reference/html/#jpa.query-methods)
### Propriedades
* [appendix-application-properties](https://docs.spring.io/spring-boot/docs/current/reference/html/appendix-application-properties.html)
* [jdbc-database-connectio](https://www.codejava.net/java-se/jdbc/jdbc-database-connection-url-for-common-databases)
### Tipos
* [JsonTypes](https://github.com/vladmihalcea/hibernate-types)
* [UserType](https://docs.jboss.org/hibernate/orm/3.5/api/org/hibernate/usertype/UserType.html)
### Heroku
* [DevCenter](https://devcenter.heroku.com/articles/getting-started-with-gradle-on-heroku)
### Qualidade de código
#### PMD
+ https://pmd.github.io/pmd-6.8.0/index.html
# Como executar o projeto
## Banco de dados
### Postgres
* [Postgres Docker Hub](https://hub.docker.com/_/postgres)
```shell script
docker run --name cities-db -d -p 5432:5432 -e POSTGRES_USER=postgres_user_city -e POSTGRES_PASSWORD=super_password -e POSTGRES_DB=cities postgres
```
### Populate
* [data](https://github.com/chinnonsantos/sql-paises-estados-cidades/tree/master/PostgreSQL)
```shell script
cd ~/workspace/sql-paises-estados-cidades/PostgreSQL
docker run -it --rm --net=host -v $PWD:/tmp postgres /bin/bash
psql -h localhost -U postgres_user_city cities -f /tmp/pais.sql
psql -h localhost -U postgres_user_city cities -f /tmp/estado.sql
psql -h localhost -U postgres_user_city cities -f /tmp/cidade.sql
psql -h localhost -U postgres_user_city cities
CREATE EXTENSION cube;
CREATE EXTENSION earthdistance;
```
* [Postgres Earth distance](https://www.postgresql.org/docs/current/earthdistance.html)
* [earthdistance--1.0--1.1.sql](https://github.com/postgres/postgres/blob/master/contrib/earthdistance/earthdistance--1.0--1.1.sql)
* [OPERATOR <@>](https://github.com/postgres/postgres/blob/master/contrib/earthdistance/earthdistance--1.1.sql)
* [postgrescheatsheet](https://postgrescheatsheet.com/#/tables)
* [datatype-geometric](https://www.postgresql.org/docs/current/datatype-geometric.html)
```shell script
docker exec -it cities-db /bin/bash
psql -U postgres_user_city cities
```
### Query para consultar distancia da terra
Point
```roomsql
select ((select lat_lon from cidade where id = 4929) <@> (select lat_lon from cidade where id=5254)) as distance;
```
Cube
```roomsql
select earth_distance(
ll_to_earth(-21.95840072631836,-47.98820114135742),
ll_to_earth(-22.01740074157715,-47.88600158691406)
) as distance;
```
### Checkstyle
+ https://checkstyle.org/
+ https://checkstyle.org/google_style.html
+ http://google.github.io/styleguide/javaguide.html
```shell script
wget https://raw.githubusercontent.com/checkstyle/checkstyle/master/src/main/resources/google_checks.xml
```
# Autor
Thallyta Macedo Carvalho de Castro
Linkedin: [https://www.linkedin.com/in/thallyta-castro/](https://www.linkedin.com/in/thallyta-castro/)
Medium: [https://medium.com/@thallyta-castro-cv](https://medium.com/@thallyta-castro-cv)
email: [contato@thallytacastro.com.br](mailto:contato@thallytacastro.com.br)