-
Notifications
You must be signed in to change notification settings - Fork 176
Step2 - 리팩터링(메뉴) #168
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
newvelop
wants to merge
5
commits into
next-step:newvelop
Choose a base branch
from
newvelop:step2
base: newvelop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Step2 - 리팩터링(메뉴) #168
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
f6e49a2
refactor : refactor create method in menu
newvelop e6a3e23
refacot : refactor menu service
newvelop 0dff1e9
refactor : refactor menu group
newvelop 64575d4
refactor : refactor product using menu
newvelop 3fd0c46
refactor : add mapper and response dto
newvelop File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 18 additions & 14 deletions
32
src/main/java/kitchenpos/menus/application/MenuGroupService.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,36 +1,40 @@ | ||
| package kitchenpos.menus.application; | ||
|
|
||
| import kitchenpos.menus.domain.MenuGroup; | ||
| import kitchenpos.menus.domain.MenuGroupRepository; | ||
| import kitchenpos.menus.dto.MenuGroupCreateRequest; | ||
| import kitchenpos.menus.dto.MenuGroupResponse; | ||
| import kitchenpos.menus.mapper.MenuGroupMapper; | ||
| import kitchenpos.menus.tobe.domain.entity.MenuGroup; | ||
| import kitchenpos.menus.tobe.domain.repository.MenuGroupRepository; | ||
| import org.springframework.stereotype.Service; | ||
| import org.springframework.transaction.annotation.Transactional; | ||
|
|
||
| import java.util.List; | ||
| import java.util.Objects; | ||
| import java.util.UUID; | ||
| import java.util.stream.Collectors; | ||
|
|
||
| @Service | ||
| public class MenuGroupService { | ||
| private final MenuGroupRepository menuGroupRepository; | ||
| private final MenuGroupMapper menuGroupMapper; | ||
|
|
||
| public MenuGroupService(final MenuGroupRepository menuGroupRepository) { | ||
| public MenuGroupService( | ||
| final MenuGroupRepository menuGroupRepository, | ||
| final MenuGroupMapper menuGroupMapper | ||
| ) { | ||
| this.menuGroupRepository = menuGroupRepository; | ||
| this.menuGroupMapper = menuGroupMapper; | ||
| } | ||
|
|
||
| @Transactional | ||
| public MenuGroup create(final MenuGroup request) { | ||
| final String name = request.getName(); | ||
| if (Objects.isNull(name) || name.isEmpty()) { | ||
| throw new IllegalArgumentException(); | ||
| } | ||
| final MenuGroup menuGroup = new MenuGroup(); | ||
| menuGroup.setId(UUID.randomUUID()); | ||
| menuGroup.setName(name); | ||
| return menuGroupRepository.save(menuGroup); | ||
| public MenuGroupResponse create(final MenuGroupCreateRequest request) { | ||
| MenuGroup menuGroup = menuGroupRepository.save(MenuGroup.createMenuGroup(request.getName())); | ||
| return menuGroupMapper.toMenuGroupResponse(menuGroup); | ||
| } | ||
|
|
||
| @Transactional(readOnly = true) | ||
| public List<MenuGroup> findAll() { | ||
| return menuGroupRepository.findAll(); | ||
| public List<MenuGroupResponse> findAll() { | ||
| return menuGroupRepository.findAll().stream().map(v -> menuGroupMapper.toMenuGroupResponse(v)) | ||
| .collect(Collectors.toList()); | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
규칙 4: 한 줄에 점을 하나만 찍는다.객체 지향 생활 체조 원칙을 지켜보면 좋을 것 같아요~^^