-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Be/fix] 특정 날짜의 식사 정보 조회하는 API 오류 수정 #427
Conversation
…pl 메서드 수정으로 인한 변경사항 반영
.where( | ||
historyEntity | ||
.memberEntity | ||
.id | ||
.eq(memberId) | ||
.and(checkFutureDate(historyEntity, date))) | ||
.orderBy(historyEntity.createdDate.asc()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
정렬도 pk로 정렬하는게 가장 빠른 것으로 알고있는데 Id GeneratorType을 AutoIncrement로 안했을 경우를 대비하여 createdDate로 정렬한건가요?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PK로 정렬하는 게 더 빠르네요. 반영하겠습니다.
@RequiredArgsConstructor | ||
public class ValidateBeforeSignupService implements ValidateBeforeSignUpUsecase { | ||
|
||
private final MemberPersistenceAdapter memberPersistenceAdapter; | ||
|
||
@Override | ||
public void execute(Long memberId, LocalDateTime dateTime) { | ||
MemberEntity memberEntity = memberPersistenceAdapter.query(memberId); | ||
if (memberEntity.checkIfBeforeSignUp(dateTime)) { | ||
throw InValidDateFoundException.EXECPTION; | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
이 유효성 검증은 왜 서비스로 따로 뺴셨나요? POJO 도메인안에 메서드로 작성하자고 하지 않았나용?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
MemberEntity의 updatedAt을 이용해서 해당 날짜가 회원가입 전이란 것을 알려주는 것 (checkIfBeforeSignUp 메서드) 까지는 MemberEntity에서 하는 것이라 생각했고, InValidDateFoundException 예외를 터뜨리는 것은 켈린더 상세 조회 서비스의 책임이라고 생각했습니다.
void findMostRecentFutureMember() { | ||
LocalDateTime dateTime = LocalDateTime.of(2023, 12, 04, 12, 00); | ||
HistoryEntity historyEntity = | ||
customHistoryRepository.findMostRecentFutureMember(1L, dateTime); | ||
assertEquals(historyEntity.getWeight(), 72.0); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
왜 여기 메서드 이름은 when_~~ 으로 하지 않았나요?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
으악 감사합니다.
📌 관련 이슈
#425
🔑 주요 변경사항
켈린더 상세 조회시 해당 회원의 상태는 특정 날짜에 따라 달라져야 한다. 따라서, 특정 날짜 기준으로 MemberEntity의 updatedAt 필드가 그 전에 있을 경우 MemberEntity에 저장된 회원 정보를 사용한다.
그리고, 특정 날짜 기준으로 MemberEntity updated 필드가 그 이후에 있다면 과거 변경 이력이 있다는 뜻으로 HistoryEntity를 확인하다.
이때, HistoryEntity의 경우 특정 날짜를 기준으로 미래중 가장 가까운 기록을 사용한다.
CustomMemberRepositoryImpl 클래스, CustomHistoryRepositoryImpl 클래스 쿼리 테스트 수행
회원가입한 날짜보다 전의 켈린더 조회하는 경우 Validate하는 ValidateBeforeSignUpUsecase 개발
특정 날짜의 식사 정보 조회하는 API 통합 테스트 보충 (식사 기록이 없을 경우, 회원가입 되기 전 날짜를 조회한 경우)