-
Notifications
You must be signed in to change notification settings - Fork 3
[Refactor/#382][jjaeroong]: 씨앗에서 새싹으로 명칭 변경 #403
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
Changes from all commits
e1e3400
cfa5164
5455041
41c65a6
af55c28
022c3a8
8d57b88
2326cb7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -33,7 +33,7 @@ public FeedResponseDto.FeedDto feedDto(Feed feed, Boolean isOwner, Boolean isLik | |
| return FeedResponseDto.FeedDto.builder() | ||
| .feedId(feed.getFeedId()) | ||
| .writerId(feed.getUser().getId()) | ||
| .writer(feed.getUser().getNickname() + " 씨앗") | ||
| .writer(feed.getUser().getNickname() + " 새싹") | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 💡 Verification agent 🧩 Analysis chain닉네임 접미사(" 새싹") 하드코딩 반복 → 상수/헬퍼로 일원화하고, 캐시와의 출력 일관성도 맞춰주세요
권장:
아래와 같이 변경 라인에서는 헬퍼를 호출하도록 제안합니다. - .writer(feed.getUser().getNickname() + " 새싹")
+ .writer(displayName(feed.getUser()))- .writer(feed.getUser().getNickname()+ " 새싹")
+ .writer(displayName(feed.getUser()))- .creatorNickname(feed.getUser().getNickname()+" 새싹")
+ .creatorNickname(displayName(feed.getUser()))- .writer(feed.getUser().getNickname()+" 새싹")
+ .writer(displayName(feed.getUser()))헬퍼 메서드 예시(클래스 내부에 추가): private String displayName(User user) {
String nickname = (user != null && user.getNickname() != null) ? user.getNickname() : "익명";
return nickname + " 새싹";
}캐시 일관성 방안 중 하나:
추가 점검(선택):
Also applies to: 64-64, 94-94, 113-113 🏁 Script executed: #!/bin/bash
# "씨앗" 잔존 문자열/리소스 점검
rg -n --hidden -S '씨앗' -g '!**/node_modules/**' -g '!**/build/**' -g '!**/dist/**'Length of output: 107 캐시 변환 로직 및 모든 닉네임 접미사 사용 위치를 한 번에 확인하기 위해 아래 스크립트를 실행해주세요. 🏁 Script executed: #!/bin/bash
set -e
# 1. 캐시 저장 시 DTO 생성 메서드 위치 확인
rg -n "toFeedCacheDto" -g '*.java'
# 2. 캐시 조회 후 DTO 변환 시 메서드 위치 확인
rg -n "toFeedDtoFromCache" -g '*.java'
# 3. writer()에 직접 접미사 하드코딩된 모든 위치 확인
rg -n "writer(feed.getUser().getNickname" -g '*.java'
# 4. creatorNickname()에 직접 접미사 하드코딩된 모든 위치 확인
rg -n "creatorNickname(feed.getUser().getNickname" -g '*.java'Length of output: 949 아래 스크립트로 🏁 Script executed: #!/bin/bash
set -e
# 1. FeedConverter.java: 캐시 저장/조회 메서드 주변 코드 확인
rg -n -B2 -A2 "toFeedCacheDto" src/main/java/stackpot/stackpot/feed/converter/FeedConverter.java
rg -n -B2 -A2 "toFeedDtoFromCache" src/main/java/stackpot/stackpot/feed/converter/FeedConverter.java
# 2. 전체 Java 파일에서 "새싹" 접미사 하드코딩 위치 확인
rg -n -B2 -A2 "새싹" -g '*.java'Length of output: 9001 닉네임 접미사(" 새싹") 중복 호출 → 헬퍼로 일원화 & 캐시 처리 일관화 필요 FeedConverter 내 4곳뿐 아니라 PotConverter, PotDetailConverter, PotApplicationConverter, UserConverter, UserCommandServiceImpl 등에도 동일 패턴이 반복되고, 캐시 변환 경로(toFeedCacheDto/toFeedDtoFromCache)에서는 접미사 처리/미처리가 달라 일관성이 깨질 위험이 있습니다.
🤖 Prompt for AI Agents |
||
| .writerRole(feed.getUser().getRole()) | ||
| .title(feed.getTitle()) | ||
| .content(feed.getContent()) | ||
|
|
@@ -61,7 +61,7 @@ public FeedResponseDto.CreatedFeedDto createFeedDto(Feed feed) { | |
| .title(feed.getTitle()) | ||
| .content(feed.getContent()) | ||
| .writerId(feed.getUser().getId()) | ||
| .writer(feed.getUser().getNickname()+ " 씨앗") | ||
| .writer(feed.getUser().getNickname()+ " 새싹") | ||
| .writerRole(feed.getUser().getRole()) | ||
| .categories(feed.getCategories().stream() | ||
| .map(Enum::name) | ||
|
|
@@ -91,7 +91,7 @@ public FeedSearchResponseDto toSearchDto(Feed feed) { | |
| .feedId(feed.getFeedId()) | ||
| .title(feed.getTitle()) | ||
| .content(feed.getContent()) | ||
| .creatorNickname(feed.getUser().getNickname()+" 씨앗") | ||
| .creatorNickname(feed.getUser().getNickname()+" 새싹") | ||
| .creatorRole(mapRoleName(String.valueOf(feed.getUser().getRole()))) | ||
| .createdAt(DateFormatter.koreanFormatter(feed.getCreatedAt())) | ||
| .likeCount(feed.getLikeCount()) // 좋아요 개수 포함 | ||
|
|
@@ -110,7 +110,7 @@ public FeedResponseDto.AuthorizedFeedDto toAuthorizedFeedDto(Feed feed, boolean | |
| FeedResponseDto.CreatedFeedDto createdDto = FeedResponseDto.CreatedFeedDto.builder() | ||
| .feedId(feed.getFeedId()) | ||
| .writerId(feed.getUser().getId()) | ||
| .writer(feed.getUser().getNickname()+" 씨앗") | ||
| .writer(feed.getUser().getNickname()+" 새싹") | ||
| .writerRole(feed.getUser().getRole()) | ||
| .title(feed.getTitle()) | ||
| .content(feed.getContent()) | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -2,15 +2,16 @@ | |||||||||||||||||||
|
|
||||||||||||||||||||
| import stackpot.stackpot.feed.entity.Feed; | ||||||||||||||||||||
| import stackpot.stackpot.feed.dto.FeedResponseDto; | ||||||||||||||||||||
| import stackpot.stackpot.user.dto.response.UserMyPageResponseDto; | ||||||||||||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 💡 Verification agent 🧩 Analysis chain반환 타입 변경(UserMyPageResponseDto) OK. 호출부 영향 점검 + 코드 스타일(들여쓰기) 정리 권장
들여쓰기 보정(diff): -UserMyPageResponseDto getFeeds(Long nextCursor, int pageSize);
+ UserMyPageResponseDto getFeeds(Long nextCursor, int pageSize);또한, 신규 DTO로의 변경 과정에서 nextCursor가 응답에 포함되지 않는 구조라면, 프런트의 커서 기반 페이지네이션 요구사항과 괴리가 없는지 확인이 필요합니다. Also applies to: 12-12, 14-14 🏁 Script executed: #!/bin/bash
# 1) 이전 타입(FeedPreviewList) 기대 호출부 탐색
rg -n --no-heading -S 'getFeedsByUserId\\(|getFeeds\\(' -A 2 -B 2
# 2) nextCursor를 여전히 사용하는지 컨트롤러/서비스 레이어에서 확인
rg -n --no-heading -S 'nextCursor' -A 2 -B 2Length of output: 24877 FeedQueryService 변경사항: 호출부 영향 없음 + 들여쓰기 정리 + 페이징 커서 확인
들여쓰기 보정(diff): -UserMyPageResponseDto getFeedsByUserId(Long userId, Long nextCursor, int pageSize);
-UserMyPageResponseDto getFeeds(Long nextCursor, int pageSize);
+ UserMyPageResponseDto getFeedsByUserId(Long userId, Long nextCursor, int pageSize);
+ UserMyPageResponseDto getFeeds(Long nextCursor, int pageSize);📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||
|
|
||||||||||||||||||||
| import java.util.Map; | ||||||||||||||||||||
|
|
||||||||||||||||||||
| public interface FeedQueryService { | ||||||||||||||||||||
| FeedResponseDto.FeedPreviewList getPreViewFeeds(String category, String sort, Long cursor, int limit); | ||||||||||||||||||||
| FeedResponseDto.AuthorizedFeedDto getFeed(Long feedId); | ||||||||||||||||||||
| FeedResponseDto.FeedPreviewList getFeedsByUserId(Long userId, Long nextCursor, int pageSize); | ||||||||||||||||||||
| UserMyPageResponseDto getFeedsByUserId(Long userId, Long nextCursor, int pageSize); | ||||||||||||||||||||
| // FeedResponseDto.FeedPreviewList searchByUserIdByKeyword(Long userId, Long nextCursor, int pageSize); | ||||||||||||||||||||
| FeedResponseDto.FeedPreviewList getFeeds(Long nextCursor, int pageSize); | ||||||||||||||||||||
| UserMyPageResponseDto getFeeds(Long nextCursor, int pageSize); | ||||||||||||||||||||
| Map<Long, String> getMySeries(); | ||||||||||||||||||||
| Long getLikeCount(Long feedId); | ||||||||||||||||||||
| Feed getFeedByFeedId(Long feedId); | ||||||||||||||||||||
|
|
||||||||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -53,23 +53,22 @@ public Page<PotPreviewResponseDto> searchPots(String keyword, Pageable pageable) | |
| .map(Pot::getPotId) | ||
| .collect(Collectors.toList()); | ||
|
|
||
| User user = null; | ||
| Long userId = null; | ||
| try { | ||
| user = authService.getCurrentUser(); | ||
| User user = authService.getCurrentUser(); | ||
| userId = user.getId(); | ||
| } catch (Exception e) { | ||
| // 비로그인 | ||
| } | ||
| } catch (Exception ignored) { /* 비로그인 */ } | ||
|
|
||
| // 배치 집계(이미 배치 쿼리 사용 중이라 OK) | ||
| Map<Long, Integer> potSaveCountMap = potSaveRepository.countSavesByPotIds(potIds); | ||
|
|
||
| // List -> Set (contains O(1)) | ||
| Set<Long> savedPotIds = (userId != null) | ||
| ? potSaveRepository.findPotIdsByUserIdAndPotIds(userId, potIds) | ||
| ? new HashSet<>(potSaveRepository.findPotIdsByUserIdAndPotIds(userId, potIds)) | ||
| : Collections.emptySet(); | ||
|
|
||
| // 참여 여부 isMember 확인 | ||
| Set<Long> memberPotIds = (userId != null) | ||
| ? potMemberRepository.findPotIdsByUserIdAndPotIds(userId, potIds) | ||
| ? new HashSet<>(potMemberRepository.findPotIdsByUserIdAndPotIds(userId, potIds)) | ||
| : Collections.emptySet(); | ||
|
|
||
| return pots.map(pot -> { | ||
|
|
@@ -86,47 +85,50 @@ public Page<PotPreviewResponseDto> searchPots(String keyword, Pageable pageable) | |
| }); | ||
| } | ||
|
|
||
|
|
||
| @Override | ||
| @Transactional(readOnly = true) | ||
| public Page<FeedResponseDto.FeedDto> searchFeeds(String keyword, Pageable pageable) { | ||
| Authentication authentication = SecurityContextHolder.getContext().getAuthentication(); | ||
| boolean isAuthenticated = authentication != null && | ||
| !(authentication instanceof AnonymousAuthenticationToken) && | ||
| authentication.isAuthenticated(); | ||
| var authentication = SecurityContextHolder.getContext().getAuthentication(); | ||
| boolean isAuthenticated = authentication != null | ||
| && !(authentication instanceof AnonymousAuthenticationToken) | ||
| && authentication.isAuthenticated(); | ||
|
|
||
| User user = isAuthenticated ? authService.getCurrentUser() : null; | ||
| Long userId = (user != null) ? user.getId() : null; | ||
|
|
||
| User user; | ||
| Long userId = null; | ||
| if (isAuthenticated) { | ||
| user = authService.getCurrentUser(); | ||
| userId = user.getId(); | ||
| } else { | ||
| user = null; | ||
| } | ||
|
|
||
| // 키워드 기반 검색 | ||
| Page<Feed> feeds = feedRepository.findByTitleContainingOrContentContainingOrderByCreatedAtDesc( | ||
| keyword, keyword, pageable | ||
| ); | ||
|
|
||
| // 좋아요/저장 정보 조회 | ||
| List<Long> likedFeedIds = (userId != null) | ||
| ? feedLikeRepository.findFeedIdsByUserId(userId) | ||
| : Collections.emptyList(); | ||
| // === N+1 제거: 한 번에 집계/조회 === | ||
| List<Long> feedIds = feeds.getContent().stream() | ||
| .map(Feed::getFeedId) | ||
| .collect(Collectors.toList()); | ||
|
|
||
| List<Long> savedFeedIds = (userId != null) | ||
| ? feedSaveRepository.findFeedIdsByUserId(userId) | ||
| : Collections.emptyList(); | ||
| // 저장 수 배치 집계 | ||
| Map<Long, Long> saveCountMap = feedSaveRepository.countByFeedIds(feedIds); | ||
|
|
||
| // List -> Set (contains O(1)) | ||
| Set<Long> likedFeedIds = (userId != null) | ||
| ? new HashSet<>(feedLikeRepository.findFeedIdsByUserId(userId)) | ||
| : Collections.emptySet(); | ||
|
|
||
| Set<Long> savedFeedIds = (userId != null) | ||
| ? new HashSet<>(feedSaveRepository.findFeedIdsByUserId(userId)) | ||
| : Collections.emptySet(); | ||
|
Comment on lines
+114
to
+120
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion 불필요한 대용량 조회
제안: 🤖 Prompt for AI Agents |
||
|
|
||
| // 각 Feed를 FeedDto로 변환 | ||
| return feeds.map(feed -> { | ||
| boolean isOwner = user != null && Objects.equals(user.getId(), feed.getUser().getId()); | ||
| Boolean isLiked = likedFeedIds.contains(feed.getFeedId()); | ||
| Boolean isSaved = savedFeedIds.contains(feed.getFeedId()); | ||
| int saveCount = feedSaveRepository.countByFeed(feed); | ||
| Boolean isLiked = (userId != null) ? likedFeedIds.contains(feed.getFeedId()) : null; | ||
| Boolean isSaved = (userId != null) ? savedFeedIds.contains(feed.getFeedId()) : null; | ||
| int saveCount = saveCountMap.getOrDefault(feed.getFeedId(), 0L).intValue(); | ||
|
|
||
| return feedConverter.feedDto(feed, isOwner, isLiked, isSaved, saveCount); | ||
| }); | ||
| } | ||
|
|
||
|
|
||
| } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 Verification agent
🧩 Analysis chain
미사용 import 제거 권장
UserMyPageResponseDto를 본 컨트롤러에서 사용하지 않습니다. 코드 정리 및 정적 분석 경고 방지를 위해 import를 제거하세요.
-import stackpot.stackpot.user.dto.response.UserMyPageResponseDto;🏁 Script executed:
Length of output: 179
미사용 import 제거 필요
다음 컨트롤러에서
UserMyPageResponseDto가 전혀 참조되지 않습니다. 코드 정리와 정적 분석 경고 방지를 위해 해당 import를 제거하세요.• 위치:
src/main/java/stackpot/stackpot/feed/controller/FeedController.java(19번 라인)-import stackpot.stackpot.user.dto.response.UserMyPageResponseDto;📝 Committable suggestion
🤖 Prompt for AI Agents