Skip to content

Commit 574504e

Browse files
committed
feat: 루틴 완료 여부 갱신 서비스 로직 추가
1 parent bdc67c9 commit 574504e

4 files changed

Lines changed: 70 additions & 0 deletions

File tree

src/main/java/bitnagil/bitnagil_backend/routineV2/domain/RoutineV2.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,4 +63,10 @@ public RoutineV2(LocalDate routineDate, Boolean routineCompleteYn, List<String>
6363
this.subRoutineCompleteYn = subRoutineCompleteYn;
6464
this.routineInfo = routineInfo;
6565
}
66+
67+
// 루틴 완료 여부 갱신
68+
public void updateRoutineCompleteYn(Boolean routineCompleteYn, List<Boolean> subRoutineCompleteYn) {
69+
this.routineCompleteYn = routineCompleteYn;
70+
this.subRoutineCompleteYn = subRoutineCompleteYn;
71+
}
6672
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
package bitnagil.bitnagil_backend.routineV2.request;
2+
3+
import java.util.List;
4+
5+
import io.swagger.v3.oas.annotations.media.Schema;
6+
import jakarta.validation.constraints.NotNull;
7+
import lombok.Getter;
8+
import lombok.NoArgsConstructor;
9+
10+
@Getter
11+
@NoArgsConstructor
12+
public class UpdateRoutineCompletionInfo {
13+
14+
@Schema(description = "루틴 완료 여부를 갱신할 루틴 ID 값입니다.",
15+
example = "4",
16+
required = true)
17+
@NotNull
18+
private Long routineId;
19+
20+
@Schema(description = "메인 루틴의 완료 여부입니다.",
21+
example = "true",
22+
required = true)
23+
@NotNull
24+
private Boolean routineCompleteYn;
25+
26+
@Schema(description = "서브루틴 완료 여부 리스트입니다..",
27+
example = "[true, false, true]",
28+
required = true)
29+
@NotNull
30+
private List<Boolean> subRoutineCompleteYn;
31+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
package bitnagil.bitnagil_backend.routineV2.request;
2+
3+
import java.util.List;
4+
5+
import io.swagger.v3.oas.annotations.media.Schema;
6+
import jakarta.validation.constraints.NotNull;
7+
import lombok.Getter;
8+
import lombok.NoArgsConstructor;
9+
10+
@Getter
11+
@NoArgsConstructor
12+
@Schema(description = "루틴 완료 여부 갱신 DTO")
13+
public class UpdateRoutineCompletionRequest {
14+
15+
@Schema(description = "루틴 완료 여부를 갱신할 루틴 정보 리스트입니다.",
16+
required = true)
17+
@NotNull
18+
List<UpdateRoutineCompletionInfo> routineCompletionInfos;
19+
}

src/main/java/bitnagil/bitnagil_backend/routineV2/service/RoutineV2Service.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66

77
import bitnagil.bitnagil_backend.global.errorcode.ErrorCode;
88
import bitnagil.bitnagil_backend.global.exception.CustomException;
9+
import bitnagil.bitnagil_backend.routineV2.request.UpdateRoutineCompletionInfo;
10+
import bitnagil.bitnagil_backend.routineV2.request.UpdateRoutineCompletionRequest;
911
import bitnagil.bitnagil_backend.routineV2.response.RoutineV2SearchResponse;
1012
import bitnagil.bitnagil_backend.routineV2.response.RoutineV2SearchResultDto;
1113
import org.springframework.stereotype.Service;
@@ -101,6 +103,18 @@ public void registerRoutineV2(User user, RegisterRoutineV2Request request) {
101103
routineV2Repository.saveAll(routinesToRegister);
102104
}
103105

106+
// 루틴 완료 여부를 업데이트 하는 메서드
107+
@Transactional
108+
public void updateRoutineCompletionStatus(User user, UpdateRoutineCompletionRequest request) {
109+
for (UpdateRoutineCompletionInfo info : request.getRoutineCompletionInfos()) {
110+
RoutineV2 routineV2 = routineV2Repository.findByUserAndRoutineId(user, info.getRoutineId())
111+
.orElseThrow(() -> new CustomException(ErrorCode.NOT_FOUND_ROUTINE));
112+
113+
// 루틴, 서브루틴 완료 여부 갱신
114+
routineV2.updateRoutineCompleteYn(info.getRoutineCompleteYn(), info.getSubRoutineCompleteYn());
115+
}
116+
}
117+
104118
/**
105119
* 날짜 범위에서 주어진 요일(repeatDays)에 해당하는 날짜만 반환
106120
*/

0 commit comments

Comments
 (0)