diff --git a/src/main/java/com/mpnp/baechelin/bookmark/service/BookmarkService.java b/src/main/java/com/mpnp/baechelin/bookmark/service/BookmarkService.java index e6bf03f..b82af0b 100644 --- a/src/main/java/com/mpnp/baechelin/bookmark/service/BookmarkService.java +++ b/src/main/java/com/mpnp/baechelin/bookmark/service/BookmarkService.java @@ -32,11 +32,13 @@ public class BookmarkService { private final UserRepository userRepository; private final StoreImgRepository storeImgRepository; // private final StoreImageRepository storeImageRepository; + + @Transactional public void bookmark(BookmarkRequestDto bookmarkRequestDto, String socialId) { Folder folder = folderRepository.findById(bookmarkRequestDto.getFolderId()).orElseThrow(()-> new IllegalArgumentException("폴더가 존재하지 않습니다")); - Store store = storeRepository.findById((long) bookmarkRequestDto.getStoreId()).orElseThrow(()-> new IllegalArgumentException("가게가 존재하지 않습니다")); - User user = userRepository.findBySocialId(socialId); if(user == null) { throw new IllegalArgumentException("해당하는 유저가 없습니다."); } + Store store = storeRepository.findById((long) bookmarkRequestDto.getStoreId()).orElseThrow(()-> new IllegalArgumentException("가게가 존재하지 않습니다")); + User user = userRepository.findBySocialId(socialId); if(user == null) { throw new IllegalArgumentException("해당하는 유저가 없습니다."); } Bookmark bookmark = Bookmark .builder() @@ -44,6 +46,7 @@ public void bookmark(BookmarkRequestDto bookmarkRequestDto, String socialId) { .storeId(store) .userId(user) .build(); + storeRepository.save(store.updateBookmarkCount()); bookmarkRepository.save(bookmark); }