Skip to content

Commit

Permalink
[refactor] divide method
Browse files Browse the repository at this point in the history
  • Loading branch information
kgy1008 committed Nov 12, 2024
1 parent 68259c5 commit 80c61bc
Showing 1 changed file with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,7 @@ public void deleteMenu(final MenuDeleteCommand command) {
Menu menu = menuFinder.findByStoreIdAndId(findStore.getId(), command.id());
menuDeleter.deleteMenu(menu);
updateLowestPriceInStore(storeFinder.findByIdWhereDeletedIsFalse(command.storeId()));
if (noMenuInStore(findStore.getId())) {
storeUpdater.deleteStore(command.storeId());
publisher.publish(DeleteStoreEvent.of(findStore.getName(), command.userId()));
}
noMenuInStore(findStore, command.userId());
}

@Transactional
Expand Down Expand Up @@ -73,7 +70,10 @@ private boolean validateMenuConflict(final Store store, final String menuName) {
return menuFinder.existsByStoreAndName(store, menuName);
}

private boolean noMenuInStore(final long storeId) {
return !menuFinder.existsByStoreId(storeId);
private void noMenuInStore(final Store store, final long userId) {
if (!menuFinder.existsByStoreId(store.getId())) {
storeUpdater.deleteStore(store.getId());
publisher.publish(DeleteStoreEvent.of(store.getName(), userId));
}
}
}

0 comments on commit 80c61bc

Please sign in to comment.