diff --git a/src/main/java/kr/hs/dgsw/clock_server/domain/routine/presentation/dto/res/RoutineLoadRes.java b/src/main/java/kr/hs/dgsw/clock_server/domain/routine/presentation/dto/res/RoutineLoadRes.java index 9aae561..0bc07dd 100644 --- a/src/main/java/kr/hs/dgsw/clock_server/domain/routine/presentation/dto/res/RoutineLoadRes.java +++ b/src/main/java/kr/hs/dgsw/clock_server/domain/routine/presentation/dto/res/RoutineLoadRes.java @@ -3,16 +3,22 @@ import kr.hs.dgsw.clock_server.global.common.enums.ColorEnum; import kr.hs.dgsw.clock_server.global.common.enums.ImportanceEnum; +import java.time.LocalDate; + public record RoutineLoadRes( Long id, String name, ImportanceEnum importanceEnum, - ColorEnum colorEnum + ColorEnum colorEnum, + LocalDate startAt, + LocalDate endAt ) { public static RoutineLoadRes of(Long id, String name, ImportanceEnum importanceEnum, - ColorEnum colorEnum){ - return new RoutineLoadRes(id, name, importanceEnum, colorEnum); + ColorEnum colorEnum, + LocalDate startAt, + LocalDate endAt){ + return new RoutineLoadRes(id, name, importanceEnum, colorEnum, startAt, endAt); } } diff --git a/src/main/java/kr/hs/dgsw/clock_server/domain/routine/repository/RoutineRepository.java b/src/main/java/kr/hs/dgsw/clock_server/domain/routine/repository/RoutineRepository.java index c08bff4..df812a9 100644 --- a/src/main/java/kr/hs/dgsw/clock_server/domain/routine/repository/RoutineRepository.java +++ b/src/main/java/kr/hs/dgsw/clock_server/domain/routine/repository/RoutineRepository.java @@ -11,5 +11,6 @@ @Repository public interface RoutineRepository extends JpaRepository { - List findByEndAtGreaterThanEqual(LocalDate endAt); + @Query("select o from RoutineEntity o where :date between o.startAt and o.endAt") + List findByDate(@Param("date") LocalDate date); } diff --git a/src/main/java/kr/hs/dgsw/clock_server/domain/routine/service/RoutineServiceImpl.java b/src/main/java/kr/hs/dgsw/clock_server/domain/routine/service/RoutineServiceImpl.java index 2c9326b..a12b096 100644 --- a/src/main/java/kr/hs/dgsw/clock_server/domain/routine/service/RoutineServiceImpl.java +++ b/src/main/java/kr/hs/dgsw/clock_server/domain/routine/service/RoutineServiceImpl.java @@ -53,14 +53,17 @@ public void delete(Long id) { @Override public List loadRoutine() { - List routineEntity = routineRepository.findByEndAtGreaterThanEqual(LocalDate.now()); + List routineEntity = routineRepository.findByDate(LocalDate.now()); List routineLoadResList = new ArrayList<>(); for (RoutineEntity routine : routineEntity){ routineLoadResList.add(RoutineLoadRes.of(routine.getRoutineId(), routine.getName(), routine.getImportanceEnum(), - routine.getColorEnum())); + routine.getColorEnum(), + routine.getStartAt(), + routine.getEndAt()) + ); } return routineLoadResList; }