From 3fbfeaa4ecb753971145c3aa7ba3e46b9f9ac8d1 Mon Sep 17 00:00:00 2001 From: JSoi Date: Mon, 1 Aug 2022 07:48:53 +0900 Subject: [PATCH] =?UTF-8?q?#14=20[Fix]=20=EB=B6=81=EB=A7=88=ED=81=AC=20?= =?UTF-8?q?=EC=97=AC=EB=9F=AC=20=EA=B0=9C=20=EB=93=B1=EB=A1=9D=EB=90=98?= =?UTF-8?q?=EB=8A=94=20=EC=9D=B4=EC=8A=88=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../baechelin/bookmark/controller/BookmarkController.java | 2 -- .../baechelin/bookmark/controller/FolderController.java | 1 - .../mpnp/baechelin/bookmark/service/BookmarkService.java | 8 ++++---- 3 files changed, 4 insertions(+), 7 deletions(-) diff --git a/src/main/java/com/mpnp/baechelin/bookmark/controller/BookmarkController.java b/src/main/java/com/mpnp/baechelin/bookmark/controller/BookmarkController.java index 1255a7e..523344b 100644 --- a/src/main/java/com/mpnp/baechelin/bookmark/controller/BookmarkController.java +++ b/src/main/java/com/mpnp/baechelin/bookmark/controller/BookmarkController.java @@ -7,7 +7,6 @@ import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Sort; import org.springframework.data.web.PageableDefault; -import org.springframework.http.HttpEntity; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.security.core.annotation.AuthenticationPrincipal; @@ -23,7 +22,6 @@ public class BookmarkController { /** 북마크 생성 폴더 담기 */ @PostMapping("/bookmark") - public ResponseEntity bookmark(@RequestBody BookmarkRequestDto bookmarkRequestDto, @AuthenticationPrincipal User user){ diff --git a/src/main/java/com/mpnp/baechelin/bookmark/controller/FolderController.java b/src/main/java/com/mpnp/baechelin/bookmark/controller/FolderController.java index 60511ee..773b2bf 100644 --- a/src/main/java/com/mpnp/baechelin/bookmark/controller/FolderController.java +++ b/src/main/java/com/mpnp/baechelin/bookmark/controller/FolderController.java @@ -61,7 +61,6 @@ public ResponseEntity folderUpdate (@PathVariable int folderId, /** 폴더 리스트 */ @GetMapping("/folderList") public List folderList (@AuthenticationPrincipal User user){ - return folderService.folderList(user.getUsername()); } } 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 b82af0b..16ce3a8 100644 --- a/src/main/java/com/mpnp/baechelin/bookmark/service/BookmarkService.java +++ b/src/main/java/com/mpnp/baechelin/bookmark/service/BookmarkService.java @@ -7,7 +7,6 @@ import com.mpnp.baechelin.bookmark.repository.BookmarkRepository; import com.mpnp.baechelin.bookmark.repository.FolderRepository; import com.mpnp.baechelin.store.domain.Store; -import com.mpnp.baechelin.store.domain.StoreImage; import com.mpnp.baechelin.store.repository.StoreImgRepository; import com.mpnp.baechelin.store.repository.StoreRepository; import com.mpnp.baechelin.user.domain.User; @@ -20,7 +19,6 @@ import javax.transaction.Transactional; import java.util.ArrayList; import java.util.List; -import java.util.Optional; @Service @RequiredArgsConstructor @@ -47,8 +45,10 @@ public void bookmark(BookmarkRequestDto bookmarkRequestDto, String socialId) { .userId(user) .build(); - storeRepository.save(store.updateBookmarkCount()); - bookmarkRepository.save(bookmark); + if (!bookmarkRepository.existsByStoreIdAndUserId(store, user)) { + bookmarkRepository.save(bookmark); + storeRepository.save(store.updateBookmarkCount()); + } } public void bookmarkDelete(int bookmarkId, String socialId) {