Skip to content

Commit

Permalink
hotfix: 상품 상세조회시 memberId null(비회원) 인경우 처리 (#144)
Browse files Browse the repository at this point in the history
  • Loading branch information
CDBchan authored Sep 27, 2023
1 parent 8fe54c6 commit 9bd1443
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
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

0 comments on commit 9bd1443

Please sign in to comment.