Skip to content
Open

. #2

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
93 commits
Select commit Hold shift + click to select a range
d8f2261
add estacionamento and carro model
CoelhoVitor Nov 24, 2019
c353a46
fix estacionamento and carro model
CoelhoVitor Nov 24, 2019
4778444
add vagaModel
hlazuroz Nov 24, 2019
a778bc2
Merge branch 'master' of https://github.com/CoelhoVitor/park
hlazuroz Nov 24, 2019
ff26dbb
add repository
hlazuroz Nov 24, 2019
97fd0fd
add repository
hlazuroz Nov 24, 2019
57f4b34
fix carro name and add vagas controller
CoelhoVitor Nov 24, 2019
28aea47
add properties
hlazuroz Nov 24, 2019
f45e52d
fix estacionamento model
CoelhoVitor Nov 24, 2019
e218949
fix estacionamento constructor
CoelhoVitor Nov 24, 2019
8f73321
add data sql
hlazuroz Nov 24, 2019
22c3555
add form
hlazuroz Nov 24, 2019
5f27633
att data sql
hlazuroz Nov 24, 2019
ca48a99
final EstacionamentoController
hlazuroz Nov 24, 2019
8f241a5
add vagas controller
CoelhoVitor Nov 24, 2019
b2a65f6
Merge branch 'master' of https://github.com/CoelhoVitor/park
CoelhoVitor Nov 24, 2019
efe0bdb
fix estacionamento controller
CoelhoVitor Nov 24, 2019
6aa45d2
fix estacionamento controller
CoelhoVitor Nov 24, 2019
b9ec32a
fix vagas route
CoelhoVitor Nov 24, 2019
764b855
solve post
hlazuroz Nov 24, 2019
f4cd334
solve post final
hlazuroz Nov 24, 2019
f69e7c4
correct put and delete EstacionamentoController
hlazuroz Nov 24, 2019
1a55b2f
Add files via upload
thauealfredo Nov 24, 2019
1fdae87
Add files via upload
thauealfredo Nov 24, 2019
63d1006
fix get methods ando some models
CoelhoVitor Nov 24, 2019
6dad663
Merge branch 'master' of https://github.com/CoelhoVitor/park
CoelhoVitor Nov 24, 2019
9fa0bb9
add initial security
hlazuroz Nov 24, 2019
ba949b8
criação da pasta template e static
Nov 24, 2019
185d8f5
[ADD] Adicionada a página inicial.
userthiago Nov 24, 2019
c4a986e
criação da pasta template e static
Nov 24, 2019
12590f7
total security
hlazuroz Nov 24, 2019
18c4eba
Merge branch 'master' of https://github.com/CoelhoVitor/park
hlazuroz Nov 24, 2019
ff0aef9
fix veiculo
CoelhoVitor Nov 24, 2019
1145c39
merge datasql
CoelhoVitor Nov 24, 2019
e39f2dd
add permission post and put
hlazuroz Nov 24, 2019
ec63db7
disable security
hlazuroz Nov 24, 2019
629e711
disable security total
hlazuroz Nov 24, 2019
26fa990
[ADD] Layout da página de Gerenciamento.
userthiago Nov 24, 2019
26459d1
link do do index
Nov 24, 2019
1e1d5ea
link do do index
Nov 24, 2019
3289ab0
link do do index
Nov 24, 2019
087268f
add vaga creation
CoelhoVitor Nov 24, 2019
54514df
resolve vaga
hlazuroz Nov 24, 2019
96c7e18
Merge branch 'master' of https://github.com/CoelhoVitor/park
hlazuroz Nov 24, 2019
edb1ac5
some adjustments
CoelhoVitor Nov 24, 2019
487b9b8
Merge branch 'master' of https://github.com/CoelhoVitor/park
CoelhoVitor Nov 24, 2019
4fc9f73
versao final index
Nov 24, 2019
0710c5b
Merge branch 'master' of https://github.com/CoelhoVitor/park
Nov 24, 2019
25297b9
final
hlazuroz Nov 24, 2019
7d6d398
Merge branch 'master' of https://github.com/CoelhoVitor/park
hlazuroz Nov 24, 2019
b6626b9
versao final index
Nov 24, 2019
4c00cf3
fix README
CoelhoVitor Nov 24, 2019
6b5ac1b
merge pom.xml
CoelhoVitor Nov 24, 2019
a673b18
Some initial changes
hlazuroz Dec 24, 2019
bca602d
Add EstacionamentoBO and Fix EstacionamentoController
Dec 24, 2019
65cb71f
Add SwaggerConfigurations
Dec 24, 2019
d84a4c3
Fix VagaController
hlazuroz Dec 26, 2019
0d5aadc
Add CorsConfiguration and Exceptions
hlazuroz Dec 26, 2019
82f0b9d
Add GlobalExceptionHandler
hlazuroz Dec 26, 2019
5578163
Add Throws Exceptions
hlazuroz Dec 26, 2019
9cb659b
Add Security Configurations
hlazuroz Dec 26, 2019
c20e98c
Add VeiculoController
hlazuroz Dec 26, 2019
43f5dba
Add @component e static in mapper
hlazuroz Dec 26, 2019
255c8ff
Add VagaDTOSemEstacionamento
hlazuroz Dec 27, 2019
b097aef
Add CorsConfiguration again and Disabel csrf()
hlazuroz Dec 27, 2019
7616f7f
Fix PUT Estacionamento
hlazuroz Dec 27, 2019
a696421
Fix Delete Estacionamento
hlazuroz Dec 30, 2019
8d20380
Add VagaBO and Fix VagaController
hlazuroz Dec 30, 2019
3cdfe55
Sei la
hlazuroz Dec 30, 2019
1f4815f
Add TipoVaga and Fix a lot of things
hlazuroz Jan 2, 2020
ea30525
Fix data.sql and Add TipoVaga in VagaDTOs
hlazuroz Jan 2, 2020
5f2d987
Add more veicules in data.sql
hlazuroz Jan 2, 2020
9201f08
Add UnmatchedTypeException and Fix VeiculoThings
hlazuroz Jan 2, 2020
c847ba7
Change Relanshionship OneToOne(Vaga-Veiculo) to OneToMany
hlazuroz Jan 2, 2020
78ef0fe
Att
hlazuroz Jan 2, 2020
77d8f07
Remove Att OneToMany
hlazuroz Jan 3, 2020
ec79bcd
03/01/2020 final
hlazuroz Jan 3, 2020
01085b6
Fix VeiculoService DELETE
hlazuroz Jan 6, 2020
18e7c03
Fix Put @Transactional and Fix Repositorys Bad Use
hlazuroz Jan 6, 2020
0980dfc
Add Security
hlazuroz Jan 6, 2020
7b156e6
Add AuthController and Refresh_Token Logic
hlazuroz Jan 7, 2020
526fc4d
Add AuthService
hlazuroz Jan 7, 2020
ef1b713
Add Perfil, DbService, Application-test.properties
hlazuroz Jan 7, 2020
f5ce281
Fix somethings
hlazuroz Jan 8, 2020
1aefd90
Fix VeiculoService Gets Methods
hlazuroz Jan 8, 2020
5664f20
Add More Data in instantiateTestDatabase()
hlazuroz Jan 8, 2020
dacec15
Add Token for swagger and PerfilService
hlazuroz Jan 8, 2020
0c2ea40
Add hasAnyRole('Admin') to remover() on UserService
Jan 9, 2020
a2e6046
Fix DbService
hlazuroz Jan 9, 2020
06e88d1
Merge branch 'master' of https://github.com/CoelhoVitor/park
hlazuroz Jan 9, 2020
1c4b3e9
Change Vaga
hlazuroz Jan 9, 2020
89e6436
chamando views a partir do index
Jan 29, 2020
8de91d0
chamando views a partir do index
Jan 29, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,39 @@ Crie um fork do teste para acompanharmos o seu desenvolvimento através dos seus

