Skip to content
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

hotfix: 상품 상세조회시 memberId null(비회원) 인경우 처리 #144

Merged
merged 1 commit into from
Sep 27, 2023
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 @@ -39,7 +39,8 @@ public abstract class CommonFilter extends OncePerRequestFilter {
new WhiteListUri("^/connect/[0-9]*$", Set.of("GET")),
new WhiteListUri("^/oauth2/authorization/[^/]+$", Set.of("GET")),
new WhiteListUri("^/login/oauth2/code/.*$", Set.of("GET")),
new WhiteListUri("^/api/regions$", Set.of("GET"))
new WhiteListUri("^/api/regions$", Set.of("GET")),
new WhiteListUri("^/api/products/[0-9]*/stat$", Set.of("GET"))
);

protected JwtProvider jwtProvider;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,13 @@ public static String extractAccessToken(HttpServletRequest request) {
}

public static Long extractMemberId(HttpServletRequest request) {
return Long.valueOf(String.valueOf(request.getAttribute(MEMBER_ID)));
Object attribute = request.getAttribute(MEMBER_ID);
if (attribute == null) {
return null;
}

String memberId = attribute.toString();
return Long.valueOf(memberId);
}

public static String extractEmail(HttpServletRequest request) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,9 @@ public ProductStatResponse findStat(Long productId, Long memberId) {
Long viewCount = redisUtil.getViewCount(productId) + product.getViewCount();
Long reactionCount = reactionQueryService.countByProduct(product);
Long chattingCount = chatQueryService.countByProduct(product);
Boolean isLiked = reactionQueryService.isLiked(memberId, product);

// memberId가 null이 아닐 때만 isLiked를 확인
Boolean isLiked = (memberId != null) ? reactionQueryService.isLiked(memberId, product) : false;

return ProductStatResponse.of(viewCount, reactionCount, chattingCount, isLiked);
}
Expand Down