Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
Expand All @@ -17,6 +18,8 @@
import com.fasterxml.jackson.annotation.JsonInclude.Include;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.SerializationFeature;
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;

import br.com.entra21.teamroxo.TMSProject.TmsProjectApplication;
import br.com.entra21.teamroxo.TMSProject.interfaces.LoginRepository;
Expand All @@ -38,6 +41,11 @@ public class LoginController {
@Autowired
private LoginRepository loginRepository;

@GetMapping
public List<Login> listAll() {
return loginRepository.findAll();
}

@PostMapping()
@ResponseStatus(code = HttpStatus.OK)
public @ResponseBody List<Login> login(@RequestBody Login credentials){
Expand All @@ -53,12 +61,6 @@ public class LoginController {
return response;

}

@PostMapping("/register")
@ResponseStatus(code = HttpStatus.CREATED)
public @ResponseBody Pessoa register(@RequestBody Pessoa credentials){
return pessoaRepository.save(credentials);
}

private void setMaturidadeLvl3(Login pessoa) {

Expand All @@ -70,7 +72,8 @@ private void setMaturidadeLvl3(Login pessoa) {
));

ObjectMapper mapper = new ObjectMapper();

mapper.registerModule(new JavaTimeModule());
mapper.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false);
mapper.setSerializationInclusion(Include.NON_NULL);

pessoa.setLinks(null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseStatus;
Expand Down Expand Up @@ -47,6 +49,14 @@ public Optional<Pessoa> list(@PathVariable int id){
return pessoaRepository.findById(id);

}

@PostMapping()
@ResponseStatus(code = HttpStatus.CREATED)
public Pessoa register(@RequestBody Pessoa dados) {

return pessoaRepository.save(dados);

}

private List<Pessoa> obterListaCompleta() {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package br.com.entra21.teamroxo.TMSProject.controllers;

import java.util.Optional;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.CrossOrigin;
Expand All @@ -10,23 +12,37 @@
import org.springframework.web.bind.annotation.ResponseStatus;
import org.springframework.web.bind.annotation.RestController;

import br.com.entra21.teamroxo.TMSProject.interfaces.LoginRepository;
import br.com.entra21.teamroxo.TMSProject.interfaces.PessoaRepository;
import br.com.entra21.teamroxo.TMSProject.template.Login;
import br.com.entra21.teamroxo.TMSProject.template.Pessoa;
import br.com.entra21.teamroxo.TMSProject.template.Register;

@RestController
@CrossOrigin(origins = "*")
@RequestMapping("/register")
public class RegisterController {

private final String PATH = "http://localhost:8080/register";

@Autowired
private PessoaRepository pessoaRepository;

@Autowired
private LoginRepository loginRepository;

@PostMapping()
@ResponseStatus(code = HttpStatus.CREATED)
public @ResponseBody Pessoa register(@RequestBody Pessoa credentials){
return pessoaRepository.save(credentials);
public @ResponseBody Login register(@RequestBody Register credentials){

Pessoa pessoa = new Pessoa();
Login login = new Login();

pessoa.setNome(credentials.getNome());
pessoa.setEmail(credentials.getEmail());
login.setPessoa_id(pessoaRepository.save(pessoa).getId());
login.setUser(credentials.getUser());
login.setSenha(credentials.getSenha());
return loginRepository.save(login);

}

}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package br.com.entra21.teamroxo.TMSProject.template;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
Expand All @@ -13,6 +14,7 @@ public class Login extends MaturidadeNivel3Richardson {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Integer id;
@Column(unique = true)
private String user;
private String senha;
private boolean admin;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import java.time.LocalDate;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
Expand All @@ -19,8 +20,10 @@ public class Pessoa extends MaturidadeNivel3Richardson {
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Integer id;
private String nome;
@Column(unique = true)
private String email;
private LocalDate birth;
@Column(unique = true)
private String document;

public Pessoa() {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
package br.com.entra21.teamroxo.TMSProject.template;

public class Register {

private String nome;
private String user;
private String email;
private String senha;

public Register() {
super();
}

public Register(String nome, String user, String email, String senha) {
super();
this.nome = nome;
this.user = user;
this.email = email;
this.senha = senha;
}

public String getNome() {
return nome;
}

public void setNome(String nome) {
this.nome = nome;
}

public String getUser() {
return user;
}

public void setUser(String user) {
this.user = user;
}

public String getEmail() {
return email;
}

public void setEmail(String email) {
this.email = email;
}

public String getSenha() {
return senha;
}

public void setSenha(String senha) {
this.senha = senha;
}

}
4 changes: 2 additions & 2 deletions backend/TMSProject/src/main/resources/application.properties
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
spring.datasource.url=jdbc:mysql://localhost:3306/mydatabase
spring.datasource.url=jdbc:mysql://34.151.219.66/mydatabase

spring.datasource.username=root

spring.datasource.password=Mr_kak4k0ur1
spring.datasource.password=Tms@2022


spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
Expand Down
11 changes: 10 additions & 1 deletion frontend/main/src/app/login/login.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,15 +50,24 @@ export class LoginComponent implements OnInit {
}

register(){
if(this.nameReg != null && this.emailReg != null && this.passwordReg != null){
if(this.nameReg != null && this.emailReg != null && this.passwordReg != null && this.userReg != null){
this.loginService.registering(this.nameReg, this.userReg , this.emailReg, this.passwordReg)
.pipe(
catchError((error)=>{
return of(['Error!', error])
})
)
.subscribe((response:any)=>{
console.log(response);

console.log('Successful Login!');
if(response == ""){
this.loginService.progress = false;
alert("ERRO!")
}else{
this.loginService.succeed = true
this.gotoHome()
}
});
}else{
alert('DIGITE TODOS OS CAMPOS OBRIGATÓRIOS!')
Expand Down
12 changes: 6 additions & 6 deletions frontend/main/src/app/loginservice.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,15 @@ export class LoginserviceService implements CanActivate {
return this.http.post(this.TMSLoginAPI +'/login', build)
}

registering(name:string ,user: string, password: string, email: string) {
registering(name:string ,user: string, email: string, password: string) {

this.progress = true

let build:any = {
'name':name,
'nome':name,
'user':user,
'password':password,
'email':email
'email':email,
'senha':password
}

this.http.post(this.TMSLoginAPI+'/register', build)
Expand All @@ -62,11 +62,11 @@ export class LoginserviceService implements CanActivate {
return error
})
)
.subscribe((response)=>{
.subscribe((response:any)=>{
return response
})

return build
return this.http.get(this.TMSLoginAPI +'/login', build)

}

Expand Down
83 changes: 41 additions & 42 deletions frontend/main/src/app/ship-qt/ship-qt.component.html
Original file line number Diff line number Diff line change
@@ -1,49 +1,48 @@
<table class="table table-bordered">
<thead>
<th>CEP de origem</th>
<th>CEP de destino</th>
<th>Comprimento (cm)</th>
<th>Largura (cm)</th>
<th>Altura (cm)</th>
<th>Peso (kg)</th>
</thead>
<tbody>
<tr>
<td><input type="number" [(ngModel)]="cepOrigem"></td>
<td><input type="number" [(ngModel)]="cepDestino"></td>
<td><input type="number" [(ngModel)]="comprimento"></td>
<td><input type="number" [(ngModel)]="largura"></td>
<td><input type="number" [(ngModel)]="altura"></td>
<td><input type="number" [(ngModel)]="peso"></td>
</tr>
</tbody>
<thead>
<th>CEP de origem</th>
<th>CEP de destino</th>
<th>Comprimento (cm)</th>
<th>Largura (cm)</th>
<th>Altura (cm)</th>
<th>Peso (kg)</th>
</thead>
<tbody>
<tr>
<td><input type="number" [(ngModel)]="cepOrigem"></td>
<td><input type="number" [(ngModel)]="cepDestino"></td>
<td><input type="number" [(ngModel)]="comprimento"></td>
<td><input type="number" [(ngModel)]="largura"></td>
<td><input type="number" [(ngModel)]="altura"></td>
<td><input type="number" [(ngModel)]="peso"></td>
</tr>
</tbody>
</table>

<button class="btn btn-success" (click)="quote()">Quote</button>
<br>
<hr>
<table class="table table-bordered">
<thead>
<th>ID</th>
<th>Preço do frete</th>
<th>Prazo</th>
<th>Origem</th>
<th>Destino</th>
<th>Comprimento (cm)</th>
<th>Largura (cm)</th>
<th>Altura (cm)</th>
<th>Peso (kg)</th>
</thead>
<tbody>
<tr *ngFor="let quote of quotes;let i = index;">
<td>{{i}}</td>
<td>R${{quote.precoFrete}}</td>
<td>{{quote.durationTime}} dias úteis</td>
<td>{{quote.startAdress}}</td>
<td>{{quote.endAdress}}</td>
<td>{{quote.comprimento}}</td>
<td>{{quote.largura}}</td>
<td>{{quote.altura}}</td>
<td>{{quote.peso}}</td>
</tr>
</tbody>
<thead>
<th>ID</th>
<th>Preço do frete</th>
<th>Prazo</th>
<th>Origem</th>
<th>Destino</th>
<th>Transportadora</th>
<th>Peso cubado</th>

</thead>
<tbody>
<tr *ngFor="let quote of quotes;let i = index;">
<td>{{i}}</td>
<td>R${{quote.precoFrete}}</td>
<td>{{quote.tempo}} dias úteis</td>
<td>{{quote.start_adress}}</td>
<td>{{quote.end_address}}</td>
<td>{{quote.carrier}}</td>
<td>{{quote.cubagem}} kg</td>

</tr>
</tbody>
</table>
Loading