Rev 760 | Details | Compare with Previous | Last modification | View Log | RSS feed
| Rev | Author | Line No. | Line |
|---|---|---|---|
| 760 | blopes | 1 | package br.com.sl.domain.service.impl; |
| 2 | |||
| 3 | import java.time.LocalDateTime; |
||
| 761 | blopes | 4 | import java.util.List; |
| 760 | blopes | 5 | |
| 6 | import org.springframework.beans.factory.annotation.Autowired; |
||
| 7 | import org.springframework.stereotype.Service; |
||
| 8 | |||
| 9 | import br.com.ec.core.generic.AbstractService; |
||
| 10 | import br.com.ec.core.generic.GenericRepository; |
||
| 11 | import br.com.ec.core.validador.Validador; |
||
| 12 | import br.com.sl.domain.dto.robo.CandleState; |
||
| 13 | import br.com.sl.domain.model.Ativo; |
||
| 14 | import br.com.sl.domain.model.Candle; |
||
| 15 | import br.com.sl.domain.model.tipos.TipoPeriodoCandle; |
||
| 16 | import br.com.sl.domain.service.AtivoService; |
||
| 17 | import br.com.sl.domain.service.CandleService; |
||
| 18 | import br.com.sl.repository.CandleRepository; |
||
| 19 | |||
| 20 | @Service |
||
| 21 | public class CandleServiceImpl extends AbstractService<Candle> implements CandleService { |
||
| 22 | |||
| 23 | private CandleRepository candleRepository; |
||
| 24 | private AtivoService ativoService; |
||
| 25 | |||
| 26 | @Autowired |
||
| 27 | public CandleServiceImpl(CandleRepository candleRepository, AtivoService ativoService, Validador validador) { |
||
| 28 | super(validador); |
||
| 29 | this.candleRepository = candleRepository; |
||
| 30 | this.ativoService = ativoService; |
||
| 31 | } |
||
| 32 | |||
| 33 | @Override |
||
| 34 | protected GenericRepository<Candle> getRepository() { |
||
| 35 | return this.candleRepository; |
||
| 36 | } |
||
| 37 | |||
| 38 | @Override |
||
| 39 | public void cadastrar(String ativo, LocalDateTime inicioCandle, LocalDateTime fimCandle, CandleState situacaoCandle) { |
||
| 40 | Ativo ativoConsultado = ativoService.consultarPorDescricao(ativo); |
||
| 41 | Candle candle = new Candle(ativoConsultado, fimCandle, situacaoCandle, TipoPeriodoCandle.M1.getValor()); |
||
| 42 | candleRepository.cadastrar(candle); |
||
| 43 | } |
||
| 44 | |||
| 761 | blopes | 45 | @Override |
| 46 | public List<Candle> consultarAtivosComCandleEncerradoAte(LocalDateTime fimUltimoCandle) { |
||
| 47 | return candleRepository.consultarAtivosComCandleEncerradoAte(fimUltimoCandle); |
||
| 48 | } |
||
| 49 | |||
| 760 | blopes | 50 | } |