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