Skip to content

[hotfix] 특정 유저 공개 피드 조회 화면 상단 api 수정#145

Merged
seongjunnoh merged 6 commits into
developfrom
hotfix/#141/feeds-get-info-of-user
Aug 5, 2025
Merged

[hotfix] 특정 유저 공개 피드 조회 화면 상단 api 수정#145
seongjunnoh merged 6 commits into
developfrom
hotfix/#141/feeds-get-info-of-user

Conversation

@seongjunnoh

@seongjunnoh seongjunnoh commented Aug 5, 2025

Copy link
Copy Markdown
Collaborator

#️⃣ 연관된 이슈

closes #141

📝 작업 내용

@heeeeyong 님의 요청으로 특정 유저의 공개 피드 목록 조회 시, 해당 화면의 상단 부분을 구성하는 api 를 수정하였습니다
(아래 화면을 구성하는 api 입니다)
image

  • 변경 사항
    • response dto 에 Long creatorId(= 피드 작성자의 id값), boolean isFollowing(= 현재 유저가 해당 피드 작성자를 팔로잉하는지) 를 추가하였습니다
    • creatorId : 피드 작성자의 정보 조회 시에 필요하기 때문, isFollowing : '띱 하기', '띱 취소' 를 표현하기 위함
    • 관련해서 service, 영속성 adapter, query mapper 를 수정하였고, 테스트 코드 또한 수정하였습니다

📸 스크린샷

💬 리뷰 요구사항

📌 PR 진행 시 이러한 점들을 참고해 주세요

* P1 : 꼭 반영해 주세요 (Request Changes) - 이슈가 발생하거나 취약점이 발견되는 케이스 등
* P2 : 반영을 적극적으로 고려해 주시면 좋을 것 같아요 (Comment)
* P3 : 이런 방법도 있을 것 같아요~ 등의 사소한 의견입니다 (Chore)

Summary by CodeRabbit

  • 신규 기능

    • 피드 사용자 정보 조회 API 응답에 'isFollowing'(팔로우 여부)와 'creatorId'(피드 주인 ID) 필드가 추가되었습니다.
    • 피드 사용자 정보 조회 시, 로그인한 사용자가 해당 사용자를 팔로우 중인지 여부가 함께 제공됩니다.
  • 버그 수정

    • 피드 사용자 정보 조회 테스트에서 로그인 사용자 맥락을 반영하도록 개선되었습니다.
  • 테스트

    • 팔로우 여부(isFollowing) 필드와 creatorId 필드 응답값을 검증하는 테스트가 추가되었습니다.
  • 환경설정

    • CORS 허용 도메인에 새로운 웹 도메인(webDomainUrl)이 추가되었습니다.

@coderabbitai

coderabbitai Bot commented Aug 5, 2025

Copy link
Copy Markdown

Caution

Review failed

The pull request is closed.

Walkthrough

특정 유저의 공개 피드 목록 상단 정보 조회 API가 수정되어, 응답에 요청자(로그인 유저)가 해당 피드 소유자를 팔로우하고 있는지 여부(isFollowing)와 피드 소유자 ID(creatorId)가 포함됩니다. 이를 위해 컨트롤러, 서비스, 매퍼, 포트, 어댑터, 레포지토리, DTO, 테스트 코드가 일괄적으로 변경되었습니다.

Changes

Cohort / File(s) Change Summary
컨트롤러 및 API 응답
src/main/java/konkuk/thip/feed/adapter/in/web/FeedQueryController.java, src/main/java/konkuk/thip/feed/adapter/in/web/response/FeedShowUserInfoResponse.java
API 메서드 시그니처를 두 개의 userId(요청자, 피드 소유자)로 변경하고, 응답 DTO에 creatorId, isFollowing 필드를 추가
서비스/유스케이스/매퍼
src/main/java/konkuk/thip/feed/application/service/FeedShowUserInfoService.java, src/main/java/konkuk/thip/feed/application/port/in/FeedShowUserInfoUseCase.java, src/main/java/konkuk/thip/feed/application/mapper/FeedQueryMapper.java
서비스, 유스케이스, 매퍼 메서드 시그니처를 수정하여 팔로잉 여부를 판단 및 전달하도록 변경. 매퍼에서 creatorId, isFollowing 매핑 추가
팔로잉 쿼리 포트/어댑터/레포지토리
src/main/java/konkuk/thip/user/application/port/out/FollowingQueryPort.java, src/main/java/konkuk/thip/user/adapter/out/persistence/FollowingQueryPersistenceAdapter.java, src/main/java/konkuk/thip/user/adapter/out/persistence/repository/following/FollowingJpaRepository.java
팔로잉 여부를 확인하는 메서드(isFollowingUser)를 포트, 어댑터, 레포지토리에 추가
API 테스트
src/test/java/konkuk/thip/feed/adapter/in/web/FeedShowUserInfoApiTest.java
로그인 유저 context를 반영한 테스트로 수정 및 isFollowing, creatorId 필드 검증 테스트 추가
보안 설정
src/main/java/konkuk/thip/config/SecurityConfig.java
CORS 허용 도메인에 webDomainUrl 환경변수 추가

