데이터베이스 상에 column matchedYoil제거, nungilentity 상에 matchedYoil삭제, update메서드 파라미터에서 yoil삭제, update메서드 수정에 따라 matchNungil메서드 상에 update 구문 수정
mysql
alter table nungil drop column matched_yoil;
nungil.java
public MatchYoilAndTimeResponse findCommonYoil(Member member1, Member member2) {
,,,,
for (Yoil yoil : list2) {
if (set1.contains(yoil.getDayOfWeek())) {
if (isAfter11AM) {
return findNextYoil(yoil, now, set1);
} else {
//해당 부분을 통해 `matchYoil`에 해당되는 날짜를 계산
int offset = (7+yoil.getDayOfWeek().getValue()-now.getDayOfWeek().getValue())%7;
return new MatchYoilAndTimeResponse(yoil, LocalDate.now().plusDays(offset));
}
}
}
return null;
}
findNextYoil.java
private MatchYoilAndTimeResponse findNextYoil(Yoil yoil, LocalDateTime now, Set<DayOfWeek> availableDays) {
DayOfWeek today = now.getDayOfWeek();
int offset = 0;
DayOfWeek nextDay = today;
do {
offset++;
nextDay = DayOfWeek.of((today.getValue() + offset - 1) % 7 + 1); // 요일을 순환
} while (!availableDays.contains(nextDay)); // 다음 사용 가능한 요일을 찾을 때까지 반복
for (Yoil nextYoil : Yoil.values()) {
if (nextYoil.getDayOfWeek().equals(nextDay)) {
//해당 부분을 통해 `matchYoil`에 해당되는 날짜를 계산
return new MatchYoilAndTimeResponse(nextYoil, LocalDate.now().plusDays(offset));
}
}
//해당 부분을 통해 `matchYoil`에 해당되는 날짜를 계산
return new MatchYoilAndTimeResponse(yoil, LocalDate.now().plusDays(offset));
}
- `NungilMatchResponse` 필드 추가, create 메서드 파라미터 수정
- `NungilMatchResponse` 변경에 따라 `getMatchedNungil ` 수정
## ☀ 스크린샷 / GIF / 화면 녹화
case 1 ) 매칭되는 요일이 없을 때
![image](https://github.com/Igloo-Club/Igloo-Club-BE/assets/106146847/715df40b-9f36-4b4d-8a3c-60d426b11010)
case 2 ) 오늘이 아닌 매칭되는 요일이 존재할 때
![image](https://github.com/Igloo-Club/Igloo-Club-BE/assets/106146847/1053483a-c511-486b-b03a-4c1e35b8ffc7)
case 3 ) 11시 이후에 매칭되는 요일이 존재하며 해당 요일이 오늘일 때(현재 요일 일요일, 매칭되는 요일은 일요일/월요일)
![image](https://github.com/Igloo-Club/Igloo-Club-BE/assets/106146847/368bf318-2c2b-4f04-9c18-723921983d18)
🔥 Related Issues
💜 작업 내용
✅ PR Point
matchedYoil
제거,nungil
entity 상에matchedYoil
삭제,update
메서드 파라미터에서yoil
삭제,update
메서드 수정에 따라matchNungil
메서드 상에 update 구문 수정 mysqlalter table nungil drop column matched_yoil;
nungil.javamatchNungil
@Getter @AllArgsConstructor @Builder public class MatchYoilAndTimeResponse { private Yoil matchYoil;
}
public class NungilMatchResponse {
}
User java.lang.NullPointerException: Cannot invoke "com.iglooclub.nungil.dto.MatchYoilAndTimeResponse.getMatchYoil()" because "response" is null
Yoil matchYoil = (response != null) ? response.getMatchYoil() : null; LocalDate matchDate = (response != null) ? response.getMatchDate() : null;