Skip to content

Refactor : 반례리스트 조회 - #406

Merged
rladmstn merged 5 commits into
developfrom
refactor/be-48
Nov 16, 2025
Merged

Refactor : 반례리스트 조회#406
rladmstn merged 5 commits into
developfrom
refactor/be-48

Conversation

@sh0723

@sh0723 sh0723 commented Nov 2, 2025

Copy link
Copy Markdown
Contributor

📌 Related Issue

be-48

🚀 Description

  • 반례리스트 조회할 때 자기 자신이 좋아요를 눌렀는지에 대한 여부(isLiked 필드) 추가했습니다.
  • 비회원의 경우 isLiked 필드는 항상 false여야하고, 회원인 경우 자신이 좋아요를 누른 부분에 대해서만 isLiked 가 true이도록 했습니다.
  • 비회원인 경우와 회원인 경우를 모두 처리해야해서, AuthUser 어노테이션 부분을 수정했습니다.

📢 Review Point

  • 자신이 좋아요를 누른 반례게시물의 ID를 모아와 집합으로 만들고 이를 edgeCaseList안의 반례게시물들의 ID와 비교하며 자신이 좋아요를 누른 부분을 찾도록 했는데, 괜찮을까요.?.?
  • 다른 부분도 이상한 거 있으면 알려주세요...!

📚Etc (선택)

@sh0723 sh0723 self-assigned this Nov 2, 2025
@sh0723 sh0723 added the refactoring 리팩토링 label Nov 2, 2025
@linear

linear Bot commented Nov 2, 2025

Copy link
Copy Markdown

BE-48 반례 리스트

@channeltalk

channeltalk Bot commented Nov 2, 2025

Copy link
Copy Markdown

@github-actions

github-actions Bot commented Nov 2, 2025

Copy link
Copy Markdown

Test Results

 27 files   27 suites   6s ⏱️
356 tests 356 ✅ 0 💤 0 ❌
358 runs  358 ✅ 0 💤 0 ❌

Results for commit 90c4eb6.

♻️ This comment has been updated with latest results.

@s-hwan

s-hwan commented Nov 9, 2025

Copy link
Copy Markdown
Contributor

저희 비회원인 경우도 좋아요를 누를 수 있는건가요?

@sh0723

sh0723 commented Nov 9, 2025

Copy link
Copy Markdown
Contributor Author

저희 비회원인 경우도 좋아요를 누를 수 있는건가요?

그걸 막은거에요 !.!.!

@s-hwan s-hwan left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

고생하셨습니당

if (jwt != null)
return userRepository.findByEmail(tokenProvider.getUserEmail(jwt))
.orElseThrow(() -> new UserValidationException("없는 사용자 입니다."));
else

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

AuthedUser어노테이션 기존 코드랑 변경한 코드가 무슨 차이가 있는거에요?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

기존에는 로그인하지 않아 user객체에 정보가 없을 땐 예외를 바로 발생했는데, 지금 바꾼건 AuthUser(required = false) 라면 예외를 발생시키지 않고 통과하도록 바꾼거에요!

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

그걸 왜 해준건가욥,,

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

필요하다고 해서요..! 유저가 아닌 경우에도 반례게시판을 봐야한다고 해서 진행했습니다

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

비회원인 경우와 회원인 경우를 모두 처리해야해서, AuthUser 어노테이션 부분을 수정했습니다.

--> 이 부분때문에요

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

아 제가 생각을 잘못하고있었네요 이해했습니다!

@rladmstn rladmstn left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

수고하셨어요 👍
코멘트 확인 부탁드립니다!

