Skip to content

Commit

Permalink
[refactor] transfer logic to dto
Browse files Browse the repository at this point in the history
  • Loading branch information
kgy1008 committed Nov 12, 2024
1 parent b2ffd04 commit a42e0cc
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package org.hankki.hankkiserver.api.menu.service;

import java.util.List;
import lombok.RequiredArgsConstructor;
import org.hankki.hankkiserver.api.menu.service.command.MenuDeleteCommand;
import org.hankki.hankkiserver.api.menu.service.command.MenuPatchCommand;
import org.hankki.hankkiserver.api.menu.service.command.MenusPostCommand;
import org.hankki.hankkiserver.api.menu.service.response.MenuGetResponse;
import org.hankki.hankkiserver.api.menu.service.response.MenusGetResponse;
import org.hankki.hankkiserver.api.menu.service.response.MenusPostResponse;
import org.hankki.hankkiserver.api.store.service.StoreFinder;
Expand All @@ -13,8 +13,6 @@
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
@RequiredArgsConstructor
public class MenuCommandService {
Expand Down Expand Up @@ -54,10 +52,7 @@ public MenusPostResponse createMenus(final MenusPostCommand command) {
public MenusGetResponse getMenus(final long storeId) {
Store findStore = storeFinder.findByIdWhereDeletedIsFalse(storeId);
List<Menu> findmenus = menuFinder.findAllByStore(findStore);
List<MenuGetResponse> menus = findmenus.stream()
.map(MenuGetResponse::of)
.toList();
return MenusGetResponse.of(menus);
return MenusGetResponse.of(findmenus);
}

private void updateLowestPriceInStore(final Store findStore) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
package org.hankki.hankkiserver.api.menu.service.response;

import java.util.List;
import org.hankki.hankkiserver.domain.menu.model.Menu;

public record MenusGetResponse(
List<MenuGetResponse> menus
) {
public static MenusGetResponse of(List<MenuGetResponse> menus) {
return new MenusGetResponse(menus);
public static MenusGetResponse of(final List<Menu> menus) {
List<MenuGetResponse> findmenus = menus.stream()
.map(MenuGetResponse::of)
.toList();
return new MenusGetResponse(findmenus);
}
}

0 comments on commit a42e0cc

Please sign in to comment.