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

Commit 24ea67c

Browse files
Notfound to nocontent (#46)
## Descrição refactoring de status not found para status ok ## Checklist - [x] Eu verifiquei se este pull request está direcionado à branch correta - [x] Meus commits seguem as [convenções de commit](https://www.conventionalcommits.org/en/v1.0.0/) - [ ] Eu adicionei/atualizei a documentação necessária (se aplicável)
2 parents db286fa + d87de6c commit 24ea67c

15 files changed

+59
-59
lines changed

backend/src/main/java/com/senac/gestaocurso/enterprise/exception/NotFoundException.java

Lines changed: 0 additions & 7 deletions
This file was deleted.
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
package com.senac.gestaocurso.enterprise.exception;
2+
3+
public class OkNoContent extends RuntimeException{
4+
public OkNoContent(String message){
5+
super(message);
6+
}
7+
}

backend/src/main/java/com/senac/gestaocurso/resource/AbstractController.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package com.senac.gestaocurso.resource;
22

3-
import com.senac.gestaocurso.enterprise.exception.NotFoundException;
3+
import com.senac.gestaocurso.enterprise.exception.OkNoContent;
44
import com.senac.gestaocurso.enterprise.exception.ValidationException;
55
import org.springframework.http.HttpStatus;
66
import org.springframework.validation.FieldError;
@@ -36,10 +36,10 @@ public Map<String, String> handleValidationExceptions422(
3636
return errors;
3737
}
3838

39-
@ResponseStatus(HttpStatus.NOT_FOUND)
40-
@ExceptionHandler(NotFoundException.class)
39+
@ResponseStatus(HttpStatus.OK)
40+
@ExceptionHandler(OkNoContent.class)
4141
public Map<String, String> handleValidationExceptions404(
42-
NotFoundException ex) {
42+
OkNoContent ex) {
4343
Map<String, String> errors = new HashMap<>();
4444
errors.put("erro", ex.getMessage());
4545
return errors;

backend/src/main/java/com/senac/gestaocurso/service/AulaService.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package com.senac.gestaocurso.service;
22

33
import com.senac.gestaocurso.dto.AulaDto;
4-
import com.senac.gestaocurso.enterprise.exception.NotFoundException;
4+
import com.senac.gestaocurso.enterprise.exception.OkNoContent;
55
import com.senac.gestaocurso.models.domain.Aula;
66
import com.senac.gestaocurso.repository.AulaRepository;
77
import com.senac.gestaocurso.strategy.NovaValidacaoAulaStrategy;
@@ -40,14 +40,14 @@ public Page<AulaDto> buscaTodos(String filter, Pageable pageable) {
4040
Page<Aula> aulasPage = aulaRepository.findAll(filter, Aula.class, pageable);
4141

4242
if (aulasPage.isEmpty()){
43-
throw new NotFoundException("Nenhum funcionário encontrado");
43+
throw new OkNoContent("Nenhum funcionário encontrado");
4444
}
4545

4646
return aulasPage.map(AulaDto::fromEntity);
4747
}
4848

4949
public Aula buscaPorId(Long id){
50-
return aulaRepository.findById(id).orElseThrow(() -> new NotFoundException("aula não encontrada"));
50+
return aulaRepository.findById(id).orElseThrow(() -> new OkNoContent("aula não encontrada"));
5151
}
5252

5353
public Aula alterar(Long id, Aula alterado){
@@ -60,7 +60,7 @@ public Aula alterar(Long id, Aula alterado){
6060
return aulaRepository.save(aula);
6161
}
6262

63-
throw new NotFoundException("Aula não encontrada");
63+
throw new OkNoContent("Aula não encontrada");
6464
}
6565

6666
public void remover(Long id) {aulaRepository.deleteById(id);}

backend/src/main/java/com/senac/gestaocurso/service/CargoService.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package com.senac.gestaocurso.service;
22

33
import com.senac.gestaocurso.dto.CargoDto;
4-
import com.senac.gestaocurso.enterprise.exception.NotFoundException;
4+
import com.senac.gestaocurso.enterprise.exception.OkNoContent;
55
import com.senac.gestaocurso.models.Cargo;
66
import com.senac.gestaocurso.repository.CargoRepository;
77
import org.modelmapper.ModelMapper;
@@ -27,14 +27,14 @@ public Page<CargoDto> buscaTodos(String filter, Pageable pageable) {
2727
Page<Cargo> cargoPage = cargoRepository.findAll(filter, Cargo.class, pageable);
2828

2929
if (cargoPage.isEmpty()){
30-
throw new NotFoundException("Nenhum cargo encontrado");
30+
throw new OkNoContent("Nenhum cargo encontrado");
3131
}
3232

3333
return cargoPage.map(CargoDto::fromEntity);
3434
}
3535

3636
public Cargo buscaPorId(Long id) {
37-
return cargoRepository.findById(id).orElseThrow(() -> new NotFoundException("cargo não encontrado"));
37+
return cargoRepository.findById(id).orElseThrow(() -> new OkNoContent("cargo não encontrado"));
3838
}
3939

4040
public Cargo alterar(Long id, Cargo alterado) {
@@ -46,7 +46,7 @@ public Cargo alterar(Long id, Cargo alterado) {
4646
return cargoRepository.save(cargo);
4747
}
4848

49-
throw new NotFoundException("cargo não encontrado");
49+
throw new OkNoContent("cargo não encontrado");
5050
}
5151

5252
public void remover(Long id) {

backend/src/main/java/com/senac/gestaocurso/service/CertificacaoService.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package com.senac.gestaocurso.service;
22

33
import com.senac.gestaocurso.dto.CertificaoDto;
4-
import com.senac.gestaocurso.enterprise.exception.NotFoundException;
4+
import com.senac.gestaocurso.enterprise.exception.OkNoContent;
55
import com.senac.gestaocurso.models.Certificacao;
66
import com.senac.gestaocurso.repository.CertifcacaoRepository;
77
import org.modelmapper.ModelMapper;
@@ -27,14 +27,14 @@ public Page<CertificaoDto> buscaTodos(String filter, Pageable pageable) {
2727
Page<Certificacao> certificacaoPage = certifcacaoRepository.findAll(filter, Certificacao.class, pageable);
2828

2929
if (certificacaoPage.isEmpty()){
30-
throw new NotFoundException("Nenhuma certificaçãp encontrado");
30+
throw new OkNoContent("Nenhuma certificaçãp encontrado");
3131
}
3232

3333
return certificacaoPage.map(CertificaoDto::fromEntity);
3434
}
3535

3636
public Certificacao buscaPorId(Long id) {
37-
return certifcacaoRepository.findById(id).orElseThrow(() -> new NotFoundException("certificação não encontrada"));
37+
return certifcacaoRepository.findById(id).orElseThrow(() -> new OkNoContent("certificação não encontrada"));
3838
}
3939

4040
public Certificacao alterar(Long id, Certificacao alterado) {
@@ -46,7 +46,7 @@ public Certificacao alterar(Long id, Certificacao alterado) {
4646
return certifcacaoRepository.save(certificacao);
4747
}
4848

49-
throw new NotFoundException("certificação não encontrada");
49+
throw new OkNoContent("certificação não encontrada");
5050
}
5151

5252
public void remover(Long id) {

backend/src/main/java/com/senac/gestaocurso/service/CursoService.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package com.senac.gestaocurso.service;
22

33
import com.senac.gestaocurso.dto.CursoDto;
4-
import com.senac.gestaocurso.enterprise.exception.NotFoundException;
4+
import com.senac.gestaocurso.enterprise.exception.OkNoContent;
55
import com.senac.gestaocurso.models.domain.Curso;
66
import com.senac.gestaocurso.repository.CursoRepository;
77
import org.modelmapper.ModelMapper;
@@ -38,14 +38,14 @@ public Page<CursoDto> buscaTodos(String filter, Pageable pageable) {
3838
Page<Curso> cursoPage = cursoRepository.findAll(filter, Curso.class ,pageable);
3939

4040
if (cursoPage.isEmpty()){
41-
throw new NotFoundException("Nenhum curso encontrado");
41+
throw new OkNoContent("Nenhum curso encontrado");
4242
}
4343

4444
return cursoPage.map(CursoDto::fromEntity);
4545
}
4646

4747
public Curso buscaPorId(Long id) {
48-
return cursoRepository.findById(id).orElseThrow(() -> new NotFoundException("Curso não encontrado"));
48+
return cursoRepository.findById(id).orElseThrow(() -> new OkNoContent("Curso não encontrado"));
4949
}
5050

5151
public Curso alterar(Long id, Curso alterado) {
@@ -56,7 +56,7 @@ public Curso alterar(Long id, Curso alterado) {
5656
modelMapper.map(alterado, curso);
5757
return cursoRepository.save(curso);
5858
}
59-
throw new NotFoundException("Curso não encontrado");
59+
throw new OkNoContent("Curso não encontrado");
6060
}
6161

6262
public void remover(Long id) {

backend/src/main/java/com/senac/gestaocurso/service/DadosBancarioService.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package com.senac.gestaocurso.service;
22

33
import com.senac.gestaocurso.dto.DadosBancarioDto;
4-
import com.senac.gestaocurso.enterprise.exception.NotFoundException;
4+
import com.senac.gestaocurso.enterprise.exception.OkNoContent;
55
import com.senac.gestaocurso.models.DadosBancario;
66
import com.senac.gestaocurso.repository.DadosBancarioRepository;
77
import org.modelmapper.ModelMapper;
@@ -27,14 +27,14 @@ public Page<DadosBancarioDto> buscaTodos(String filter, Pageable pageable) {
2727
Page<DadosBancario> dadosBancarioPage = dadosBancarioRepository.findAll(filter, DadosBancario.class, pageable);
2828

2929
if (dadosBancarioPage.isEmpty()){
30-
throw new NotFoundException("Dados bancarios não encontrado");
30+
throw new OkNoContent("Dados bancarios não encontrado");
3131
}
3232

3333
return dadosBancarioPage.map(DadosBancarioDto::fromEntity);
3434
}
3535

3636
public DadosBancario buscaPorId(Long id) {
37-
return dadosBancarioRepository.findById(id).orElseThrow(() -> new NotFoundException("Dado bancário não encontrado"));
37+
return dadosBancarioRepository.findById(id).orElseThrow(() -> new OkNoContent("Dado bancário não encontrado"));
3838
}
3939

4040
public DadosBancario alterar(Long id, DadosBancario alterado) {
@@ -46,7 +46,7 @@ public DadosBancario alterar(Long id, DadosBancario alterado) {
4646
return dadosBancarioRepository.save(dadosBancario);
4747
}
4848

49-
throw new NotFoundException("Dado bancário não encontrado");
49+
throw new OkNoContent("Dado bancário não encontrado");
5050
}
5151

5252
public void remover(Long id) {

backend/src/main/java/com/senac/gestaocurso/service/DependenteService.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package com.senac.gestaocurso.service;
22

33
import com.senac.gestaocurso.dto.DependenteDto;
4-
import com.senac.gestaocurso.enterprise.exception.NotFoundException;
4+
import com.senac.gestaocurso.enterprise.exception.OkNoContent;
55
import com.senac.gestaocurso.models.Dependente;
66
import com.senac.gestaocurso.repository.DependenteRepository;
77
import org.modelmapper.ModelMapper;
@@ -27,14 +27,14 @@ public Page<DependenteDto> buscaTodos(String filter, Pageable pageable) {
2727
Page<Dependente> dependentePage = dependenteRepository.findAll(filter, Dependente.class, pageable);
2828

2929
if (dependentePage.isEmpty()){
30-
throw new NotFoundException("Nenhum Dependente encontrado");
30+
throw new OkNoContent("Nenhum Dependente encontrado");
3131
}
3232

3333
return dependentePage.map(DependenteDto::fromEntity);
3434
}
3535

3636
public Dependente buscaPorId(Long id) {
37-
return dependenteRepository.findById(id).orElseThrow(() -> new NotFoundException("Dependente não encontrado"));
37+
return dependenteRepository.findById(id).orElseThrow(() -> new OkNoContent("Dependente não encontrado"));
3838
}
3939

4040
public Dependente alterar(Long id, Dependente alterado) {
@@ -46,7 +46,7 @@ public Dependente alterar(Long id, Dependente alterado) {
4646
return dependenteRepository.save(dependente);
4747
}
4848

49-
throw new NotFoundException("Dependente não encontrado");
49+
throw new OkNoContent("Dependente não encontrado");
5050
}
5151

5252
public void remover(Long id) {

backend/src/main/java/com/senac/gestaocurso/service/ExperienciaAnteriorService.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package com.senac.gestaocurso.service;
22

33
import com.senac.gestaocurso.dto.ExperiencaAnteriorDto;
4-
import com.senac.gestaocurso.enterprise.exception.NotFoundException;
4+
import com.senac.gestaocurso.enterprise.exception.OkNoContent;
55
import com.senac.gestaocurso.models.ExperienciaAnterior;
66
import com.senac.gestaocurso.repository.ExperienciaAnteriorRepository;
77
import org.modelmapper.ModelMapper;
@@ -27,13 +27,13 @@ public Page<ExperiencaAnteriorDto> buscaTodos(String filter, Pageable pageable)
2727
Page<ExperienciaAnterior> experienciaAnteriorPage = experienciaAnteriorRepository.findAll(filter, ExperienciaAnterior.class, pageable);
2828

2929
if (experienciaAnteriorPage.isEmpty()){
30-
throw new NotFoundException("Nenhuma experiencia encontrada");
30+
throw new OkNoContent("Nenhuma experiencia encontrada");
3131
}
3232
return experienciaAnteriorPage.map(ExperiencaAnteriorDto::fromEntity);
3333
}
3434

3535
public ExperienciaAnterior buscaPorId(Long id) {
36-
return experienciaAnteriorRepository.findById(id).orElseThrow(() -> new NotFoundException("Experiência anterior não encontrada"));
36+
return experienciaAnteriorRepository.findById(id).orElseThrow(() -> new OkNoContent("Experiência anterior não encontrada"));
3737
}
3838

3939
public ExperienciaAnterior alterar(Long id, ExperienciaAnterior alterado) {
@@ -45,7 +45,7 @@ public ExperienciaAnterior alterar(Long id, ExperienciaAnterior alterado) {
4545
return experienciaAnteriorRepository.save(experienciaAnterior);
4646
}
4747

48-
throw new NotFoundException("Experiência anterior não encontrada");
48+
throw new OkNoContent("Experiência anterior não encontrada");
4949
}
5050

5151
public void remover(Long id) {

backend/src/main/java/com/senac/gestaocurso/service/FiliacaoService.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package com.senac.gestaocurso.service;
22

33
import com.senac.gestaocurso.dto.FiliacaoDto;
4-
import com.senac.gestaocurso.enterprise.exception.NotFoundException;
4+
import com.senac.gestaocurso.enterprise.exception.OkNoContent;
55
import com.senac.gestaocurso.models.Filiacao;
66
import com.senac.gestaocurso.repository.FiliacaoRepository;
77
import org.modelmapper.ModelMapper;
@@ -27,14 +27,14 @@ public Page<FiliacaoDto> buscaTodos(String filter, Pageable pageable) {
2727
Page<Filiacao> filiacaoPage = filiacaoRepository.findAll(filter, Filiacao.class, pageable);
2828

2929
if (filiacaoPage.isEmpty()){
30-
throw new NotFoundException("Não há Filiação");
30+
throw new OkNoContent("Não há Filiação");
3131
}
3232

3333
return filiacaoPage.map(FiliacaoDto::fromEntity);
3434
}
3535

3636
public Filiacao buscaPorId(Long id) {
37-
return filiacaoRepository.findById(id).orElseThrow(() -> new NotFoundException("Filiação não encontrada"));
37+
return filiacaoRepository.findById(id).orElseThrow(() -> new OkNoContent("Filiação não encontrada"));
3838
}
3939

4040
public Filiacao alterar(Long id, Filiacao alterado) {
@@ -46,7 +46,7 @@ public Filiacao alterar(Long id, Filiacao alterado) {
4646
return filiacaoRepository.save(filiacao);
4747
}
4848

49-
throw new NotFoundException("Filiaçãonão encontrada");
49+
throw new OkNoContent("Filiaçãonão encontrada");
5050
}
5151

5252
public void remover(Long id) {

backend/src/main/java/com/senac/gestaocurso/service/FrequenciaService.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package com.senac.gestaocurso.service;
22

33
import com.senac.gestaocurso.dto.FrequenciaDto;
4-
import com.senac.gestaocurso.enterprise.exception.NotFoundException;
4+
import com.senac.gestaocurso.enterprise.exception.OkNoContent;
55
import com.senac.gestaocurso.models.domain.Frequencia;
66
import com.senac.gestaocurso.repository.FrequenciaRepository;
77
import org.modelmapper.ModelMapper;
@@ -27,14 +27,14 @@ public Page<FrequenciaDto> buscaTodos(String filter, Pageable pageable) {
2727
Page<Frequencia> frequenciasPage = frequenciaRepository.findAll(filter, Frequencia.class, pageable);
2828

2929
if (frequenciasPage.isEmpty()){
30-
throw new NotFoundException("Nenhuma frequência enscontrada");
30+
throw new OkNoContent("Nenhuma frequência enscontrada");
3131
}
3232

3333
return frequenciasPage.map(FrequenciaDto::fromEntity);
3434
}
3535

3636
public Frequencia buscaPorId(Long id) {
37-
return frequenciaRepository.findById(id).orElseThrow(() -> new NotFoundException("Frequência não encontrada"));
37+
return frequenciaRepository.findById(id).orElseThrow(() -> new OkNoContent("Frequência não encontrada"));
3838
}
3939

4040
public Frequencia alterar(Long id, Frequencia alterado) {
@@ -44,7 +44,7 @@ public Frequencia alterar(Long id, Frequencia alterado) {
4444
modelMapper.map(alterado, frequencia);
4545
return frequenciaRepository.save(frequencia);
4646
}
47-
throw new NotFoundException("Frequência não encontrada");
47+
throw new OkNoContent("Frequência não encontrada");
4848
}
4949

5050
public void remover(Long id) {frequenciaRepository.deleteById(id);

backend/src/main/java/com/senac/gestaocurso/service/FuncionarioService.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package com.senac.gestaocurso.service;
22

33
import com.senac.gestaocurso.dto.FuncionarioDto;
4-
import com.senac.gestaocurso.enterprise.exception.NotFoundException;
4+
import com.senac.gestaocurso.enterprise.exception.OkNoContent;
55
import com.senac.gestaocurso.models.*;
66
import com.senac.gestaocurso.repository.FuncionarioRepository;
77
import com.senac.gestaocurso.strategy.NovaValidacaoFuncionarioStrategy;
@@ -38,14 +38,14 @@ public Page<FuncionarioDto> buscaTodos(String filter, Pageable pageable) {
3838
Page<Funcionario> funcionariosPage = funcionarioRepository.findAll(filter, Funcionario.class, pageable);
3939

4040
if (funcionariosPage.isEmpty()){
41-
throw new NotFoundException("Nenhum funcionário encontrado");
41+
throw new OkNoContent("Nenhum funcionário encontrado");
4242
}
4343

4444
return funcionariosPage.map(FuncionarioDto::fromEntity);
4545
}
4646

4747
public Funcionario buscaPorId(Long id) {
48-
return funcionarioRepository.findById(id).orElseThrow(() -> new NotFoundException("Funcionário não encontrado"));
48+
return funcionarioRepository.findById(id).orElseThrow(() -> new OkNoContent("Funcionário não encontrado"));
4949
}
5050

5151
public Funcionario alterar(Long id, Funcionario alterado) {
@@ -57,7 +57,7 @@ public Funcionario alterar(Long id, Funcionario alterado) {
5757
return funcionarioRepository.save(funcionario);
5858
}
5959

60-
throw new NotFoundException("Funcionário não encontrado");
60+
throw new OkNoContent("Funcionário não encontrado");
6161
}
6262

6363
public void remover(Long id) {

0 commit comments

Comments
 (0)