Skip to content
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

Merged
merged 8 commits into from
Nov 22, 2024
Merged

[Feat] Our Shoot 조회 API 구현 #67

merged 8 commits into from
Nov 22, 2024

Conversation

cowboysj
Copy link
Member

#️⃣ 관련 이슈

💡 작업내용

쿼리 파라미터 tab으로 구별해 Our shoot을 조회하는 API 구현

  • Shoot 상태(yet, doing, done) 받아 반환
  • mentioned면 내가 태그된 슛 반환
  • Querydsl로 구현하였습니다.

📸 스크린샷(선택)

📝 기타

(참고사항, 리뷰어에게 전하고 싶은 말 등을 넣어주세요)

@cowboysj cowboysj linked an issue Nov 20, 2024 that may be closed by this pull request
1 task
@cowboysj cowboysj added the ✨ feature 기능 구현 label Nov 20, 2024
@cowboysj cowboysj requested a review from iiqcov November 20, 2024 18:22
@cowboysj cowboysj self-assigned this Nov 20, 2024
Copy link
Contributor

@iiqcov iiqcov left a 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);
}
Copy link
Contributor

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);
...

이런식으로요!

Copy link
Member Author

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);
    }

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

object-mapping 방식은 저도 처음 본 방식이네요! 너무 좋은 방법인 것 같습니다 👍 👍 다음에 저도 적용해봐야겠어요~
수고하셨습니다!!

@cowboysj cowboysj requested a review from iiqcov November 21, 2024 17:02
@cowboysj cowboysj merged commit 93b4a75 into develop Nov 22, 2024
2 checks passed
@iiqcov iiqcov deleted the feat/#65 branch November 23, 2024 12:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
✨ feature 기능 구현
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Feat] OUR SHOOT 조회 구현
2 participants