Skip to content

6주차 미션 [루크]#11

Open
yujining3827 wants to merge 46 commits into
mainfrom
luke/week6
Open

6주차 미션 [루크]#11
yujining3827 wants to merge 46 commits into
mainfrom
luke/week6

Conversation

@yujining3827
Copy link
Copy Markdown
Collaborator

🚩 관련 이슈



📌 구현 결과

마이페이지 조회 API 구현

  • GET /members/home/my
  • memberId를 기반으로 사용자 정보 조회하도록 memberId params 추가
  • 사용자 이름, 이메일, 포인트 반환

실행 결과

image

리뷰 작성 API 구현

  • POST /review/markets/{marketId}
  • memberId와 marketId를 기반으로 리뷰 작성 기능 구현
  • 리뷰 저장 후 reviewId 및 성공 메시지 반환

실행 결과

image

진행중 / 완료 미션 조회 API 구현

  • GET /mission
  • memberId와 ParticipatedStatus(CHALLENGING / COMPLETE)를 기반으로 참여 미션 목록 조회
  • Pageable 기반 페이징 처리 구현
  • @query + JOIN FETCH를 사용하여 Mission 연관 데이터 조회
@Query(""" 
SELECT p 
FROM Participate p J
OIN FETCH p.mission m 
WHERE p.member.id = :memberId 
AND p.status = :status """)

실행 결과

image

홈 화면 지역별 진행 중인 미션 조회 API 구현

  • GET /mission/home
  • regionName 기반으로 특정 지역의 진행중(IN_PROGRESS) 미션 목록 조회
  • Pageable 기반 페이징 처리 구현
  • @query + JOIN FETCH를 사용하여 Market, Region 연관 데이터 조회
@Query(""" 
SELECT m F
ROM Mission m 
JOIN FETCH m.market mk 
JOIN FETCH mk.region r WHERE r.name = :regionName AND m.missionStatus = :status """)

실행결과

image



❓ 리뷰 요청

🤔 질문

💬 기타 공유 사항

@ochyeon
Copy link
Copy Markdown
Collaborator

ochyeon commented May 7, 2026

수고하셨습니다!

Copy link
Copy Markdown
Collaborator

@ywkim1m ywkim1m left a comment

Choose a reason for hiding this comment

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

코드가 일관성 있고 좋아요!!

@KateteDeveloper
Copy link
Copy Markdown
Collaborator

일관성 있고 좋습니다~! 수고하셨습니다:)

Copy link
Copy Markdown
Member

@yangjiae12 yangjiae12 left a comment

Choose a reason for hiding this comment

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

수고하셨습니다~

Comment on lines +22 to +28
return MemberResDTO.MyPageDTO.builder()
.nickname(member.getName())
.email(member.getEmail())
.phoneNumber(member.getPhoneNumber())
.phoneNumberStatus(member.getPhoneNumberStatus())
.userPoint(member.getUserPoint())
.build();
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

dto 변환 로직을 MemberConverter로 분리하여 서비스 레이어는 비즈니스 로직에만 집중할 수 있도록 개선하면 좋을 것 같습니다

public MemberResDTO.MyPageDTO getMyPage(Long memberId) {

Member member = memberRepository.findById(memberId)
.orElseThrow(() -> new RuntimeException("멤버가 존재하지 않습니다."));
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

커스텀 익셉션 사용하도록 수정하면 좋을 것 같습니다

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

현재 getMissionList와 getHomeMissionList 내부에 데이터를 DTO로 변환하는 매핑 로직이 길게 포함되어 있습니다. 프로젝트의 일관성을 위해 매핑 책임은 MissionConverter로 위임하고, 서비스는 비즈니스 흐름을 제어하는 데 집중하면 가독성이 훨씬 좋아질 것 같습니다!


Pageable pageable = PageRequest.of(page, size);

Page<Participate> participatePage =
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

응답 DTO에서 전체 페이지 수가 아닌 hasNext 여부만 사용하고 있기 때문에 전체 카운트 쿼리가 나가는 Page 대신 다음 페이지 존재 여부만 확인하는 Slice를 활용하면 성능을 높일 수 있습니다~

Comment on lines +9 to +18
@Getter
@Builder
@AllArgsConstructor
@NoArgsConstructor
public static class MissionListDTO {
public List<MissionDTO> content;
public Integer page;
public Integer size;
public Boolean hasNext;
}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

지금처럼 페이징이 필요할 때 도메인마다 MissionListDTO 등을 따로 만들면 중복 코드가 발생하기 때문에 공통 페이징 DTO를 정의하면 좋을 것 같습니다


@Service
@RequiredArgsConstructor
@Transactional
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

생성 로직에는 적절하지만, 나중에 추가될 조회 메서드들을 고려하여 클래스 전체에는 @transactional(readOnly = true)를 설정하고, 생성이 발생하는 메서드에만 @transactional을 개별 선언하는 방식이 성능 및 안정성 측면에서 권장됩니다.

Comment on lines +30 to +34
Member member = memberRepository.findById(memberId)
.orElseThrow(() -> new RuntimeException("멤버가 존재하지 않습니다."));

Market market = marketRepository.findById(marketId)
.orElseThrow(() -> new RuntimeException("가게가 존재하지 않습니다."));
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

여기도 커스텀 익셉션 적용해주세요

Comment on lines +36 to +48
Review review = Review.builder()
.member(member)
.market(market)
.stars(request.getStars())
.content(request.getContent())
.build();

Review savedReview = reviewRepository.save(review);

return ReviewResDTO.CreateReviewDTO.builder()
.reviewId(savedReview.getId())
.message("리뷰 작성 완료!")
.build();
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

ReviewConverter로 분리해주세요!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants