Skip to content

Commit 3f5b364

Browse files
committed
fix: 상태 예약시간 무한값 변환 오류 수정
- durationSeconds가 무기한을 의미하는 값(약 100년 = 3,153,600,000초)일 때 기존 로직에서 시,분 단위로 변환되지 못하는 문제 수정 - 무기한일 경우 시,분 대신 프론트와 무한으로 정한 컨벤션인 (-1, -1)로 변환되도록 처리 - Long -> Duration -> Long 으로 불필요한 변환 작업이 이루어져 단순화
1 parent 6637801 commit 3f5b364

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/main/java/com/example/wini/domain/member/service/MemberService.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
package com.example.wini.domain.member.service;
22

3+
import static com.example.wini.global.common.constant.StatusReserveTimeConstants.INDEFINITE_HOUR;
4+
import static com.example.wini.global.common.constant.StatusReserveTimeConstants.INDEFINITE_MINUTE;
5+
import static com.example.wini.global.common.constant.StatusReserveTimeConstants.INDEFINITE_SECONDS;
36
import static com.example.wini.global.error.exception.ErrorCode.MATE_NOT_FOUND;
47
import static com.example.wini.global.error.exception.ErrorCode.STATUS_NOT_FOUND;
58

@@ -72,6 +75,10 @@ private boolean isStatusValid(Member member) {
7275
}
7376

7477
private ReservedTimeInfo createReservedTimeInfo(long durationSeconds) {
78+
if (durationSeconds == INDEFINITE_SECONDS) {
79+
return ReservedTimeInfo.of(INDEFINITE_HOUR, INDEFINITE_MINUTE);
80+
}
81+
7582
Duration duration = Duration.ofSeconds(durationSeconds);
7683
return ReservedTimeInfo.of(duration.toHours(), duration.toMinutes() % 60);
7784
}
@@ -83,8 +90,7 @@ public MemberStatusResponse updateStatus(MemberStatusUpdateRequest request) {
8390
Status status =
8491
statusRepository.findById(request.statusId()).orElseThrow(() -> new CustomException(STATUS_NOT_FOUND));
8592

86-
Duration statusDuration = request.reservedTimeInfo().toDuration();
87-
Long statusDurationSeconds = statusDuration.getSeconds();
93+
Long statusDurationSeconds = request.reservedTimeInfo().toSeconds();
8894

8995
member.updateStatus(status, request.startedAt(), statusDurationSeconds);
9096
notifyRoommateOfStatusUpdate(member.getId());

0 commit comments

Comments
 (0)