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 @@ -11,6 +11,7 @@
import org.springframework.data.repository.query.Param;
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;
Expand Down Expand Up @@ -101,6 +102,11 @@ public boolean disBounce(@PathVariable("id") int id) {
public Pessoa register(@RequestBody Pessoa dados) {
return pessoaRepository.save(dados);
}

@DeleteMapping("/{id}")
public void deletePessoa(@PathVariable("id") int id){
pessoaRepository.deleteById(id);
}

private List<Pessoa> obterListaCompleta() {

Expand Down
2 changes: 1 addition & 1 deletion frontend/main/src/app/users/users.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ <h2 class="text-uppercase">New User</h2>
<td>{{user.document}}</td>
<td>{{user.birth}}</td>
<td>
<button class="btn btn-danger mr-2" (click)="deletar()">Delet</button>
<button class="btn btn-danger mr-2" (click)="deletar(user.id)">Delet</button>
<button class="btn btn-primary mr-2" (click)="alterar()">Edit</button>
</td>
</tr>
Expand Down
9 changes: 7 additions & 2 deletions frontend/main/src/app/users/users.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ name!:string
email!:string
document!:string
birth!:string
id!: number

constructor(public usersService: UsersService, private router: Router, private http: HttpClient) { }

Expand All @@ -27,13 +28,14 @@ birth!:string

for (let i = 0; i < count; i++) {

this.id = response[i].id;
this.name = response[i].nome;
this.email = response[i].email;
this.document = response[i].document;
this.birth = response[i].birth;


this.users.push({name:this.name, email:this.email, document:this.document, birth:this.birth});
this.users.push({id: this.id, name:this.name, email:this.email, document:this.document, birth:this.birth});

}

Expand Down Expand Up @@ -62,8 +64,11 @@ birth!:string
this.users.push({name:this.name, email:this.email, document:this.document, birth:this.birth});
}

deletar(){
deletar(id:number){

console.log(id);

this.http.delete('http://localhost:8080/user/'+id);
}

alterar(){
Expand Down