## Obrigado!
Agradecemos sua participação. Boa sorte! 😄

## Requisitos do Projeto

### Tecnologies
- JPA, SpringBoot and H2 for Back-end
- HTML5, CSS, Photoshop, Bootstrap and JavaScript for Front-end

### How to run
- Open the project in Eclipse IDE
- Run ParkApplication.java
- The projects runs on `http://localhost:8080/estacionamentos`


### Services
- List establishments: `http://localhost:8080/estacionamentos`
- Create establishments: `http://localhost:8080/estacionamentos`
- _Header: Contet-Type application/json_
- Update establishments: `http://localhost:8080/estacionamentos/{establishment id}`
- _Header: Contet-Type application/json_
- Delete establishments: `http://localhost:8080/estacionamentos/{establishment id}`

- List vacancies: `http://localhost:8080/estacionamentos/{vacancy id}`

- List vehicles: `http://localhost:8080/estacionamentos/{establishment id}/vagas/{vehicle id}`
- Create vehicles: `http://localhost:8080/estacionamentos/{establishment id}/vagas/{vehicles id}`
- _Header: Contet-Type application/json_
- Update vehicles: `http://localhost:8080/estacionamento/{establishment id}/vagas/{vehicle id}`
- _Header: Contet-Type application/json_
- Delete vehicles: `http://localhost:8080/estacionamentos/{establishment id}/vagas/{vehicle id}`


