Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,7 @@ public UserProfileResponse getUserProfile(Long currentUserId, Long profileUserId
// 3. 프로필 주인의 정원 목록 및 물주기 가능 여부 계산
List<UserGardenDetailResponse> userGardens =
profileUser.getGardens().stream()
.filter(garden -> !garden.isLocked()) // isLocked가 false인 텃밭만 가져옵니다.
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Verification agent

🧩 Analysis chain

잠금 텃밭 필터가 소유자 본인까지 숨깁니다 — 요구사항 확인 및 조건부 필터 제안

프로필 주인 본인이 자기 프로필을 볼 때도 locked 텃밭이 제외됩니다. locked 의미가 “타인에게만 비공개”라면 조건부로 필터링해야 합니다.

-            .filter(garden -> !garden.isLocked()) // isLocked가 false인 텃밭만 가져옵니다.
+            .filter(garden -> Objects.equals(currentUserId, profileUserId) || !garden.isLocked())

필터 조건 변경 전, currentUserIdprofileUserId가 해당 메서드 내에서 사용 가능한지 및 코드 컨텍스트를 확인합니다.


🏁 Script executed:

#!/bin/bash
# UserService.java 200~260행 출력
sed -n '200,260p' src/main/java/com/example/cp_main_be/domain/member/user/service/UserService.java

# 변수 currentUserId 사용 위치 확인
rg -n 'currentUserId' -C2 src/main/java/com/example/cp_main_be/domain/member/user/service/UserService.java

# 변수 profileUserId 사용 위치 확인
rg -n 'profileUserId' -C2 src/main/java/com/example/cp_main_be/domain/member/user/service/UserService.java

Length of output: 4789


Objects.equals 사용을 위해 java.util.Objects가 import되어 있는지 확인합니다.


🏁 Script executed:

#!/bin/bash
rg -n 'import java.util.Objects' src/main/java/com/example/cp_main_be/domain/member/user/service/UserService.java

Length of output: 115


java.util.Objects import 누락 & 조건부 필터 추가
Objects.equals 사용을 위해 import java.util.Objects;를 추가하고, 프로필 주인의 경우 locked 텃밭도 보여주도록 필터를 수정하세요.

+ import java.util.Objects;
...
- .filter(garden -> !garden.isLocked())
+ .filter(garden -> Objects.equals(currentUserId, profileUserId) || !garden.isLocked())
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
.filter(garden -> !garden.isLocked()) // isLocked가 false인 텃밭만 가져옵니다.
// At the top of src/main/java/com/example/cp_main_be/domain/member/user/service/UserService.java, add:
import java.util.Objects;
...
// Then, in the stream pipeline (around line 226), replace:
.filter(garden -> Objects.equals(currentUserId, profileUserId) || !garden.isLocked()) // isLocked가 false인 텃밭만 가져옵니다.
🤖 Prompt for AI Agents
In
src/main/java/com/example/cp_main_be/domain/member/user/service/UserService.java
around line 226, add the import "import java.util.Objects;" and change the
stream filter so locked gardens are still excluded for regular viewers but
included when the requester is the profile owner; replace the current
".filter(garden -> !garden.isLocked())" with a predicate using Objects.equals to
compare the garden owner id to the current/profile owner id (e.g.
".filter(garden -> !garden.isLocked() || Objects.equals(garden.getOwnerId(),
profileOwnerId))" or the equivalent fields/method params used in this method) to
avoid NPEs.

.sorted(Comparator.comparing(Garden::getSlotNumber))
.map(
garden -> {
Expand Down