From ed6690309d992485e32850d3c96cb772dcf2abb5 Mon Sep 17 00:00:00 2001 From: Mateus Felipe Date: Sun, 9 Oct 2022 09:30:33 -0300 Subject: [PATCH] Delet Carriers --- .../controllers/CarriersControllers.java | 6 ++++++ .../controllers/PessoaController.java | 2 ++ .../TMSProject/controllers/QuoteController.java | 2 ++ .../src/app/carriers/carriers.component.html | 12 ++++++------ .../main/src/app/carriers/carriers.component.ts | 17 ++++++++++++++--- .../main/src/app/users/users.component.html | 2 +- 6 files changed, 31 insertions(+), 10 deletions(-) diff --git a/backend/TMSProject/src/main/java/br/com/entra21/teamroxo/TMSProject/controllers/CarriersControllers.java b/backend/TMSProject/src/main/java/br/com/entra21/teamroxo/TMSProject/controllers/CarriersControllers.java index 0fe9e65..cbf2618 100644 --- a/backend/TMSProject/src/main/java/br/com/entra21/teamroxo/TMSProject/controllers/CarriersControllers.java +++ b/backend/TMSProject/src/main/java/br/com/entra21/teamroxo/TMSProject/controllers/CarriersControllers.java @@ -5,6 +5,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.DeleteMapping; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PostMapping; @@ -42,5 +43,10 @@ public Carriers register(@RequestBody Carriers dados) { return carriersRepository.save(dados); } + + @DeleteMapping("/{id}") + public void deleteCarrier(@PathVariable("id") int id){ + carriersRepository.deleteById(id); + } } diff --git a/backend/TMSProject/src/main/java/br/com/entra21/teamroxo/TMSProject/controllers/PessoaController.java b/backend/TMSProject/src/main/java/br/com/entra21/teamroxo/TMSProject/controllers/PessoaController.java index 6ffcfc6..364abb4 100644 --- a/backend/TMSProject/src/main/java/br/com/entra21/teamroxo/TMSProject/controllers/PessoaController.java +++ b/backend/TMSProject/src/main/java/br/com/entra21/teamroxo/TMSProject/controllers/PessoaController.java @@ -146,5 +146,7 @@ private void setMaturidadeNivel3(Pessoa pessoa) { } } + + } diff --git a/backend/TMSProject/src/main/java/br/com/entra21/teamroxo/TMSProject/controllers/QuoteController.java b/backend/TMSProject/src/main/java/br/com/entra21/teamroxo/TMSProject/controllers/QuoteController.java index 8916be7..64d4f0d 100644 --- a/backend/TMSProject/src/main/java/br/com/entra21/teamroxo/TMSProject/controllers/QuoteController.java +++ b/backend/TMSProject/src/main/java/br/com/entra21/teamroxo/TMSProject/controllers/QuoteController.java @@ -83,4 +83,6 @@ public int goingPackages() { } + + } diff --git a/frontend/main/src/app/carriers/carriers.component.html b/frontend/main/src/app/carriers/carriers.component.html index 41f6830..ae1e54c 100644 --- a/frontend/main/src/app/carriers/carriers.component.html +++ b/frontend/main/src/app/carriers/carriers.component.html @@ -95,12 +95,12 @@

New Carrier

- - - + + + - + @@ -113,8 +113,8 @@

New Carrier

diff --git a/frontend/main/src/app/carriers/carriers.component.ts b/frontend/main/src/app/carriers/carriers.component.ts index 9f54a61..32adf7b 100644 --- a/frontend/main/src/app/carriers/carriers.component.ts +++ b/frontend/main/src/app/carriers/carriers.component.ts @@ -16,6 +16,7 @@ export class CarriersComponent implements OnInit { email!: string razao!: string taxa!: string + id!: number constructor(public carrierService: CarrierService, public quoteService: QuoteService, private router: Router, private http: HttpClient) { } @@ -37,12 +38,14 @@ export class CarriersComponent implements OnInit { for (let i = 0; i < count; i++) { + + this.id = response[i].id; this.razao = response[i].razao; this.taxa = response[i].taxa; this.email = response[i].email; this.cnpj = response[i].cnpj; - this.carriers.push({ razao: this.razao, taxa: this.taxa, email: this.email, cnpj: this.cnpj}); + this.carriers.push({id: this.id, razao: this.razao, taxa: this.taxa, email: this.email, cnpj: this.cnpj}); } @@ -57,7 +60,6 @@ export class CarriersComponent implements OnInit { adicionar(razao: string, taxa: string, email: string, cnpj: string) { - let build ={ "razao":razao, "taxa":taxa, @@ -75,8 +77,15 @@ export class CarriersComponent implements OnInit { // this.carriers.push({razao:this.razao, taxa:this.taxa, email:this.email, cnpj:this.cnpj}); } - deletar(){ + deletar(id:number){ + + console.log(id); + this.http.delete('http://localhost:8080/carriers/'+id).subscribe(); + + setTimeout(() => { + this.ngOnInit(); + }, 500); } @@ -107,4 +116,6 @@ export class CarriersComponent implements OnInit { } + + } diff --git a/frontend/main/src/app/users/users.component.html b/frontend/main/src/app/users/users.component.html index 531d363..f383cd6 100644 --- a/frontend/main/src/app/users/users.component.html +++ b/frontend/main/src/app/users/users.component.html @@ -92,7 +92,7 @@

New User


IDRazão socialTaxaItemCarrier nameTax of transport E-mail CnpjAçãoAction
{{carrier.email}} {{carrier.cnpj}} - - + +
- +
IDItem Name E-mail CPF