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 @@ -19,6 +19,7 @@
import com.fasterxml.jackson.databind.ObjectMapper;

import br.com.entra21.teamroxo.TMSProject.TmsProjectApplication;
import br.com.entra21.teamroxo.TMSProject.interfaces.LoginRepository;
import br.com.entra21.teamroxo.TMSProject.interfaces.PessoaRepository;
import br.com.entra21.teamroxo.TMSProject.template.ItemNivel3;
import br.com.entra21.teamroxo.TMSProject.template.Login;
Expand All @@ -34,11 +35,14 @@ public class LoginController {
@Autowired
private PessoaRepository pessoaRepository;

@Autowired
private LoginRepository loginRepository;

@PostMapping()
@ResponseStatus(code = HttpStatus.OK)
public @ResponseBody List<Login> login(@RequestBody Login credentials){

List<Login> response = new ArrayList<Login>(pessoaRepository.findAll()).stream()
List<Login> response = new ArrayList<Login>(loginRepository.findAll()).stream()
.filter(login -> (login.getUser().equals(credentials.getUser())) &&
login.getSenha().equals(credentials.getSenha()))
.toList();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,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.PessoaRepository;
Expand Down Expand Up @@ -60,6 +62,8 @@ private void setMaturidadeNivel3(Pessoa pessoa) {
headers.add("Accept : application/json");
headers.add("Content-type : application/json");
ObjectMapper mapper = new ObjectMapper();
mapper.registerModule(new JavaTimeModule());
mapper.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false);
mapper.setSerializationInclusion(Include.NON_NULL);

try {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package br.com.entra21.teamroxo.TMSProject.controllers;

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.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.ResponseStatus;
import org.springframework.web.bind.annotation.RestController;

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

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

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

@Autowired
private PessoaRepository pessoaRepository;

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

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package br.com.entra21.teamroxo.TMSProject.interfaces;

import org.springframework.data.jpa.repository.JpaRepository;

import br.com.entra21.teamroxo.TMSProject.template.Login;

public interface LoginRepository extends JpaRepository<Login, Integer> {

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

import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;

@Entity
@Table(name = "login")
public class Login extends MaturidadeNivel3Richardson {

@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Integer id;
private String user;
private String senha;
private boolean admin;
Expand All @@ -11,13 +22,22 @@ public Login() {
super();
}

public Login(String user, String senha, boolean admin, boolean enterprise) {
public Login(Integer id, String user, String senha, boolean admin, boolean enterprise) {
super();
this.id = id;
this.user = user;
this.senha = senha;
this.admin = admin;
this.enterprise = enterprise;
}

public Integer getId() {
return id;
}

public void setId(Integer id) {
this.id = id;
}

public String getUser() {
return user;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,26 @@
import javax.persistence.Id;
import javax.persistence.Table;

import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;

@Entity
@Table(name = "pessoa")
public class Pessoa extends Login {
public class Pessoa extends MaturidadeNivel3Richardson {

@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Integer id;
private String nome;
private String email;
private LocalDate birth;
private long document;
private String document;

public Pessoa() {
super();
}

public Pessoa(Integer id, String nome, String email, LocalDate birth, long document) {
public Pessoa(Integer id, String nome, String email, LocalDate birth, String document) {
super();
this.id = id;
this.nome = nome;
Expand Down Expand Up @@ -65,11 +68,11 @@ public void setBirth(LocalDate birth) {
this.birth = birth;
}

public long getDocument() {
public String getDocument() {
return document;
}

public void setDocument(long document) {
public void setDocument(String document) {
this.document = document;
}

Expand Down
7 changes: 3 additions & 4 deletions frontend/main/src/app/ship-qt/ship-qt.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,7 @@ export class ShipQtComponent implements OnInit {
distanceKm!:string

constructor(
public quoteService: QuoteService,
private activatedRoute: ActivatedRoute
public quoteService: QuoteService, private activatedRoute: ActivatedRoute
) { }

ngOnInit(): void {
Expand All @@ -54,7 +53,7 @@ export class ShipQtComponent implements OnInit {
this.startAdress = response.routes[0].legs[0].start_address;
this.endAdress = response.routes[0].legs[0].end_address;



this.precoFrete = (parseFloat(this.distanceKm)/1000) * 0.081;
console.log(this.precoFrete);
Expand All @@ -66,7 +65,7 @@ export class ShipQtComponent implements OnInit {
} else {
alert('DIGITE TODOS OS DADOS!')
}

}

}