### Team
- Henrico Lazuroz Moura de Almeida
- Thaue Alfredo Ferreira Lima
- Thiago Henrique Santos
- Vitor Coelho da Silva
45 changes: 42 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,18 @@
</properties>

<dependencies>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.10</version>
</dependency>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
Expand All @@ -38,6 +42,41 @@
<artifactId>h2</artifactId>
<scope>runtime</scope>
</dependency>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<scope>runtime</scope>
</dependency>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>

<dependency>
<groupId>io.jsonwebtoken</groupId>
<artifactId>jjwt</artifactId>
<version>0.9.1</version>
</dependency>

<<<<<<< HEAD
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
=======
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
<version>2.9.2</version>
</dependency>

>>>>>>> 1c4b3e9a796b48bc8009019578bab236cfdaedb5
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
<version>2.9.2</version>
</dependency>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
Expand Down
1 change: 0 additions & 1 deletion src/main/java/br/com/hackathonfc/park/ParkApplication.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,4 @@ public class ParkApplication {
public static void main(String[] args) {
SpringApplication.run(ParkApplication.class, args);
}

}
48 changes: 48 additions & 0 deletions src/main/java/br/com/hackathonfc/park/bo/EstacionamentoBO.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
package br.com.hackathonfc.park.bo;

import br.com.hackathonfc.park.dto.EstacionamentoDTO;
import br.com.hackathonfc.park.dto.VagaDTO;
import br.com.hackathonfc.park.dto.VagaDTOSemEstacionamento;
import br.com.hackathonfc.park.exception.CnpjFound;
import br.com.hackathonfc.park.exception.EstacionamentoNotFound;
import br.com.hackathonfc.park.exception.NomeFound;
import br.com.hackathonfc.park.model.Estacionamento;
import br.com.hackathonfc.park.service.EstacionamentoService;
import br.com.hackathonfc.park.service.VagaService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class EstacionamentoBO {

@Autowired
private EstacionamentoService estacionamentoService;

@Autowired
private VagaService vagaService;

public Page<EstacionamentoDTO> listarEstacionamentos(Pageable paginacao){
return estacionamentoService.listar(paginacao);
}

public ResponseEntity<EstacionamentoDTO> cadastrar(EstacionamentoDTO estacionamento) throws NomeFound, CnpjFound {
return estacionamentoService.cadastrar(estacionamento);
}

public ResponseEntity<EstacionamentoDTO> atualizar(Long id, EstacionamentoDTO estacionamentoDTO) throws EstacionamentoNotFound {
return estacionamentoService.atualizar(id, estacionamentoDTO);
}

public ResponseEntity<Estacionamento> deletar(Long id) throws EstacionamentoNotFound {
return estacionamentoService.deletar(id);
}

public EstacionamentoDTO detalharEstacionamento(Long id) throws EstacionamentoNotFound {
return estacionamentoService.detalhar(id);
}
}
50 changes: 50 additions & 0 deletions src/main/java/br/com/hackathonfc/park/bo/VagaBO.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
package br.com.hackathonfc.park.bo;

