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

내 경로 조회, 수정, 삭제 API 구현 완료 #30

Merged
merged 12 commits into from
Oct 29, 2024

Conversation

gywns0417
Copy link
Contributor

@gywns0417 gywns0417 commented Oct 29, 2024

💡 작업 내용

  • 내 경로 조회, 수정, 삭제 API 구현
  • 경로 상세조회 API 구현

💡 자세한 설명

postman 테스트 완료

경로 생성 시, Route-RouteSpot은 서로 참조 관계에 있습니다.
따라서 우선 Route 엔티티를 routeSpots 필드를 null인 상태로 생성 후, initRouteSpots() 메서드를 통해 생성한 RouteSpot 엔티티들을 할당시켜 줍니다.

public void createRoute(CreateRouteRequest createRouteRequest, ApiMember apiMember) {
        Member member = apiMember.toMember(memberRepository);

        String routeName = createRouteRequest.getRouteName();
        List<Long> spotIds = createRouteRequest.getRouteSpots();
        List<Spot> spots = spotRepository.findAllById(spotIds);

        validateRouteName(routeName, member);
        validateRouteSpot(spotIds);

        Route route = createRouteRequest.toEntity(member);
        routeRepository.save(route);

        List<RouteSpot> routeSpots = spots.stream()
                .map(spot -> CreateRouteSpotRequest.toEntity(spot, route))
                .toList();

        route.initRouteSpots(routeSpots);
    }

또한 Route의 이름과 관광지 수정 처리는 해당 엔티티 내부에서 이뤄지게 만들었습니다. (캡슐화, 응집도, 객체 자율성 상승)

📗 참고 자료 (선택)

📢 리뷰 요구 사항 (선택)

🚩 후속 작업 (선택)

✅ 셀프 체크리스트

  • PR 제목을 형식에 맞게 작성했나요?
  • 브랜치 전략에 맞는 브랜치에 PR을 올리고 있나요? (master/main이 아닙니다.)
  • 이슈는 close 했나요?
  • Reviewers, Labels, Projects를 등록했나요?
  • 작업 도중 문서 수정이 필요한 경우 잘 수정했나요?
  • 테스트는 잘 통과했나요?
  • 불필요한 코드는 제거했나요?

closes #26

@gywns0417 gywns0417 added the ✨ feature 구현, 개선 사항 관련 부분 label Oct 29, 2024
@gywns0417 gywns0417 self-assigned this Oct 29, 2024
@gywns0417 gywns0417 merged commit 30b6d34 into main Oct 29, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
✨ feature 구현, 개선 사항 관련 부분
Projects
Status: No status
Development

Successfully merging this pull request may close these issues.

경로 만들기 기능 구현
1 participant