Skip to content
This repository has been archived by the owner on Aug 13, 2022. It is now read-only.

[#102] 카페 메뉴 조회하기 및 삭제하기 #109

Open
wants to merge 7 commits into
base: develop
Choose a base branch
from

Conversation

nicky-day
Copy link
Collaborator

@nicky-day nicky-day commented Sep 25, 2021

Fixes #102
Fixes #86
Fixes #83

개요

  • 메뉴 정보를 조회하고 삭제하는 기능이 현재 존재하지 않습니다. 따라서 카페의 전체 메뉴, 옵션을 조회하는 기능과 카페의 개별 메뉴, 옵션을 조회하는 기능을 추가합니다. 또한 카페의 메뉴와 옵션을 삭제하는 기능을 추가합니다.

작업사항

  • 1. 카페의 개별 메뉴, 옵션 조회하기
  • 2. 카페의 전체 메뉴, 옵션 조회하기
  • 3. 카페의 개별 메뉴, 옵션 삭제하기
  • 3. 테스트 코드 작성(삭제하기 기능 통합 테스트 코드는 테스트 코드 후 전체 레코드 삭제 기능 때문에 단위 테스트로 대체합니다.)

@nicky-day nicky-day self-assigned this Sep 25, 2021
@nicky-day nicky-day changed the title Feature/102 [#102] 카페 메뉴 조회하기 Sep 25, 2021
@nicky-day nicky-day changed the title [#102] 카페 메뉴 조회하기 [#102] 카페 메뉴 조회하기 및 삭제하기 Sep 25, 2021
return ResponseEntity.ok().body(AllMenu);
} else {
LOGGER.info("해당 카페의 전체 메뉴를 조회할 수 없습니다. cafeId = {}", cafeId);
return ResponseEntity.badRequest().build();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

실제로 메뉴가 없는경우도 있을수 있는데 400에러를 내리는건 안될것 같습니다.

@@ -24,4 +34,19 @@ public boolean updateMenu(MenuDTO menuDTO) {
int updateMenu = menuMapper.updateMenu(menuDTOToMenuConverter.convert(menuDTO));
return updateMenu == 1;
}

public List<MenuDTO> getAllMenu(long cafeId) {
List<MenuDTO> selectAllMenu = menuMapper.selectAllMenu(cafeId);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cafeId 의 유효성 검증이 필요해보입니다.
(존재하는 카페인지 등의)

MenuDTO menuDTO = menuService.getMenu(menuId);
if (menuDTO == null) {
LOGGER.info("해당 메뉴를 조회할 수 없습니다. cafeId = {}, menuId = {}", cafeId, menuId);
return ResponseEntity.badRequest().build();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

역시 이곳에서도 메뉴가 없다고 해서 400 에러를 내면 안될것 같습니다.
이런경우는 리소스를 찾을수 없는 404에러가 적합합니다.

return ResponseEntity.ok().body(AllOption);
} else {
LOGGER.info("해당 메뉴의 전체 옵션을 조회할 수 없습니다. cafeId = {}, menuId = {}", cafeId, menuId);
return ResponseEntity.badRequest().build();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

여기도 위와 동일

}

public boolean deleteMenu(long menuId) {
int deleteMenu = menuMapper.deleteMenu(menuId);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

해당 메뉴가 존재하는지 확인후 없다면 404를 내리고 있는데 삭제를 실패한 경우면 500에러를 내리는게 더 좋을것 같습니다.

@@ -24,4 +25,19 @@ public boolean updateOption(OptionDTO optionDTO) {
int updateOption = optionMapper.updateOption(optionDTOToOptionConverter.convert(optionDTO));
return updateOption == 1;
}

public List<OptionDTO> getAllOption(long menuId) {
List<OptionDTO> selectAllOption = optionMapper.selectAllOption(menuId);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

menuId에 대한 검증부터 하는것이 좋을것 같습니다.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
2 participants