Rev 195 | Go to most recent revision | Details | Last modification | View Log | RSS feed
| Rev | Author | Line No. | Line |
|---|---|---|---|
| 106 | espaco | 1 | package br.com.ec.domain.service.taxa.impl; |
| 2 | |||
| 3 | import java.util.List; |
||
| 4 | |||
| 5 | import org.springframework.beans.factory.annotation.Autowired; |
||
| 6 | import org.springframework.stereotype.Service; |
||
| 7 | |||
| 8 | import br.com.ec.domain.model.Taxa; |
||
| 9 | import br.com.ec.domain.service.taxa.TaxaService; |
||
| 10 | import br.com.ec.infrastructure.repository.TaxaRepository; |
||
| 11 | import br.edu.cesmac.core.consulta.ParametrosConsulta; |
||
| 12 | import br.edu.cesmac.core.exception.NegocioException; |
||
| 13 | import br.edu.cesmac.core.generic.AbstractService; |
||
| 14 | import br.edu.cesmac.core.generic.GenericRepository; |
||
| 15 | import br.edu.cesmac.core.util.VerificadorUtil; |
||
| 16 | import br.edu.cesmac.core.validador.Validador; |
||
| 17 | |||
| 18 | @Service |
||
| 19 | public class TaxaServiceImpl extends AbstractService<Taxa> implements TaxaService { |
||
| 20 | |||
| 21 | private TaxaRepository taxaRepository; |
||
| 22 | |||
| 23 | @Autowired |
||
| 24 | public TaxaServiceImpl(Validador validador, TaxaRepository taxaRepository) { |
||
| 25 | super(validador); |
||
| 26 | this.taxaRepository = taxaRepository; |
||
| 27 | } |
||
| 28 | |||
| 29 | @Override |
||
| 30 | protected GenericRepository<Taxa> getRepository() { |
||
| 31 | return taxaRepository; |
||
| 32 | } |
||
| 33 | |||
| 34 | @Override |
||
| 35 | protected void regrasNegocioCadastrar(Taxa taxa) { |
||
| 36 | taxa.setAtivo(true); |
||
| 37 | // verificarSeTaxaJaExiste(taxa); |
||
| 38 | } |
||
| 39 | |||
| 40 | private void verificarSeTaxaJaExiste(Taxa taxa) { |
||
| 41 | if (this.consultarPassandoEntidade(taxa, 0, 1).size() > 0) { |
||
| 42 | throw new NegocioException("Taxa já existe"); |
||
| 43 | } |
||
| 44 | } |
||
| 45 | |||
| 46 | @Override |
||
| 47 | public List<Taxa> listarTaxasAtivas() { |
||
| 48 | Taxa taxaSelecionado = new Taxa(); |
||
| 49 | taxaSelecionado.setAtivo(true); |
||
| 50 | return this.consultarPassandoEntidade(taxaSelecionado, 0, this.obterQuantidadeDeRegistrosPassandoEntidade(taxaSelecionado)); |
||
| 51 | } |
||
| 52 | |||
| 53 | @Override |
||
| 54 | public List<Taxa> consultarTaxas(ParametrosConsulta<Taxa> parametrosConsulta) { |
||
| 55 | return this.consultarPassandoEntidade(parametrosConsulta.getEntidade(), 0, this.obterQuantidadeDeRegistrosPassandoEntidade(parametrosConsulta.getEntidade())); |
||
| 56 | } |
||
| 57 | |||
| 58 | @Override |
||
| 59 | public Taxa consultarTaxa(Taxa taxa) { |
||
| 60 | return taxaRepository.consultarTaxa(taxa); |
||
| 61 | } |
||
| 62 | |||
| 63 | } |