Skip to content
This repository has been archived by the owner on Nov 8, 2024. It is now read-only.

Commit

Permalink
feat: implementando paginação e alterando rota no ResponseEntity do p…
Browse files Browse the repository at this point in the history
…ostMapping
  • Loading branch information
JuannCarloss committed Mar 20, 2024
1 parent 9d4784a commit 632e932
Showing 1 changed file with 8 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
import com.senac.gestaocurso.models.Avaliacao;
import com.senac.gestaocurso.service.AvaliacaoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

Expand All @@ -20,13 +23,15 @@ public class FuncionarioController {
@PostMapping()
public ResponseEntity salvar(@RequestBody Avaliacao avaliacoes) {
Avaliacao save = avaliacaoService.salvar(avaliacoes);
return ResponseEntity.created(URI.create("/avaliacoes/salvar" + avaliacoes.getId())).body(save);
return ResponseEntity.created(URI.create("/api/avaliacao" + avaliacoes.getId())).body(save);
}


@GetMapping
public ResponseEntity findAll() {
List<Avaliacao> avaliacoes = avaliacaoService.buscaTodos();
public ResponseEntity findAll(@RequestParam(defaultValue = "0") int page,
@RequestParam(defaultValue = "0") int size) {
Pageable pageable = PageRequest.of(page, size);
Page<Avaliacao> avaliacoes = avaliacaoService.buscaTodos(pageable);
return ResponseEntity.ok(avaliacoes);
}

Expand Down

0 comments on commit 632e932

Please sign in to comment.