import br.com.hackathonfc.park.dto.VagaDTO;
import br.com.hackathonfc.park.dto.VagaDTOSemEstacionamento;
import br.com.hackathonfc.park.dto.VeiculoDTO;
import br.com.hackathonfc.park.exception.EstacionamentoNotFound;
import br.com.hackathonfc.park.exception.VagaNotFound;
import br.com.hackathonfc.park.exception.VeiculoNotFound;
import br.com.hackathonfc.park.model.Vaga;
import br.com.hackathonfc.park.model.Veiculo;
import br.com.hackathonfc.park.service.VagaService;
import br.com.hackathonfc.park.service.VeiculoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class VagaBO {

@Autowired
private VagaService vagaService;

@Autowired
private VeiculoService veiculoService;

public List<VeiculoDTO> listarVeiculos(Long id) throws EstacionamentoNotFound {
return veiculoService.listarVeiculosDoEstacionamento(id);
}
public List<VagaDTOSemEstacionamento> listarVagas(Long id) throws EstacionamentoNotFound {
return vagaService.listar(id);
}

public ResponseEntity<VagaDTO> cadastrarVaga(VagaDTO vagaDTO, Long id) {
return vagaService.cadastrar(vagaDTO, id);
}

public ResponseEntity<VagaDTO> atualizarVaga(Long id, VagaDTO vagaDTO) throws VagaNotFound, VeiculoNotFound {
return vagaService.atualizar(id, vagaDTO);
}

public ResponseEntity<VagaDTO> removerVaga(Long id) throws VagaNotFound {
return vagaService.remover(id);
}

public VagaDTO detalharVaga(Long id) throws VagaNotFound {
return vagaService.detalhar(id);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package br.com.hackathonfc.park.config.cors;

import org.springframework.context.annotation.Bean;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@EnableWebMvc
public class CorsConfiguration implements WebMvcConfigurer{

@Bean
public WebMvcConfigurer corsConfigurer() {
return new WebMvcConfigurer() {
public void addCorsMappings(CorsRegistry registry) {
registry.addMapping("/**")
.allowedMethods("GET", "POST", "PUT", "DELETE");
}
};
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package br.com.hackathonfc.park.config.profiles;

import br.com.hackathonfc.park.service.DbService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Profile;

@Configuration
@Profile("test")
public class TestConfig {

@Autowired
private DbService dbService;

@Bean
public boolean instantiateDatebase(){
dbService.instantiateTestDatabase();

return true;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
package br.com.hackathonfc.park.config.security;

import br.com.hackathonfc.park.repository.UserRepository;
import br.com.hackathonfc.park.service.AuthenticationService;
import br.com.hackathonfc.park.service.TokenService;
import br.com.hackathonfc.park.util.AuthenticationFilter;
import br.com.hackathonfc.park.util.AuthorizationFilter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.HttpMethod;
import org.springframework.security.authentication.AuthenticationManager;
import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.builders.WebSecurity;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
import org.springframework.security.config.http.SessionCreationPolicy;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.security.crypto.password.PasswordEncoder;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
@EnableWebSecurity
@EnableGlobalMethodSecurity(prePostEnabled = true)
public class SecurityConfiguration extends WebSecurityConfigurerAdapter {

@Autowired
private AuthenticationService authenticationService;

@Autowired
private TokenService tokenService;

@Autowired
private UserRepository userRepository;

@Autowired
private UserDetailsService userDetailsService;

@Override
@Bean
protected AuthenticationManager authenticationManager() throws Exception {
return super.authenticationManager();
}

@Bean
public BCryptPasswordEncoder bCryptPasswordEncoder() {
return new BCryptPasswordEncoder();
}

@Override
protected void configure(AuthenticationManagerBuilder auth) throws Exception {
auth.userDetailsService(authenticationService).passwordEncoder(new BCryptPasswordEncoder());
}

@Override
protected void configure(HttpSecurity http) throws Exception {
http.authorizeRequests()
.antMatchers(HttpMethod.GET, "/estacionamentos/**").permitAll()
.antMatchers("/h2-console/**").permitAll()
.antMatchers("/login").permitAll()
.antMatchers("/signup").permitAll()
.antMatchers("/auth/**").permitAll()
.antMatchers("/user/**").permitAll()
.anyRequest().authenticated();

http.csrf().disable().sessionManagement().sessionCreationPolicy(SessionCreationPolicy.STATELESS);

http.headers().frameOptions().disable();

http.addFilter(new AuthenticationFilter(authenticationManager(), tokenService));
http.addFilter(new AuthorizationFilter(authenticationManager(), tokenService, userDetailsService));
}

@Override
public void configure(WebSecurity web) throws Exception {
web.ignoring()
.antMatchers("/**.html", "/v2/api-docs", "/webjars/**", "/configuration/**", "/swagger-resources/**");
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package br.com.hackathonfc.park.config.swagger;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ParameterBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.schema.ModelRef;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

import java.util.Arrays;

@Configuration
@EnableSwagger2
public class SwaggerConfigurations {
@Bean
public Docket api() {
return new Docket(DocumentationType.SWAGGER_2)
.select()
.apis(RequestHandlerSelectors.basePackage("br.com.hackathonfc.park"))
.paths(PathSelectors.ant("/**"))
.build()
.globalOperationParameters(Arrays.asList(
new ParameterBuilder()
.name("Authorization")
.description("Header para token JWT")
.modelRef(new ModelRef("string"))
.parameterType("header")
.required(false)
.build()
));
}
}
Loading