Skip to content

Commit

Permalink
#29 [Update] 에러 수정
Browse files Browse the repository at this point in the history
코드 리팩토링하면서 생긴 User가 없을 때 발생하는 nullPointException 수정
  • Loading branch information
Anna-Jin committed Jul 19, 2022
1 parent e6dbeec commit c45c295
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,11 @@ public List<StoreCardResponseDto> getStoreInRangeHighBookmark(@RequestParam(requ
public StoreCardResponseDto getStore(
@PathVariable(required = false) int storeId,
@AuthenticationPrincipal User user) {
return storeService.getStore(storeId, user.getUsername());
String socialId = "";
if (user != null) {
socialId = user.getUsername();
}

return storeService.getStore(storeId, socialId);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -166,9 +166,8 @@ private List<StoreCardResponseDto> getStoreCardResponseDtos(User targetUser, Lis
*/
public StoreCardResponseDto getStore(int storeId, String socialId) {
Store store = storeRepository.findById(storeId).orElseThrow(() -> new IllegalArgumentException("해당하는 업장이 존재하지 않습니다."));
User targetUser = socialId == null ? null : userRepository.findBySocialId(socialId);

if (targetUser == null) {
if (socialId == null) {
return new StoreCardResponseDto(store, "N");
} else {
String isBookmark = "N";
Expand Down

0 comments on commit c45c295

Please sign in to comment.