-
Notifications
You must be signed in to change notification settings - Fork 0
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
[Feat] Our Shoot 조회 API 구현 #67
Conversation
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.
수고하셨습니다!!
return getMentionedShoot(figma); | ||
} else { | ||
throw new CustomException(ErrorCode.INVALID_TAB); | ||
} |
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.
이 부분을 스위치문으로 변경하면 가독성이 더 좋아질 것 같은데 혹시 if-else문으로 작성한 이유가 있을까요?
return switch (tab) {
case YET -> getShootByStatus(figma, Status.YET);
...
이런식으로요!
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.
switch문은 지양해야 한다는 글을 봤었어서 사용하지 않았었는데, 다시 찾아보니 그 의미는 switch문 대신 if-else문을 쓰라는 게 아니라 OCP 원칙에 위배되지 않게 작성하라는 거였네요..!
이 블로그 글 참고해서 object-mapping 방식으로 바꿔봤습니다..!
@Transactional(readOnly = true)
public List<GetOurShootResponse> getOurShoot(String tab) {
final Figma figma = figmaUtil.getCurrentFigma();
if (tab == null || tab.isBlank()) {
tab = YET;
}
Map<String, Function<Figma, List<GetOurShootResponse>>> tabMapping = Map.of(
YET, f -> getShootByStatus(f, Status.YET),
DOING, f -> getShootByStatus(f, Status.DOING),
DONE, f -> getShootByStatus(f, Status.DONE),
MENTIONED, this::getMentionedShoot
);
return tabMapping.getOrDefault(tab, f -> {
throw new CustomException(ErrorCode.INVALID_TAB);
}).apply(figma);
}
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.
object-mapping 방식은 저도 처음 본 방식이네요! 너무 좋은 방법인 것 같습니다 👍 👍 다음에 저도 적용해봐야겠어요~
수고하셨습니다!!
|
#️⃣ 관련 이슈
💡 작업내용
쿼리 파라미터 tab으로 구별해 Our shoot을 조회하는 API 구현
📸 스크린샷(선택)
📝 기타
(참고사항, 리뷰어에게 전하고 싶은 말 등을 넣어주세요)