From 5cd3128247454f6bd052f2a4adb3ef23c8d53e4c Mon Sep 17 00:00:00 2001 From: JuannCarloss Date: Tue, 19 Mar 2024 23:29:37 -0300 Subject: [PATCH] =?UTF-8?q?feat:=20implementando=20fun=C3=A7=C3=A3o=20de?= =?UTF-8?q?=20pagina=C3=A7=C3=A3o?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../resource/CertificacoesController.java | 11 ++++++++--- .../gestaocurso/resource/CursoController.java | 11 ++++++++--- .../resource/DadosBancariosController.java | 11 ++++++++--- .../resource/DependentesController.java | 11 ++++++++--- .../resource/ExpAnteriorController.java | 11 ++++++++--- .../gestaocurso/resource/FiliacaoController.java | 11 ++++++++--- .../gestaocurso/resource/FrequenciaController.java | 11 ++++++++--- .../resource/FuncionarioController.java | 9 +++++++-- .../gestaocurso/resource/InscricaoController.java | 11 ++++++++--- .../gestaocurso/resource/MateriaController.java | 11 ++++++++--- .../gestaocurso/resource/TurmaController.java | 11 ++++++++--- .../gestaocurso/service/CertificacoesService.java | 10 +++++++--- .../senac/gestaocurso/service/CursoService.java | 10 +++++++--- .../gestaocurso/service/DadosBancariosService.java | 10 +++++++--- .../gestaocurso/service/DependentesService.java | 14 ++++++++++---- .../gestaocurso/service/ExpAnteriorService.java | 10 +++++++--- .../senac/gestaocurso/service/FiliacaoService.java | 10 ++++++++-- .../gestaocurso/service/FrequenciaService.java | 10 ++++++++-- .../gestaocurso/service/FuncionarioService.java | 10 +++++++--- .../gestaocurso/service/InscricaoService.java | 10 ++++++++-- .../senac/gestaocurso/service/MateriaService.java | 10 +++++++--- .../senac/gestaocurso/service/TurmaService.java | 10 +++++++--- 22 files changed, 170 insertions(+), 63 deletions(-) diff --git a/backend/src/main/java/com/senac/gestaocurso/resource/CertificacoesController.java b/backend/src/main/java/com/senac/gestaocurso/resource/CertificacoesController.java index f9137eb..e8b44ea 100644 --- a/backend/src/main/java/com/senac/gestaocurso/resource/CertificacoesController.java +++ b/backend/src/main/java/com/senac/gestaocurso/resource/CertificacoesController.java @@ -3,6 +3,9 @@ import com.senac.gestaocurso.models.Certificacoes; import com.senac.gestaocurso.service.CertificacoesService; 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.*; import java.net.URI; @@ -18,12 +21,14 @@ public class CertificacoesController { @PostMapping() public ResponseEntity salvar(@RequestBody Certificacoes certificacoes){ Certificacoes save = certificacoesService.salvar(certificacoes); - return ResponseEntity.created(URI.create("/funcionario/salvar" + certificacoes.getId())).body(save); + return ResponseEntity.created(URI.create("/api/certificacoes" + certificacoes.getId())).body(save); } @GetMapping - public ResponseEntity findAll() { - List certificacoes = certificacoesService.buscaTodos(); + public ResponseEntity findAll(@RequestParam(defaultValue = "0") int page, + @RequestParam(defaultValue = "0") int size) { + Pageable pageable = PageRequest.of(page, size); + Page certificacoes = certificacoesService.buscaTodos(pageable); return ResponseEntity.ok(certificacoes); } @GetMapping("/{id}") diff --git a/backend/src/main/java/com/senac/gestaocurso/resource/CursoController.java b/backend/src/main/java/com/senac/gestaocurso/resource/CursoController.java index 44511d7..6880283 100644 --- a/backend/src/main/java/com/senac/gestaocurso/resource/CursoController.java +++ b/backend/src/main/java/com/senac/gestaocurso/resource/CursoController.java @@ -4,6 +4,9 @@ import com.senac.gestaocurso.models.Curso; import com.senac.gestaocurso.service.CursoService; 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.*; @@ -19,12 +22,14 @@ public class CursoController { @PostMapping() public ResponseEntity salvar(@RequestBody Curso curso){ Curso save = cursoService.salvar(curso); - return ResponseEntity.created(URI.create("/cursos/salvar" + curso.getId())).body(save); + return ResponseEntity.created(URI.create("/api/cursos" + curso.getId())).body(save); } @GetMapping - public ResponseEntity findAll() { - List cursos = cursoService.buscaTodos(); + public ResponseEntity findAll(@RequestParam(defaultValue = "0") int page, + @RequestParam(defaultValue = "0") int size) { + Pageable pageable = PageRequest.of(page, size); + Page cursos = cursoService.buscaTodos(pageable); return ResponseEntity.ok(cursos); } @GetMapping("/{id}") diff --git a/backend/src/main/java/com/senac/gestaocurso/resource/DadosBancariosController.java b/backend/src/main/java/com/senac/gestaocurso/resource/DadosBancariosController.java index 6cfb932..c0895bb 100644 --- a/backend/src/main/java/com/senac/gestaocurso/resource/DadosBancariosController.java +++ b/backend/src/main/java/com/senac/gestaocurso/resource/DadosBancariosController.java @@ -4,6 +4,9 @@ import com.senac.gestaocurso.models.DadosBancarios; import com.senac.gestaocurso.service.DadosBancariosService; 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.*; @@ -18,12 +21,14 @@ public class DadosBancariosController { @PostMapping() public ResponseEntity salvar(@RequestBody DadosBancarios dadosBancarios){ DadosBancarios save = dadosBancariosService.salvar(dadosBancarios); - return ResponseEntity.created(URI.create("/dadosbancarios/salvar" + dadosBancarios.getId())).body(save); + return ResponseEntity.created(URI.create("/api/dadosbancarios" + dadosBancarios.getId())).body(save); } @GetMapping - public ResponseEntity findAll() { - List dadosBancarios = dadosBancariosService.buscaTodos(); + public ResponseEntity findAll(@RequestParam(defaultValue = "0") int page, + @RequestParam(defaultValue = "0") int size) { + Pageable pageable = PageRequest.of(page, size); + Page dadosBancarios = dadosBancariosService.buscaTodos(pageable); return ResponseEntity.ok(dadosBancarios); } @GetMapping("/{id}") diff --git a/backend/src/main/java/com/senac/gestaocurso/resource/DependentesController.java b/backend/src/main/java/com/senac/gestaocurso/resource/DependentesController.java index 596cdec..c35a0bd 100644 --- a/backend/src/main/java/com/senac/gestaocurso/resource/DependentesController.java +++ b/backend/src/main/java/com/senac/gestaocurso/resource/DependentesController.java @@ -4,6 +4,9 @@ import com.senac.gestaocurso.models.Dependentes; import com.senac.gestaocurso.service.DependentesService; 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.*; import java.net.URI; @@ -18,12 +21,14 @@ public class DependentesController { @PostMapping() public ResponseEntity salvar(@RequestBody Dependentes dependentes){ Dependentes save = dependentesService.salvar(dependentes); - return ResponseEntity.created(URI.create("/dependentes/salvar" + dependentes.getId())).body(save); + return ResponseEntity.created(URI.create("/api/dependentes" + dependentes.getId())).body(save); } @GetMapping - public ResponseEntity findAll() { - List dependentes = dependentesService.buscaTodos(); + public ResponseEntity findAll(@RequestParam(defaultValue = "0") int page, + @RequestParam(defaultValue = "0") int size) { + Pageable pageable = PageRequest.of(page, size); + Page dependentes = dependentesService.buscaTodos(pageable); return ResponseEntity.ok(dependentes); } @GetMapping("/{id}") diff --git a/backend/src/main/java/com/senac/gestaocurso/resource/ExpAnteriorController.java b/backend/src/main/java/com/senac/gestaocurso/resource/ExpAnteriorController.java index 65809f3..f86417d 100644 --- a/backend/src/main/java/com/senac/gestaocurso/resource/ExpAnteriorController.java +++ b/backend/src/main/java/com/senac/gestaocurso/resource/ExpAnteriorController.java @@ -4,6 +4,9 @@ import com.senac.gestaocurso.models.ExpAnterior; import com.senac.gestaocurso.service.ExpAnteriorService; 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.*; import java.net.URI; @@ -19,12 +22,14 @@ public class ExpAnteriorController { @PostMapping() public ResponseEntity salvar(@RequestBody ExpAnterior expAnterior) { ExpAnterior save = expAnteriorService.salvar(expAnterior); - return ResponseEntity.created(URI.create("/funcionario/salvar" + expAnterior.getId())).body(save); + return ResponseEntity.created(URI.create("/api/experiencias" + expAnterior.getId())).body(save); } @GetMapping - public ResponseEntity findAll() { - List expAnteriors = expAnteriorService.buscaTodos(); + public ResponseEntity findAll(@RequestParam(defaultValue = "0") int page, + @RequestParam(defaultValue = "0") int size) { + Pageable pageable = PageRequest.of(page, size); + Page expAnteriors = expAnteriorService.buscaTodos(pageable); return ResponseEntity.ok(expAnteriors); } @GetMapping("/{id}") diff --git a/backend/src/main/java/com/senac/gestaocurso/resource/FiliacaoController.java b/backend/src/main/java/com/senac/gestaocurso/resource/FiliacaoController.java index b4d6e7f..74aa1fd 100644 --- a/backend/src/main/java/com/senac/gestaocurso/resource/FiliacaoController.java +++ b/backend/src/main/java/com/senac/gestaocurso/resource/FiliacaoController.java @@ -3,6 +3,9 @@ import com.senac.gestaocurso.models.Filiacao; import com.senac.gestaocurso.service.FiliacaoService; 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.*; @@ -17,12 +20,14 @@ public class FiliacaoController { @PostMapping() public ResponseEntity salvar(@RequestBody Filiacao filiacao){ Filiacao save = filiacaoService.salvar(filiacao); - return ResponseEntity.created(URI.create("/filiacao/salvar" + filiacao.getId())).body(save); + return ResponseEntity.created(URI.create("/api/filiacao" + filiacao.getId())).body(save); } @GetMapping - public ResponseEntity findAll() { - List filiacao = filiacaoService.buscaTodos(); + public ResponseEntity findAll(@RequestParam(defaultValue = "0") int page, + @RequestParam(defaultValue = "0") int size) { + Pageable pageable = PageRequest.of(page, size); + Page filiacao = filiacaoService.buscaTodos(pageable); return ResponseEntity.ok(filiacao); } @GetMapping("/{id}") diff --git a/backend/src/main/java/com/senac/gestaocurso/resource/FrequenciaController.java b/backend/src/main/java/com/senac/gestaocurso/resource/FrequenciaController.java index 71b2399..a1aca85 100644 --- a/backend/src/main/java/com/senac/gestaocurso/resource/FrequenciaController.java +++ b/backend/src/main/java/com/senac/gestaocurso/resource/FrequenciaController.java @@ -3,6 +3,9 @@ import com.senac.gestaocurso.models.Frequencia; import com.senac.gestaocurso.service.FrequenciaService; 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.*; @@ -17,11 +20,13 @@ public class FrequenciaController { @PostMapping() public ResponseEntity salvar(@RequestBody Frequencia frequencia){ Frequencia save = frequenciaService.salvar(frequencia); - return ResponseEntity.created(URI.create("/frequencia/salvar" + frequencia.getId())).body(save); + return ResponseEntity.created(URI.create("/api/frequencia" + frequencia.getId())).body(save); } @GetMapping - public ResponseEntity findAll() { - List frequencias = frequenciaService.buscaTodos(); + public ResponseEntity findAll(@RequestParam(defaultValue = "0") int page, + @RequestParam(defaultValue = "0") int size) { + Pageable pageable = PageRequest.of(page, size); + Page frequencias = frequenciaService.buscaTodos(pageable); return ResponseEntity.ok(frequencias); } @GetMapping("/{id}") diff --git a/backend/src/main/java/com/senac/gestaocurso/resource/FuncionarioController.java b/backend/src/main/java/com/senac/gestaocurso/resource/FuncionarioController.java index 2ceb7fa..ad4d3d3 100644 --- a/backend/src/main/java/com/senac/gestaocurso/resource/FuncionarioController.java +++ b/backend/src/main/java/com/senac/gestaocurso/resource/FuncionarioController.java @@ -4,6 +4,9 @@ import com.senac.gestaocurso.models.Funcionario; import com.senac.gestaocurso.service.FuncionarioService; 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.*; @@ -24,8 +27,10 @@ public ResponseEntity salvar(@RequestBody Funcionario funcionario){ @GetMapping - public ResponseEntity findAll() { - List funcionarios = funcionarioService.buscaTodos(); + public ResponseEntity findAll(@RequestParam(defaultValue = "0") int page, + @RequestParam(defaultValue = "0") int size) { + Pageable pageable = PageRequest.of(page, size); + Page funcionarios = funcionarioService.buscaTodos(pageable); return ResponseEntity.ok(funcionarios); } @GetMapping("/{id}") diff --git a/backend/src/main/java/com/senac/gestaocurso/resource/InscricaoController.java b/backend/src/main/java/com/senac/gestaocurso/resource/InscricaoController.java index db9951f..7f56290 100644 --- a/backend/src/main/java/com/senac/gestaocurso/resource/InscricaoController.java +++ b/backend/src/main/java/com/senac/gestaocurso/resource/InscricaoController.java @@ -5,6 +5,9 @@ import com.senac.gestaocurso.service.FuncionarioService; import com.senac.gestaocurso.service.InscricaoService; 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.*; @@ -19,12 +22,14 @@ public class InscricaoController { @PostMapping() public ResponseEntity salvar(@RequestBody Inscricao inscricao){ Inscricao save = inscricaoService.salvar(inscricao); - return ResponseEntity.created(URI.create("/inscricao/salvar" + inscricao.getId())).body(save); + return ResponseEntity.created(URI.create("/api/inscricao" + inscricao.getId())).body(save); } @GetMapping - public ResponseEntity findAll() { - List inscricao = inscricaoService.buscaTodos(); + public ResponseEntity findAll(@RequestParam(defaultValue = "0") int page, + @RequestParam(defaultValue = "0") int size) { + Pageable pageable = PageRequest.of(page, size); + Page inscricao = inscricaoService.buscaTodos(pageable); return ResponseEntity.ok(inscricao); } @GetMapping("/{id}") diff --git a/backend/src/main/java/com/senac/gestaocurso/resource/MateriaController.java b/backend/src/main/java/com/senac/gestaocurso/resource/MateriaController.java index f3ce135..192be50 100644 --- a/backend/src/main/java/com/senac/gestaocurso/resource/MateriaController.java +++ b/backend/src/main/java/com/senac/gestaocurso/resource/MateriaController.java @@ -3,6 +3,9 @@ import com.senac.gestaocurso.models.Materia; import com.senac.gestaocurso.service.MateriaService; 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.*; @@ -18,12 +21,14 @@ public class MateriaController { @PostMapping() public ResponseEntity salvar(@RequestBody Materia materia){ Materia save = materiaService.salvar(materia); - return ResponseEntity.created(URI.create("/materia/salvar" + materia.getId())).body(save); + return ResponseEntity.created(URI.create("/api/materia" + materia.getId())).body(save); } @GetMapping - public ResponseEntity findAll() { - List materias = materiaService.buscaTodos(); + public ResponseEntity findAll(@RequestParam(defaultValue = "0") int page, + @RequestParam(defaultValue = "0") int size) { + Pageable pageable = PageRequest.of(page, size); + Page materias = materiaService.buscaTodos(pageable); return ResponseEntity.ok(materias); } @GetMapping("/{id}") diff --git a/backend/src/main/java/com/senac/gestaocurso/resource/TurmaController.java b/backend/src/main/java/com/senac/gestaocurso/resource/TurmaController.java index ae819ac..09fa6b4 100644 --- a/backend/src/main/java/com/senac/gestaocurso/resource/TurmaController.java +++ b/backend/src/main/java/com/senac/gestaocurso/resource/TurmaController.java @@ -4,6 +4,9 @@ import com.senac.gestaocurso.models.Turma; import com.senac.gestaocurso.service.TurmaService; 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.*; @@ -19,12 +22,14 @@ public class TurmaController { @PostMapping() public ResponseEntity salvar(@RequestBody Turma turma){ Turma save = turmaService.salvar(turma); - return ResponseEntity.created(URI.create("/turma/salvar" + turma.getId())).body(save); + return ResponseEntity.created(URI.create("/api/turma" + turma.getId())).body(save); } @GetMapping - public ResponseEntity findAll() { - List funcionarios = turmaService.buscaTodos(); + public ResponseEntity findAll(@RequestParam(defaultValue = "0") int page, + @RequestParam(defaultValue = "0") int size) { + Pageable pageable = PageRequest.of(page, size); + Page funcionarios = turmaService.buscaTodos(pageable); return ResponseEntity.ok(funcionarios); } @GetMapping("/{id}") diff --git a/backend/src/main/java/com/senac/gestaocurso/service/CertificacoesService.java b/backend/src/main/java/com/senac/gestaocurso/service/CertificacoesService.java index 9130fba..bff1ef8 100644 --- a/backend/src/main/java/com/senac/gestaocurso/service/CertificacoesService.java +++ b/backend/src/main/java/com/senac/gestaocurso/service/CertificacoesService.java @@ -5,6 +5,8 @@ import com.senac.gestaocurso.models.Certificacoes; import com.senac.gestaocurso.repository.CertifcacoesRepository; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.Pageable; import org.springframework.stereotype.Service; import java.util.List; @@ -15,10 +17,12 @@ public class CertificacoesService { @Autowired private CertifcacoesRepository certifcacoesRepository; - public Certificacoes salvar(Certificacoes entity) {return certifcacoesRepository.save(entity);} + public Certificacoes salvar(Certificacoes entity) { + return certifcacoesRepository.save(entity); + } - public List buscaTodos() { - return certifcacoesRepository.findAll(); + public Page buscaTodos(Pageable pageable) { + return certifcacoesRepository.findAll(pageable); } public Certificacoes buscaPorId(Long id) { return certifcacoesRepository.findById(id).orElse(null); diff --git a/backend/src/main/java/com/senac/gestaocurso/service/CursoService.java b/backend/src/main/java/com/senac/gestaocurso/service/CursoService.java index 749ed0e..56365a7 100644 --- a/backend/src/main/java/com/senac/gestaocurso/service/CursoService.java +++ b/backend/src/main/java/com/senac/gestaocurso/service/CursoService.java @@ -4,6 +4,8 @@ import com.senac.gestaocurso.models.Curso; import com.senac.gestaocurso.repository.CursoRepository; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.Pageable; import org.springframework.stereotype.Service; import java.util.List; @@ -12,9 +14,11 @@ public class CursoService { @Autowired private CursoRepository cursoRepository; - public Curso salvar(Curso entity) {return cursoRepository.save(entity);} - public List buscaTodos() { - return cursoRepository.findAll(); + public Curso salvar(Curso entity) { + return cursoRepository.save(entity); + } + public Page buscaTodos(Pageable pageable) { + return cursoRepository.findAll(pageable); } public Curso buscaPorId(Long id) { return cursoRepository.findById(id).orElse(null); diff --git a/backend/src/main/java/com/senac/gestaocurso/service/DadosBancariosService.java b/backend/src/main/java/com/senac/gestaocurso/service/DadosBancariosService.java index 858524f..7b51459 100644 --- a/backend/src/main/java/com/senac/gestaocurso/service/DadosBancariosService.java +++ b/backend/src/main/java/com/senac/gestaocurso/service/DadosBancariosService.java @@ -4,6 +4,8 @@ import com.senac.gestaocurso.models.DadosBancarios; import com.senac.gestaocurso.repository.DadosBancariosRepository; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.Pageable; import org.springframework.stereotype.Service; import java.util.List; @@ -13,9 +15,11 @@ public class DadosBancariosService { @Autowired private DadosBancariosRepository dadosBancariosRepository; - public DadosBancarios salvar(DadosBancarios entity) {return dadosBancariosRepository.save(entity);} - public List buscaTodos() { - return dadosBancariosRepository.findAll(); + public DadosBancarios salvar(DadosBancarios entity) { + return dadosBancariosRepository.save(entity); + } + public Page buscaTodos(Pageable pageable) { + return dadosBancariosRepository.findAll(pageable); } public DadosBancarios buscaPorId(Long id) { return dadosBancariosRepository.findById(id).orElse(null); diff --git a/backend/src/main/java/com/senac/gestaocurso/service/DependentesService.java b/backend/src/main/java/com/senac/gestaocurso/service/DependentesService.java index fb5b39d..f666817 100644 --- a/backend/src/main/java/com/senac/gestaocurso/service/DependentesService.java +++ b/backend/src/main/java/com/senac/gestaocurso/service/DependentesService.java @@ -4,6 +4,8 @@ import com.senac.gestaocurso.models.Dependentes; import com.senac.gestaocurso.repository.DependentesRepository; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.Pageable; import org.springframework.stereotype.Service; import java.util.List; import java.util.Optional; @@ -12,11 +14,15 @@ public class DependentesService { @Autowired private DependentesRepository dependentesRepository; - public Dependentes salvar(Dependentes entity) {return dependentesRepository.save(entity);} - public List buscaTodos() { - return dependentesRepository.findAll(); + public Dependentes salvar(Dependentes entity) { + return dependentesRepository.save(entity); + } + public Page buscaTodos(Pageable pageable) { + return dependentesRepository.findAll(pageable); + } + public Dependentes buscaPorId(Long id) { + return dependentesRepository.findById(id).orElse(null); } - public Dependentes buscaPorId(Long id) {return dependentesRepository.findById(id).orElse(null);} public Dependentes alterar(Long id, Dependentes alterado) { Optional encontrado = dependentesRepository.findById(id); if ((encontrado.isPresent())) { diff --git a/backend/src/main/java/com/senac/gestaocurso/service/ExpAnteriorService.java b/backend/src/main/java/com/senac/gestaocurso/service/ExpAnteriorService.java index 7b10b99..8b8fa9d 100644 --- a/backend/src/main/java/com/senac/gestaocurso/service/ExpAnteriorService.java +++ b/backend/src/main/java/com/senac/gestaocurso/service/ExpAnteriorService.java @@ -4,6 +4,8 @@ import com.senac.gestaocurso.models.ExpAnterior; import com.senac.gestaocurso.repository.ExpAnteriorRepository; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.Pageable; import org.springframework.stereotype.Service; import java.util.List; import java.util.Optional; @@ -12,9 +14,11 @@ public class ExpAnteriorService { @Autowired private ExpAnteriorRepository expAnteriorRepository; - public ExpAnterior salvar(ExpAnterior entity) {return expAnteriorRepository.save(entity);} - public List buscaTodos() { - return expAnteriorRepository.findAll(); + public ExpAnterior salvar(ExpAnterior entity) { + return expAnteriorRepository.save(entity); + } + public Page buscaTodos(Pageable pageable) { + return expAnteriorRepository.findAll(pageable); } public ExpAnterior buscaPorId(Long id) { return expAnteriorRepository.findById(id).orElse(null); diff --git a/backend/src/main/java/com/senac/gestaocurso/service/FiliacaoService.java b/backend/src/main/java/com/senac/gestaocurso/service/FiliacaoService.java index 74e40f2..f231f37 100644 --- a/backend/src/main/java/com/senac/gestaocurso/service/FiliacaoService.java +++ b/backend/src/main/java/com/senac/gestaocurso/service/FiliacaoService.java @@ -3,6 +3,8 @@ import com.senac.gestaocurso.models.Filiacao; import com.senac.gestaocurso.repository.FiliacaoRepository; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.Pageable; import org.springframework.stereotype.Service; import java.util.List; @@ -12,8 +14,12 @@ public class FiliacaoService { @Autowired private FiliacaoRepository filiacaoRepository; - public Filiacao salvar(Filiacao entity) {return filiacaoRepository.save(entity);} - public List buscaTodos() {return filiacaoRepository.findAll();} + public Filiacao salvar(Filiacao entity) { + return filiacaoRepository.save(entity); + } + public Page buscaTodos(Pageable pageable) { + return filiacaoRepository.findAll(pageable); + } public Filiacao buscaPorId(Long id) { return filiacaoRepository.findById(id).orElse(null); } diff --git a/backend/src/main/java/com/senac/gestaocurso/service/FrequenciaService.java b/backend/src/main/java/com/senac/gestaocurso/service/FrequenciaService.java index 6bd9df1..bdba80e 100644 --- a/backend/src/main/java/com/senac/gestaocurso/service/FrequenciaService.java +++ b/backend/src/main/java/com/senac/gestaocurso/service/FrequenciaService.java @@ -5,6 +5,8 @@ import com.senac.gestaocurso.repository.FiliacaoRepository; import com.senac.gestaocurso.repository.FrequenciaRepository; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.Pageable; import org.springframework.stereotype.Service; import java.util.List; @@ -13,8 +15,12 @@ public class FrequenciaService { @Autowired private FrequenciaRepository frequenciaRepository; - public Frequencia salvar(Frequencia entity) {return frequenciaRepository.save(entity);} - public List buscaTodos() {return frequenciaRepository.findAll();} + public Frequencia salvar(Frequencia entity) { + return frequenciaRepository.save(entity); + } + public Page buscaTodos(Pageable pageable) { + return frequenciaRepository.findAll(pageable); + } public Frequencia buscaPorId(Long id) { return frequenciaRepository.findById(id).orElse(null); } diff --git a/backend/src/main/java/com/senac/gestaocurso/service/FuncionarioService.java b/backend/src/main/java/com/senac/gestaocurso/service/FuncionarioService.java index ae76fd3..cdb47ad 100644 --- a/backend/src/main/java/com/senac/gestaocurso/service/FuncionarioService.java +++ b/backend/src/main/java/com/senac/gestaocurso/service/FuncionarioService.java @@ -3,6 +3,8 @@ import com.senac.gestaocurso.models.Funcionario; import com.senac.gestaocurso.repository.FuncionarioRepository; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.Pageable; import org.springframework.stereotype.Service; import java.util.List; @@ -14,10 +16,12 @@ public class FuncionarioService { @Autowired private FuncionarioRepository funcionarioRepository; - public Funcionario salvar(Funcionario entity) {return funcionarioRepository.save(entity);} + public Funcionario salvar(Funcionario entity) { + return funcionarioRepository.save(entity); + } - public List buscaTodos() { - return funcionarioRepository.findAll(); + public Page buscaTodos(Pageable pageable) { + return funcionarioRepository.findAll(pageable); } public Funcionario buscaPorId(Long id) { return funcionarioRepository.findById(id).orElse(null); diff --git a/backend/src/main/java/com/senac/gestaocurso/service/InscricaoService.java b/backend/src/main/java/com/senac/gestaocurso/service/InscricaoService.java index 585b9d6..89d3a13 100644 --- a/backend/src/main/java/com/senac/gestaocurso/service/InscricaoService.java +++ b/backend/src/main/java/com/senac/gestaocurso/service/InscricaoService.java @@ -3,6 +3,8 @@ import com.senac.gestaocurso.models.Inscricao; import com.senac.gestaocurso.repository.InscricaoRepository; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.Pageable; import org.springframework.stereotype.Service; import java.util.List; @@ -12,8 +14,12 @@ public class InscricaoService { @Autowired private InscricaoRepository inscricaoRepository; - public Inscricao salvar(Inscricao entity) {return inscricaoRepository.save(entity);} - public List buscaTodos() {return inscricaoRepository.findAll();} + public Inscricao salvar(Inscricao entity) { + return inscricaoRepository.save(entity); + } + public Page buscaTodos(Pageable pageable) { + return inscricaoRepository.findAll(pageable); + } public Inscricao buscaPorId(Long id) { return inscricaoRepository.findById(id).orElse(null); } diff --git a/backend/src/main/java/com/senac/gestaocurso/service/MateriaService.java b/backend/src/main/java/com/senac/gestaocurso/service/MateriaService.java index 2b6fd96..9571750 100644 --- a/backend/src/main/java/com/senac/gestaocurso/service/MateriaService.java +++ b/backend/src/main/java/com/senac/gestaocurso/service/MateriaService.java @@ -5,6 +5,8 @@ import com.senac.gestaocurso.repository.FuncionarioRepository; import com.senac.gestaocurso.repository.MateriaRepository; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.Pageable; import org.springframework.stereotype.Service; import java.util.List; @@ -14,9 +16,11 @@ public class MateriaService { @Autowired private MateriaRepository materiaRepository; - public Materia salvar(Materia entity) {return materiaRepository.save(entity);} - public List buscaTodos() { - return materiaRepository.findAll(); + public Materia salvar(Materia entity) { + return materiaRepository.save(entity); + } + public Page buscaTodos(Pageable pageable) { + return materiaRepository.findAll(pageable); } public Materia buscaPorId(Long id) { return materiaRepository.findById(id).orElse(null); diff --git a/backend/src/main/java/com/senac/gestaocurso/service/TurmaService.java b/backend/src/main/java/com/senac/gestaocurso/service/TurmaService.java index ab3e478..13e03fb 100644 --- a/backend/src/main/java/com/senac/gestaocurso/service/TurmaService.java +++ b/backend/src/main/java/com/senac/gestaocurso/service/TurmaService.java @@ -3,6 +3,8 @@ import com.senac.gestaocurso.models.Turma; import com.senac.gestaocurso.repository.TurmaRepository; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.Pageable; import org.springframework.stereotype.Service; import java.util.List; @@ -11,9 +13,11 @@ public class TurmaService { @Autowired private TurmaRepository turmaRepository; - public Turma salvar(Turma entity) {return turmaRepository.save(entity);} - public List buscaTodos() { - return turmaRepository.findAll(); + public Turma salvar(Turma entity) { + return turmaRepository.save(entity); + } + public Page buscaTodos(Pageable pageable) { + return turmaRepository.findAll(pageable); } public Turma buscaPorId(Long id) { return turmaRepository.findById(id).orElse(null);