Skip to content

Commit 2332ca4

Browse files
authored
[T3-107] 홈 루틴 조회 API 수정 (#26)
* fix: 홈 루틴 조회 API 내부 로직 수정(삭제이력 조회 제외, 완료여부 응답값 추가) * feat: 루틴 조회 응답값 추가(이력순번)
1 parent 9b86c08 commit 2332ca4

8 files changed

Lines changed: 86 additions & 43 deletions

File tree

src/main/java/bitnagil/bitnagil_backend/changedRoutine/repository/ChangedRoutineRepository.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public interface ChangedRoutineRepository extends JpaRepository<ChangedRoutine,
2121
* 현재 시점을 기준으로 유저의 살아있는 변경루틴 이력을 조회
2222
* historyStartDateTime < systime <= historyEndDateTime
2323
*/
24-
List<ChangedRoutine> findByUserIdAndHistoryStartDateTimeBeforeAndHistoryEndDateTimeGreaterThanEqualAndChangedRoutineDateBetween(
24+
List<ChangedRoutine> findByUserIdAndDeletedAtIsNullAndHistoryStartDateTimeBeforeAndHistoryEndDateTimeGreaterThanEqualAndChangedRoutineDateBetween(
2525
UUID userId,
2626
LocalDateTime now1,
2727
LocalDateTime now2,

src/main/java/bitnagil/bitnagil_backend/changedRoutine/repository/ChangedSubRoutineRepository.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public interface ChangedSubRoutineRepository extends JpaRepository<ChangedSubRou
1818
* 현재 시점을 기준으로 살아있는 변경 서브루틴 이력을 조회
1919
* historyStartDateTime < systime <= historyEndDateTime
2020
*/
21-
List<ChangedSubRoutine> findByChangedRoutineIdAndHistoryStartDateTimeBeforeAndHistoryEndDateTimeGreaterThanEqual(
21+
List<ChangedSubRoutine> findByChangedRoutineIdAndDeletedAtIsNullAndHistoryStartDateTimeBeforeAndHistoryEndDateTimeGreaterThanEqual(
2222
UUID changedRoutineId,
2323
LocalDateTime now1,
2424
LocalDateTime now2

src/main/java/bitnagil/bitnagil_backend/routine/repository/RoutineCompletionRepository.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
package bitnagil.bitnagil_backend.routine.repository;
22

3-
import java.util.Optional;
43
import java.util.UUID;
54

65
import org.springframework.data.jpa.repository.JpaRepository;
@@ -11,6 +10,6 @@
1110

1211
public interface RoutineCompletionRepository extends JpaRepository<RoutineCompletion, HistoryPk> {
1312

14-
Optional<RoutineCompletion> findByRoutineIdAndRoutineHistorySeqAndRoutineType(
13+
RoutineCompletion findByRoutineIdAndRoutineHistorySeqAndRoutineType(
1514
UUID routineId, Long routineHistorySeq, RoutineType routineType);
1615
}

src/main/java/bitnagil/bitnagil_backend/routine/repository/RoutineRepository.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,15 @@ Optional<Routine> findByRoutinePk_IdAndHistoryStartDateTimeLessThanAndHistoryEnd
2626
* 현재 시점을 기준으로 유저의 살아있는 루틴 이력을 조회
2727
* historyStartDate < systime <= historyEndDate
2828
*/
29-
List<Routine> findByUserIdAndHistoryStartDateTimeBeforeAndHistoryEndDateTimeGreaterThanEqual(
29+
List<Routine> findByUserIdAndDeletedAtIsNullAndHistoryStartDateTimeBeforeAndHistoryEndDateTimeGreaterThanEqual(
3030
UUID userId,
3131
LocalDateTime now1,
3232
LocalDateTime now2
3333
);
34+
35+
List<Routine> findByUserIdAndDeletedAtIsNullAndHistoryStartDateTimeLessThanEqualAndHistoryEndDateTimeGreaterThanEqual(
36+
UUID userId,
37+
LocalDateTime endDateTime,
38+
LocalDateTime startDateTime
39+
);
3440
}

src/main/java/bitnagil/bitnagil_backend/routine/repository/SubRoutineRepository.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ Optional<SubRoutine> findBySubRoutinePk_IdAndHistoryStartDateTimeLessThanAndHist
2424
* 현재 시점을 기준으로 살아있는 서브루틴 이력을 조회
2525
* historyStartDateTime < systime <= historyEndDateTime
2626
*/
27-
List<SubRoutine> findByRoutineIdAndHistoryStartDateTimeBeforeAndHistoryEndDateTimeGreaterThanEqual(
27+
List<SubRoutine> findByRoutineIdAndDeletedAtIsNullAndHistoryStartDateTimeBeforeAndHistoryEndDateTimeGreaterThanEqual(
2828
UUID routineId,
2929
LocalDateTime now1,
3030
LocalDateTime now2
Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
package bitnagil.bitnagil_backend.routine.response;
22

3+
import bitnagil.bitnagil_backend.routine.domain.enums.RoutineType;
34
import io.swagger.v3.oas.annotations.media.Schema;
45
import lombok.AllArgsConstructor;
56
import lombok.Builder;
67
import lombok.Getter;
78

9+
import java.time.DayOfWeek;
810
import java.time.LocalTime;
911
import java.util.List;
1012
import java.util.UUID;
@@ -13,16 +15,21 @@
1315
@AllArgsConstructor
1416
@Builder
1517
public class RoutineSearchResultDto {
16-
@Schema(example = "1")
18+
@Schema(example = "046259d9-352a-4fd3-9855-c4539fb19242")
1719
private UUID routineId; // 루틴 ID
20+
@Schema(example = "1")
21+
private Long historySeq; // 루틴 이력 시퀀스
1822
@Schema(example = "물마시기")
1923
private String routineName; // 루틴 이름
20-
// todo: 완료여부 추가
24+
@Schema(example = "[MONDAY, WEDNESDAY, FRIDAY]")
25+
private List<DayOfWeek> repeatDay; // 반복 요일
2126
@Schema(example = "08:30:00")
2227
private LocalTime executionTime; // 루틴 실행 시간
2328
private List<SubRoutineSearchResultDto> subRoutineSearchResultDto; // 서브루틴 목록
2429
@Schema(example = "false")
2530
private Boolean modifiedYn; // 수정 여부
2631
@Schema(example = "false", description = "true: 완료, false: 미완료 (default는 false)")
2732
private Boolean completeYn; // 완료 여부 (true: 완료, false: 미완료)
33+
@Schema(example = "ROUTINE", description = "루틴 구분을 위한 타입. 추후 루틴 완료 처리시 해당값을 그대로 전달")
34+
private RoutineType routineType; // 루틴 타입 (ROUTINE, SUB_ROUTINE, CHANGED_ROUTINE, CHANGED_SUB_ROUTINE)
2835
}

src/main/java/bitnagil/bitnagil_backend/routine/response/SubRoutineSearchResultDto.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package bitnagil.bitnagil_backend.routine.response;
22

3+
import bitnagil.bitnagil_backend.routine.domain.enums.RoutineType;
34
import io.swagger.v3.oas.annotations.media.Schema;
45
import lombok.AllArgsConstructor;
56
import lombok.Builder;
@@ -11,8 +12,10 @@
1112
@AllArgsConstructor
1213
@Builder
1314
public class SubRoutineSearchResultDto {
14-
@Schema(example = "1")
15+
@Schema(example = "046259d9-352a-4fd3-9855-c4539fb19242")
1516
private UUID subRoutineId; // 서브 루틴 ID
17+
@Schema(example = "1")
18+
private Long historySeq;
1619
@Schema(example = "물 10초만에 마시기")
1720
private String subRoutineName; // 서브 루틴 이름
1821
@Schema(example = "false")
@@ -21,4 +24,6 @@ public class SubRoutineSearchResultDto {
2124
private Integer sortOrder; // 정렬 순서
2225
@Schema(example = "false", description = "true: 완료, false: 미완료 (default는 false)")
2326
private Boolean completeYn; // 완료 여부 (true: 완료, false: 미완료)
27+
@Schema(example = "SUB_ROUTINE", description = "루틴 구분을 위한 타입. 추후 루틴 완료 처리시 해당값을 그대로 전달")
28+
private RoutineType routineType; // 루틴 타입 (ROUTINE, SUB_ROUTINE, CHANGED_ROUTINE, CHANGED_SUB_ROUTINE)
2429
}

0 commit comments

Comments
 (0)