Skip to content

Commit

Permalink
#14 [Fix] 북마크 여러 개 등록되는 이슈 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
JSoi committed Jul 31, 2022
1 parent 4370cd6 commit 3fbfeaa
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -23,7 +22,6 @@ public class BookmarkController {

/** 북마크 생성 폴더 담기 */
@PostMapping("/bookmark")

public ResponseEntity<?> bookmark(@RequestBody BookmarkRequestDto bookmarkRequestDto,
@AuthenticationPrincipal User user){

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ public ResponseEntity<?> folderUpdate (@PathVariable int folderId,
/** 폴더 리스트 */
@GetMapping("/folderList")
public List<FolderResponseDto> folderList (@AuthenticationPrincipal User user){

return folderService.folderList(user.getUsername());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -20,7 +19,6 @@
import javax.transaction.Transactional;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;

@Service
@RequiredArgsConstructor
Expand All @@ -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) {
Expand Down

0 comments on commit 3fbfeaa

Please sign in to comment.