Skip to content

Conversation

@7ijin01
Copy link
Member

@7ijin01 7ijin01 commented Jul 20, 2025

📌 PR 개요

  • 기존 DB에 저장된 관광지를 기준으로, 연관된 관광지 5개씩 저장하는 기능 추가

✅ 변경사항

  • TourSpotAssociated 추상 클래스를 기반으로 연관 관광지 엔티티 구조 설계
  • 연관관광지 api 호출
  • Mapper 로직 활용 엔티티 변환

🔍 체크리스트

  • PR 제목은 명확한가요?
  • 관련 이슈가 있다면 연결했나요?
  • 로컬 테스트는 통과했나요?
  • 코드에 불필요한 부분은 없나요?

📎 관련 이슈

Closes #30


💬 기타 참고사항

  • 현재 연관관광지 api를 호출 후 수신 받은 관광지가 tourSpot db에 존재해야 연관관광지에 추가하는 방식임
    -> 따라서 관광지 5개를 모두 저장하려면
  1. 관광지를 사전에 수동으로 등록/관리하거나
  2. api 호출 시 DB에 없을 경우 자동 추가하는 로직 도입 필요

Summary by CodeRabbit

  • 신규 기능

    • 관광지 간 연관 관계를 관리하는 기능이 추가되었습니다.
    • 외부 공공 API를 통해 연관 관광지 정보를 비동기로 조회하고 저장할 수 있습니다.
  • 버그 수정 및 개선

    • 기존에 사용하지 않던 엔드포인트가 제거되었습니다.
    • 오류 상태에 "해당 관광지가 존재하지 않습니다" 메시지가 추가되었습니다.
  • 기타

    • 관련 저장소 및 매퍼, 서비스가 추가되어 연관 관광지 데이터 처리 및 관리가 향상되었습니다.

@7ijin01 7ijin01 requested a review from kamillcream July 20, 2025 12:23
@7ijin01 7ijin01 linked an issue Jul 20, 2025 that may be closed by this pull request
@coderabbitai
Copy link

coderabbitai bot commented Jul 20, 2025

Caution

Review failed

An error occurred during the review process. Please try again later.

Walkthrough

관광지 연관관광지 정보를 저장하기 위한 신규 기능이 대규모로 추가되었습니다. 연관관광지 DTO, 엔티티, 매퍼, 서비스, 저장 로직 및 관련 저장소가 도입되었으며, 기존 컨트롤러의 불필요한 엔드포인트가 제거되고, 에러 상태가 확장되었습니다. 일부 저장소 인터페이스와 패키지 구조도 정비되었습니다.

Changes

파일/경로 요약 변경 요약
.../dto/TourSpotRelatedDto.java 연관관광지 응답 구조를 위한 DTO 클래스 및 중첩 클래스 추가
.../entity/TourSpotRelated.java 연관관광지 JPA 엔티티 신설, TourSpot과 다대일 관계 및 기본키 필드 등 추가
.../entity/TourSpot.java relatedSpots 필드 및 관련 컬렉션 관리 메서드 2개 추가
.../mapper/TourSpotRelatedMapper.java MapStruct 기반 연관관광지 매퍼 인터페이스 및 AfterMapping 메서드 추가
.../repository/TourSpotRelatedRepository.java 연관관광지 JPA 저장소 인터페이스 신설, 커스텀 저장소 인터페이스 상속
.../repository/custom/CustomTourSpotRelatedRepository.java
...Impl.java
커스텀 연관관광지 저장소 인터페이스 및 구현체(내용 없음) 추가
.../repository/MonthlyCongestionRepository.java CustomMonthlyCongestionRepository 상속 추가, 불필요한 import 제거
.../repository/custom/CustomMonthlyCongestionRepository.java
...Impl.java
패키지 경로 변경(기능 변화 없음)
.../service/TourSpotRelatedService.java 외부 API로부터 연관관광지 비동기 조회 서비스 클래스 및 fetch 메서드 추가
.../service/TourSpotService.java saveRelatedTourspot() 메서드 및 관련 의존성 필드 추가, 연관관광지 저장 전체 로직 구현
.../controller/TourSpotController.java getOrganArea 엔드포인트(메서드) 삭제
.../response/status/ErrorStatus.java TOURSPOT_NOT_FOUND 에러 상태 상수 추가

Sequence Diagram(s)

sequenceDiagram
    participant TourSpotService
    participant AddressCache
    participant TourSpotRelatedService
    participant TourSpotRepository
    participant TourSpotRelatedMapper
    participant TourSpotRelatedRepository

    TourSpotService->>AddressCache: getAllAddress()
    loop 각 address
        TourSpotService->>TourSpotRelatedService: fetchRelatedTourSpotData(areaId, tourSpotName)
        TourSpotRelatedService->>API: GET 연관관광지 외부 API
        API-->>TourSpotRelatedService: JSON 응답
        TourSpotRelatedService-->>TourSpotService: CompletableFuture<TourSpotRelatedDto>
    end
    TourSpotService->>TourSpotRepository: findByName(관광지명)
    loop 각 연관관광지명
        TourSpotService->>TourSpotRepository: findByName(연관관광지명)
        TourSpotService->>TourSpotRelatedMapper: toEntity(현관광지, 연관관광지)
    end
    TourSpotService->>TourSpot: updateTourSpotRelated(연관관광지목록)
    TourSpotService->>TourSpotRepository: save(관광지)
Loading

Estimated code review effort

4 (~90분)

Suggested labels

enhancement

Poem

🐇
새로운 연관관광지, 토끼도 신나네!
API에서 받아와, DB에 쏙쏙 저장해.
매퍼와 서비스, 저장소도 줄지어 등장,
관광지 친구들, 이제 더 풍성해졌네.
리뷰어님, 힘내세요—코드는 깔끔하게!
🗺️✨


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

7ijin01 added 3 commits July 22, 2025 09:53
# Conflicts:
#	src/main/java/com/opendata/domain/tourspot/service/TourSpotService.java
Comment on lines -29 to -34
@GetMapping("/organ")
public ResponseEntity<List<Void>> getOrganArea()
{
tourSpotService.fetchAllOrganTourSpotAndSave();
return ResponseEntity.ok().build();
}
Copy link
Contributor

Choose a reason for hiding this comment

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

ApiResponse 사용

Copy link
Member Author

Choose a reason for hiding this comment

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

요거 지웠음

Copy link
Contributor

Choose a reason for hiding this comment

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

아 그렇네 ㅇㅋㅇㅋ

Comment on lines -29 to -34
@GetMapping("/organ")
public ResponseEntity<List<Void>> getOrganArea()
{
tourSpotService.fetchAllOrganTourSpotAndSave();
return ResponseEntity.ok().build();
}
Copy link
Contributor

Choose a reason for hiding this comment

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

아 그렇네 ㅇㅋㅇㅋ

@7ijin01 7ijin01 merged commit 039d1a0 into main Jul 22, 2025
2 checks passed
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.

[feat] 공사 api 관광지 연관관광지 정보 저장

3 participants