Sequence Diagram(s)

sequenceDiagram
    participant Client
    participant FeedQueryController
    participant FeedShowUserInfoService
    participant FollowingQueryPersistenceAdapter
    participant FeedQueryMapper

    Client->>FeedQueryController: GET /feeds/users/{userId}/info (with userId)
    FeedQueryController->>FeedShowUserInfoService: showAnotherUserInfoInFeeds(userId, feedOwnerId)
    FeedShowUserInfoService->>FollowingQueryPersistenceAdapter: isFollowingUser(userId, feedOwnerId)
    FollowingQueryPersistenceAdapter-->>FeedShowUserInfoService: boolean isFollowing
    FeedShowUserInfoService->>FeedQueryMapper: toFeedShowUserInfoResponse(feedOwner, feedCount, isFollowing, ...)
    FeedQueryMapper-->>FeedShowUserInfoService: FeedShowUserInfoResponse
    FeedShowUserInfoService-->>FeedQueryController: FeedShowUserInfoResponse
    FeedQueryController-->>Client: BaseResponse<FeedShowUserInfoResponse>
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~18 minutes

Assessment against linked issues

Objective Addressed Explanation
특정 유저의 공개 피드 목록 상단 화면 API의 response에 accessToken의 유저가 해당 feedOwner를 팔로잉하는지 여부를 포함하도록 수정 (#141)

Assessment against linked issues: Out-of-scope changes

(해당 사항 없음)

Possibly related PRs

Suggested labels

🛠️ feat

Poem

🐰
유저의 피드 위에 바람이 분다,
팔로잉 여부도 이제는 응답에 담는다.
creatorId도 함께 실어,
테스트까지 꼼꼼히 챙겼구나!
코드의 들판에 토끼가 뛴다,
리뷰어님, 이 변화에 박수를~ 👏

Note

⚡️ Unit Test Generation is now available in beta!

Learn more here, or try it out under "Finishing Touches" below.


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 0ac3943 and febeb86.

📒 Files selected for processing (1)
  • src/main/java/konkuk/thip/config/SecurityConfig.java (2 hunks)
✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch hotfix/#141/feeds-get-info-of-user

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.
  • 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.

Support

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

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 generate unit tests to generate unit tests for 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.

@seongjunnoh seongjunnoh merged commit 08af9ad into develop Aug 5, 2025
1 check passed
@seongjunnoh seongjunnoh deleted the hotfix/#141/feeds-get-info-of-user branch August 5, 2025 13:15

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
src/main/java/konkuk/thip/user/adapter/out/persistence/repository/following/FollowingJpaRepository.java (1)

10-10: 메서드명 길이 개선을 고려해보세요.

JPA Query Method 컨벤션을 잘 따르고 있고 exists를 사용한 것도 성능상 적절하지만, 메서드명이 상당히 길어서 가독성이 떨어집니다.

커스텀 쿼리를 사용하여 더 간결한 메서드명으로 개선할 수 있습니다:

-boolean existsByUserJpaEntity_UserIdAndFollowingUserJpaEntity_UserId(Long userId, Long followingUserId);
+@Query("SELECT COUNT(f) > 0 FROM FollowingJpaEntity f WHERE f.userJpaEntity.userId = :userId AND f.followingUserJpaEntity.userId = :followingUserId")
+boolean existsFollowingRelation(@Param("userId") Long userId, @Param("followingUserId") Long followingUserId);
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 7b7bea3 and 0ac3943.

📒 Files selected for processing (9)
  • src/main/java/konkuk/thip/feed/adapter/in/web/FeedQueryController.java (1 hunks)
  • src/main/java/konkuk/thip/feed/adapter/in/web/response/FeedShowUserInfoResponse.java (1 hunks)
  • src/main/java/konkuk/thip/feed/application/mapper/FeedQueryMapper.java (1 hunks)
  • src/main/java/konkuk/thip/feed/application/port/in/FeedShowUserInfoUseCase.java (1 hunks)
  • src/main/java/konkuk/thip/feed/application/service/FeedShowUserInfoService.java (1 hunks)
  • src/main/java/konkuk/thip/user/adapter/out/persistence/FollowingQueryPersistenceAdapter.java (1 hunks)
  • src/main/java/konkuk/thip/user/adapter/out/persistence/repository/following/FollowingJpaRepository.java (1 hunks)
  • src/main/java/konkuk/thip/user/application/port/out/FollowingQueryPort.java (1 hunks)
  • src/test/java/konkuk/thip/feed/adapter/in/web/FeedShowUserInfoApiTest.java (3 hunks)
🧰 Additional context used
🧠 Learnings (2)
📓 Common learnings
Learnt from: seongjunnoh
PR: THIP-TextHip/THIP-Server#113
File: src/main/java/konkuk/thip/recentSearch/adapter/out/persistence/RecentSearchCommandPersistenceAdapter.java:38-44
Timestamp: 2025-07-30T14:05:04.945Z
Learning: seongjunnoh는 코드 최적화 제안에 대해 구체적인 기술적 근거와 효율성 차이를 이해하고 싶어하며, 성능 개선 방식에 대한 상세한 설명을 선호한다.
Learnt from: seongjunnoh
PR: THIP-TextHip/THIP-Server#93
File: src/main/java/konkuk/thip/room/adapter/out/persistence/RoomQueryPersistenceAdapter.java:49-114
Timestamp: 2025-07-28T16:44:31.224Z
Learning: seongjunnoh는 코드 중복 문제에 대한 리팩토링 제안을 적극적으로 수용하고 함수형 인터페이스를 활용한 해결책을 선호한다.
Learnt from: seongjunnoh
PR: THIP-TextHip/THIP-Server#112
File: src/main/java/konkuk/thip/feed/adapter/out/persistence/repository/FeedQueryRepositoryImpl.java:272-272
Timestamp: 2025-07-30T10:44:34.115Z
Learning: seongjunnoh는 피드 커서 페이지네이션에서 LocalDateTime 단일 커서 방식을 선호하며, 복합 키 기반 커서보다 구현 단순성과 성능을 우선시한다.
📚 Learning: thip 프로젝트에서는 cqrs port 분리 시 다음 컨벤션을 따름: commandport에는 findbyxxx를 통해 도메인 엔티티를 찾아오는 메서드를 추가하고, querypo...
Learnt from: seongjunnoh
PR: THIP-TextHip/THIP-Server#43
File: src/main/java/konkuk/thip/book/application/port/out/BookCommandPort.java:0-0
Timestamp: 2025-07-03T03:05:05.031Z
Learning: THIP 프로젝트에서는 CQRS Port 분리 시 다음 컨벤션을 따름: CommandPort에는 findByXXX를 통해 도메인 엔티티를 찾아오는 메서드를 추가하고, QueryPort에는 조회 API의 response에 해당하는 데이터들을 DB로부터 조회하는 메서드를 추가함.

Applied to files:

  • src/main/java/konkuk/thip/user/application/port/out/FollowingQueryPort.java
🧬 Code Graph Analysis (1)
src/test/java/konkuk/thip/feed/adapter/in/web/FeedShowUserInfoApiTest.java (1)
src/test/java/konkuk/thip/common/util/TestEntityFactory.java (1)
  • TestEntityFactory (33-316)
🔇 Additional comments (13)
src/main/java/konkuk/thip/user/application/port/out/FollowingQueryPort.java (1)

14-14: LGTM! 메서드 설계가 적절합니다.

메서드명과 파라미터가 직관적이고, QueryPort의 책임에 맞게 잘 설계되었습니다.

src/main/java/konkuk/thip/user/adapter/out/persistence/FollowingQueryPersistenceAdapter.java (1)

49-52: LGTM! 효율적인 구현입니다.

exists 쿼리를 사용하여 데이터 존재 여부만 확인하는 것이 성능상 적절하고, JPA 네이밍 컨벤션도 잘 따르고 있습니다.

src/main/java/konkuk/thip/feed/adapter/in/web/response/FeedShowUserInfoResponse.java (1)

8-18: FeedShowUserInfoResponse 필드 순서 변경 호환성 확인 완료

ast-grep와 ripgrep 검증 결과,

  • new FeedShowUserInfoResponse(...) 직접 호출
  • FeedShowUserInfoResponse.(빌더 메서드 제외) 정적 메서드 호출

어느 곳에서도 사용되고 있지 않음을 확인했습니다.
따라서 필드 순서 변경으로 인한 컴파일 오류나 호환성 문제는 없습니다.

src/main/java/konkuk/thip/feed/application/port/in/FeedShowUserInfoUseCase.java (1)

9-9: 구현체와 호출부 모두 새로운 시그니처로 정상 적용됨 확인

모든 구현체(FeedShowUserInfoService)와 호출부(FeedQueryController)가 showAnotherUserInfoInFeeds(Long userId, Long feedOwnerId) 시그니처로 올바르게 업데이트된 것을 확인했습니다. 더 이상 추가 수정이 필요하지 않습니다.

src/main/java/konkuk/thip/feed/adapter/in/web/FeedQueryController.java (2)

80-80: API 문서 업데이트가 적절합니다.

새로운 기능인 팔로잉 상태 조회가 description에 명확히 반영되었습니다.


84-87: 메서드 시그니처 변경이 올바르게 구현되었습니다.

인증된 사용자 ID(userId)와 피드 소유자 ID(feedOwnerId) 파라미터를 모두 받아 팔로잉 상태를 확인할 수 있도록 적절히 수정되었습니다. 파라미터 설명도 명확합니다.

src/main/java/konkuk/thip/feed/application/mapper/FeedQueryMapper.java (1)

55-64: 매퍼 메서드 업데이트가 적절합니다.

새로운 필드인 creatorIdisFollowing 매핑이 올바르게 추가되었고, 메서드 시그니처도 새로운 파라미터를 반영하여 적절히 수정되었습니다.

src/main/java/konkuk/thip/feed/application/service/FeedShowUserInfoService.java (2)

38-38: 자신의 정보 조회시 isFollowing 처리가 올바릅니다.

사용자가 자신을 팔로우할 수 없으므로 false로 설정하는 것이 논리적으로 적절합니다.


43-57: 다른 사용자 정보 조회 로직이 잘 구현되었습니다.

메서드 시그니처가 적절히 수정되었고, 팔로잉 상태 확인 로직이 올바르게 추가되었습니다. 포트 인터페이스를 통한 팔로잉 상태 조회는 클린 아키텍처 원칙을 잘 따르고 있습니다.

src/test/java/konkuk/thip/feed/adapter/in/web/FeedShowUserInfoApiTest.java (4)

170-170: 기존 테스트에 인증 컨텍스트 추가가 적절합니다.

API 변경사항에 맞춰 인증된 사용자 컨텍스트를 추가하여 테스트가 올바르게 수정되었습니다.

Also applies to: 198-199


201-201: 새로운 응답 필드 검증이 잘 추가되었습니다.

creatorIdisFollowing 필드에 대한 검증이 적절히 추가되어 새로운 기능이 올바르게 테스트됩니다.

Also applies to: 208-208


213-237: 팔로잉 시나리오 테스트가 잘 구현되었습니다.

팔로잉 관계가 있는 경우의 isFollowing=true 시나리오를 별도 테스트로 분리하여 명확하게 검증하고 있습니다. 테스트 데이터 설정과 검증 로직이 적절합니다.


245-245: 다른 테스트 메서드들의 인증 컨텍스트 업데이트가 일관됩니다.

모든 관련 테스트가 새로운 API 요구사항에 맞춰 일관되게 수정되었습니다.

Also applies to: 291-292

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[THIP2025-206] [hotfix] 특정 유저의 공개 피드 목록 조회 상단 화면 api 수정

2 participants