Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

deleção física de dados #24

Merged
merged 2 commits into from
Feb 27, 2024
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
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ Veja mais informações das lições aprendidas na [Wiki](https://github.com/jal
* [Armanezando dados com Spring Data JPA](https://github.com/jalussa-santos/formacao-spring-boot/issues/11)
* [Consultando dados com Spring Data JPA](https://github.com/jalussa-santos/formacao-spring-boot/issues/15)
* [Atualizando dados com Spring Data JPA](https://github.com/jalussa-santos/formacao-spring-boot/issues/21)
* [Deletando dados com Spring Data JPA](https://github.com/jalussa-santos/formacao-spring-boot/issues/23)

>### Tecnologias:

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@
import org.springframework.data.domain.Pageable;
import org.springframework.data.web.PageableDefault;
import org.springframework.transaction.annotation.Transactional;
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;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
Expand All @@ -37,12 +39,19 @@ public Page<DadosListagemMedicoDto> listar(@PageableDefault(size = 10, sort = {"
.map(DadosListagemMedicoDto::new);
}

@PutMapping
@PutMapping
@Transactional
public void atualizar(@RequestBody @Valid DadosAtualizacaoMedicoDto dados) {

var medico = repository.getReferenceById(dados.id());

medico.atualizarInformacoes(dados);
}

@DeleteMapping("/{id}")
@Transactional
public void excluir(@PathVariable Long id) {

repository.deleteById(id);
}
}