diff --git a/src/main/java/mx/com/pandadevs/pibeapi/models/vacants/repository/VacantRepository.java b/src/main/java/mx/com/pandadevs/pibeapi/models/vacants/repository/VacantRepository.java index 6ac8b40..daec648 100644 --- a/src/main/java/mx/com/pandadevs/pibeapi/models/vacants/repository/VacantRepository.java +++ b/src/main/java/mx/com/pandadevs/pibeapi/models/vacants/repository/VacantRepository.java @@ -4,11 +4,13 @@ import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.stereotype.Repository; +import java.time.LocalDateTime; import java.util.List; import java.util.Optional; @Repository public interface VacantRepository extends JpaRepository { List findAllByActiveIsTrueAndIsPublicIsTrue(); + List findAllByActiveIsTrueAndIsPublicIsTrueAndEndDateGreaterThanEqual(LocalDateTime time); Optional findByIdAndActiveIsTrue(Integer id); } diff --git a/src/main/java/mx/com/pandadevs/pibeapi/models/vacants/service/VacantService.java b/src/main/java/mx/com/pandadevs/pibeapi/models/vacants/service/VacantService.java index 42ebca6..b2297f9 100644 --- a/src/main/java/mx/com/pandadevs/pibeapi/models/vacants/service/VacantService.java +++ b/src/main/java/mx/com/pandadevs/pibeapi/models/vacants/service/VacantService.java @@ -23,6 +23,7 @@ import org.springframework.util.ReflectionUtils; import java.lang.reflect.Field; +import java.time.LocalDateTime; import java.util.ArrayList; import java.util.List; import java.util.Map; @@ -64,7 +65,8 @@ public VacantService(VacantMapper mapper) { @Transactional(readOnly = true) public List getAll() { - return mapper.toVacantsDto(vacantRepository.findAllByActiveIsTrueAndIsPublicIsTrue()); + LocalDateTime nowTime = LocalDateTime.now(); + return mapper.toVacantsDto(vacantRepository.findAllByActiveIsTrueAndIsPublicIsTrueAndEndDateGreaterThanEqual(nowTime)); } @Transactional(readOnly = true)