Skip to content
Merged
Show file tree
Hide file tree
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 @@ -151,5 +151,13 @@ public ApiResponse<CardResponse.ProfileCardListDTO> getProfileCardsList(@PathVar
return ApiResponse.onSuccess(cardService.getProfileCardList(userId, size, cursor));
}

@GetMapping("/mypage/feeds")
@Operation(summary = "내가 작성한 피드 보기", description = "내가 작성한 피드 전체 조회(미리보기)")
public ApiResponse<CardResponse.ProfileCardListDTO> getMyCardsList(HttpServletRequest request,
@RequestParam(required = false) Long cursor,
@RequestParam(defaultValue = "15") int size) {
return ApiResponse.onSuccess(cardService.getMyProfileCardList(request, size, cursor));
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,10 @@ SELECT ch.hashtag.id, COUNT(ch.card.id)
Slice<Card> findByUserIdAndIsSharedTrueAndIsDeletedFalseOrderByIdDesc(Long userId, Pageable pageable);
Slice<Card> findByUserIdAndIsSharedTrueAndIsDeletedFalseAndIdLessThanOrderByIdDesc(Long userId, Long cursor, Pageable pageable);

Slice<Card> findByUserIdAndIsDeletedFalseOrderByIdDesc(Long userId, Pageable pageable);
Slice<Card> findByUserIdAndIsDeletedFalseAndIdLessThanOrderByIdDesc(Long userId, Long cursor, Pageable pageable);


@Query("""
select count(c)
from Card c
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,5 @@ public interface CardService {
CardResponse.PagedCardFeedResponseDto getCardFeedByCursor(HttpServletRequest request, Long userId, int size, Long cursor);
List<RecommendCardResponse> getRecommendedCardPreviews(Long userId);
CardResponse.ProfileCardListDTO getProfileCardList(Long userId, int size, Long cursor);
CardResponse.ProfileCardListDTO getMyProfileCardList(HttpServletRequest request,int size, Long cursor);

Choose a reason for hiding this comment

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

medium

메서드 파라미터 사이에 공백을 추가하여 가독성을 높이는 것이 좋습니다. request,int sizerequest, int size로 수정하는 것을 제안합니다.

Suggested change
CardResponse.ProfileCardListDTO getMyProfileCardList(HttpServletRequest request,int size, Long cursor);
CardResponse.ProfileCardListDTO getMyProfileCardList(HttpServletRequest request, int size, Long cursor);

}
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,23 @@ public CardResponse.ProfileCardListDTO getProfileCardList(Long userId, int size,
return CardConverter.toProfileCardList(userId, cardSlice);
}

@Override
public CardResponse.ProfileCardListDTO getMyProfileCardList(HttpServletRequest request,int size, Long cursor) {

Choose a reason for hiding this comment

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

medium

메서드 파라미터 사이에 공백을 추가하여 가독성을 높이는 것이 좋습니다. request,int sizerequest, int size로 수정하는 것을 제안합니다.

Suggested change
public CardResponse.ProfileCardListDTO getMyProfileCardList(HttpServletRequest request,int size, Long cursor) {
public CardResponse.ProfileCardListDTO getMyProfileCardList(HttpServletRequest request, int size, Long cursor) {

User me = userService.getLoginUser(request);

Slice<Card> cardSlice;
Pageable pageable = PageRequest.of(0, size);

if (cursor == null) {
cardSlice = cardRepository.findByUserIdAndIsDeletedFalseOrderByIdDesc(me.getId(), pageable);
} else {
cardSlice = cardRepository.findByUserIdAndIsDeletedFalseAndIdLessThanOrderByIdDesc(me.getId(), cursor, pageable);
}
return CardConverter.toProfileCardList(me.getId(), cardSlice);
}
Comment on lines +268 to +280

Choose a reason for hiding this comment

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

medium

새로 추가된 getMyProfileCardList 메서드의 내용이 기존의 getProfileCardList 메서드(255-265행)와 매우 유사하여 코드 중복이 발생하고 있습니다. 두 메서드의 공통 로직을 별도의 private 메서드로 추출하여 중복을 제거하고 유지보수성을 높이는 것을 고려해 보세요. 예를 들어, sharedOnly와 같은 boolean 플래그를 사용하여 두 경우를 모두 처리할 수 있는 private 메서드를 만들 수 있습니다.




@Override
@Transactional
public CardDeleteResponse deleteCard(Long cardId, Long userId) {
Expand Down
Loading