public Object resolveArgument(MethodParameter parameter, ModelAndViewContainer mavContainer,
NativeWebRequest webRequest, WebDataBinderFactory binderFactory) throws Exception {
AuthedUser authedUser = parameter.getParameterAnnotation(AuthedUser.class);
boolean required = (authedUser == null) || authedUser.required();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

이거 authedUser == null이면 왜 required가 true인지 잘 이해가 안가요..!
제가 이해하기로는 Controller에 @AuthedUser 애노테이션이 없는 케이스인 것 같은데, 그럼 인증이 필요 없는 API인거 아닐까요??

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

회원인 경우와 비회원인 경우에 따라 따로따로 처리해야하는 로직이라서 @authuser이 필요해서 바꾼거에요!

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

비회원인 경우에 반례게시판을 볼 수 있지만, 좋아요는 누를 수 없도록 처리해야해서 이렇게 진행했습니다

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

지금 반례리스트 조회할 때 비회원도 가능해서 @AuthedUser(required=false)인건 이해됩니다.
근데 그럼 EdgeCaseLike에서 좋아요를 누를 수 있도록 하게 하려면, 좋아요 추가 API의 컨트롤러에 @AuthedUser(required=true)로 추가해야 하는거 아닐까요??

지금 로직에서는 컨트롤러에서 @AuthedUser를 쓰지 않으면 인증이 필요하다고 판단하게 되지 않나요??

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@AuthedUser를 쓰지 않으면 인증이 필요하다고 판단하게 되지 않나요?? 맞아요 ! 좋아요 추가 API의 컨트롤러에 @AuthedUser()로 이미 존재하지 않나요? default값이 true라서 괜찮을거같다고 생각했습니다..!

@rladmstn rladmstn Nov 9, 2025

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

boolean required = (authedUser == null) || authedUser.required();

위 조건에서 authedUser == null 이 이해가 안된거였습니다.
authedUser == null은 컨트롤러에 아예 @AuthedUser 애노테이션이 없는 경우인 것 같은데 왜 인증 정보 required가 true이도록 조건을 걸어야 하는지요!

저는@AuthedUser 애노테이션 자체가 없으면 인증 정보는 필요없는 API라는게 더 자연스러운 문맥이지 않을까 싶었거든요.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

아!! 이해했습니다. 저 authedUser == null부분을 지우는게 더 맞는거같네요..!

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

아!! 코멘트 정정합니다!

해당 resolveArgument() 메서드 내에서는 authedUser가 null일 경우가 없어서 authedUser == null 조건이 필요 없는겁니다!
애초에 @AuthedUser가 안쓰였으면 supportsParameter()에서 false가 나와버리고, 이 resolver도 사용이 안되겠군요!

Comment on lines +92 to +99
if (user != null && !edgeCaseList.isEmpty()) {
List<EdgeCaseLike> myLikes =
edgeCaseLikeRepository.findByUserAndEdgeCaseIn(user, edgeCaseList);

likedEdgeCaseIds = myLikes.stream()
.map(like -> like.getEdgeCase().getId())
.collect(Collectors.toSet());
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

QueryDSL 사용해서 동적 쿼리로 DTO를 만들 수는 있을 것 같은데 많이 복잡할 것 같네요!
그래도 반례 하나마다 쿼리가 나가는 것보단 지금이 더 나은 것 같긴 합니다!

@sh0723
sh0723 requested a review from rladmstn November 11, 2025 06:36

@rladmstn rladmstn left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

고생하셨습니다! 굿입니당

public Object resolveArgument(MethodParameter parameter, ModelAndViewContainer mavContainer,
NativeWebRequest webRequest, WebDataBinderFactory binderFactory) throws Exception {
AuthedUser authedUser = parameter.getParameterAnnotation(AuthedUser.class);
boolean required = (authedUser == null) || authedUser.required();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

아!! 코멘트 정정합니다!

해당 resolveArgument() 메서드 내에서는 authedUser가 null일 경우가 없어서 authedUser == null 조건이 필요 없는겁니다!
애초에 @AuthedUser가 안쓰였으면 supportsParameter()에서 false가 나와버리고, 이 resolver도 사용이 안되겠군요!

@rladmstn
rladmstn merged commit 76a6c05 into develop Nov 16, 2025
2 checks passed
hwangjokim pushed a commit that referenced this pull request Jan 27, 2026
Co-authored-by: Willie <150939763+junggyo1020@users.noreply.github.com>
Co-authored-by: shshwn <87060472+s-hwan@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

refactoring 리팩토링

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants