|
| 1 | +package es.lanyu.eventos.rest; |
| 2 | + |
| 3 | +import java.time.Instant; |
| 4 | +import java.util.List; |
| 5 | + |
| 6 | +import org.springframework.data.rest.webmvc.PersistentEntityResource; |
| 7 | +import org.springframework.data.rest.webmvc.PersistentEntityResourceAssembler; |
| 8 | +import org.springframework.data.rest.webmvc.RepositoryRestController; |
| 9 | +import org.springframework.hateoas.CollectionModel; |
| 10 | +import org.springframework.web.bind.annotation.GetMapping; |
| 11 | +import org.springframework.web.bind.annotation.PathVariable; |
| 12 | +import org.springframework.web.bind.annotation.RequestMapping; |
| 13 | +import org.springframework.web.bind.annotation.RequestParam; |
| 14 | +import org.springframework.web.bind.annotation.ResponseBody; |
| 15 | + |
| 16 | +import es.lanyu.eventos.repositorios.SucesoConId; |
| 17 | +import es.lanyu.eventos.repositorios.SucesoDAO; |
| 18 | + |
| 19 | +@RepositoryRestController |
| 20 | +@RequestMapping(path = "/sucesos/search") |
| 21 | +public class SucesoController { |
| 22 | + |
| 23 | + private SucesoDAO sucesoDAO; |
| 24 | + |
| 25 | + SucesoController(SucesoDAO sucesoDAO) { |
| 26 | + this.sucesoDAO = sucesoDAO; |
| 27 | + } |
| 28 | + |
| 29 | + @GetMapping("/participante/{id}/entre-fechas") |
| 30 | + @ResponseBody |
| 31 | + public CollectionModel<PersistentEntityResource> getSucesosConIdParticipanteEntreFechas( |
| 32 | + @PathVariable("id") String id, @RequestParam Instant comienzo, @RequestParam Instant fin, |
| 33 | + PersistentEntityResourceAssembler assembler) { |
| 34 | + List<SucesoConId> sucesos = sucesoDAO.findByIdParticipanteAndTemporalBetween(id, comienzo, fin); |
| 35 | + |
| 36 | + return assembler.toCollectionModel(sucesos); |
| 37 | + } |
| 38 | + |
| 39 | +} |
0 commit comments