Skip to content

Commit

Permalink
[refac] divided method responsibility
Browse files Browse the repository at this point in the history
  • Loading branch information
kgy1008 committed Jul 12, 2024
1 parent fd3ff54 commit c9db421
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public HeartCreateResponse createHeart(final StorePostCommand storePostCommand)
Long storeId = storePostCommand.storeId();
validateCreateStoreHeart(userId, storeId);
saveStoreHeart(userId, storeId);
updateStoreHeartCount(storeId, false);
increaseStoreHeartCount(storeId);
return HeartCreateResponse.of(storeId, true);
}

Expand All @@ -37,7 +37,7 @@ public HeartDeleteResponse deleteHeart(final StoreDeleteCommand storeDeleteComma
Long storeId = storeDeleteCommand.storeId();
validateDeleteStoreHeart(userId, storeId);
heartDeleter.deleteHeart(userId,storeId);
updateStoreHeartCount(storeId, true);
decreaseStoreHeartCount(storeId);
return HeartDeleteResponse.of(storeId, false);
}

Expand All @@ -58,7 +58,11 @@ private void saveStoreHeart(final Long userId, final Long storeId) {
heartUpdater.saveHeart(heart);
}

private void updateStoreHeartCount(final Long storeId, final boolean isDeleted) {
storeFinder.getStore(storeId).updateHearCount(isDeleted);
private void increaseStoreHeartCount(final Long storeId) {
storeFinder.getStore(storeId).updateHearCount(false);
}

private void decreaseStoreHeartCount(final Long storeId) {
storeFinder.getStore(storeId).updateHearCount(true);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ public class Store extends BaseTimeEntity {
public void updateHearCount(boolean isDeleted) {
if (isDeleted) {
heartCount--;
} else {
}
else {
heartCount++;
}
}

}

0 comments on commit c9db421

Please sign in to comment.