Repository: Ddukbbegi/backend
Pull request #36: [Feat] #30 : 메뉴 상세 조회 기능 구현 
Author: login: YongLeeCode
Created: 2025-04-23T08:14:59Z | Merged: 2025-04-23T11:28:20Z

<!-- 
  📌 PR 제목 작성 가이드
  형식: [태그] #이슈번호 : 간단한 설명
  예시: [Feat] #12 : 로그인 API 연동
-->


## 🔎 작업 내용

- 클래스의 주석 삭제
- BaseRepository 적용
- 메뉴 상세 조회 기능 구현


Diff:
diff --git a/src/main/java/com/ddukbbegi/api/menu/controller/MenuController.java b/src/main/java/com/ddukbbegi/api/menu/controller/MenuController.java
index 7a3a4f7..5e4ee41 100644
--- a/src/main/java/com/ddukbbegi/api/menu/controller/MenuController.java
+++ b/src/main/java/com/ddukbbegi/api/menu/controller/MenuController.java
@@ -1,5 +1,6 @@
 package com.ddukbbegi.api.menu.controller;
 
+import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.PathVariable;
 import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.RequestBody;
@@ -7,26 +8,26 @@
 import org.springframework.web.bind.annotation.RestController;
 
 import com.ddukbbegi.api.menu.dto.request.NewMenuRequestDto;
+import com.ddukbbegi.api.menu.dto.response.DetailMenuResponseDto;
 import com.ddukbbegi.api.menu.service.MenuService;
 
 import lombok.RequiredArgsConstructor;
 
-/**
- * @packageName    : com.ddukbbegi.api.menu.controller
- * @fileName       : MenuController
- * @author         : yong
- * @date           : 4/23/25
- * @description    :
- */
 @RestController
-@RequestMapping("/api/stores/{storeId}")
+@RequestMapping("/api/stores/{storeId}/menus")
 @RequiredArgsConstructor
 public class MenuController {
-
 	private final MenuService menuService;
 
-	@PostMapping("/menus")
+	@GetMapping("/{menuId}")
+	public DetailMenuResponseDto findDetailMenu(@PathVariable long storeId, @PathVariable long menuId) {
+		return menuService.findMenuById(menuId);
+	}
+
+	@PostMapping
 	public Long addNewMenu(@PathVariable long storeId, @RequestBody NewMenuRequestDto dto) {
 		return menuService.addNewMenu(storeId, dto);
 	}
+
+
 }
diff --git a/src/main/java/com/ddukbbegi/api/menu/dto/response/DetailMenuResponseDto.java b/src/main/java/com/ddukbbegi/api/menu/dto/response/DetailMenuResponseDto.java
new file mode 100644
index 0000000..cdba94d
--- /dev/null
+++ b/src/main/java/com/ddukbbegi/api/menu/dto/response/DetailMenuResponseDto.java
@@ -0,0 +1,28 @@
+package com.ddukbbegi.api.menu.dto.response;
+
+import com.ddukbbegi.api.menu.entity.Menu;
+
+import lombok.Builder;
+import lombok.Getter;
+import lombok.RequiredArgsConstructor;
+
+@Getter
+@RequiredArgsConstructor
+public class DetailMenuResponseDto {
+	private final long id;
+	private final String name;
+	private final int price;
+	private final String description;
+	private final String category;
+
+	@Builder
+	public static DetailMenuResponseDto toDto(Menu menu) {
+		return new DetailMenuResponseDto(
+			menu.getId(),
+			menu.getName(),
+			menu.getPrice(),
+			menu.getDescription(),
+			menu.getCategory()
+		);
+	}
+}
diff --git a/src/main/java/com/ddukbbegi/api/menu/repository/MenuRepository.java b/src/main/java/com/ddukbbegi/api/menu/repository/MenuRepository.java
index f2d313a..dd2d130 100644
--- a/src/main/java/com/ddukbbegi/api/menu/repository/MenuRepository.java
+++ b/src/main/java/com/ddukbbegi/api/menu/repository/MenuRepository.java
@@ -1,15 +1,7 @@
 package com.ddukbbegi.api.menu.repository;
 
-import org.springframework.data.jpa.repository.JpaRepository;
-
+import com.ddukbbegi.api.common.repository.BaseRepository;
 import com.ddukbbegi.api.menu.entity.Menu;
 
-/**
- * @packageName    : com.ddukbbegi.api.menu.repository
- * @fileName       : MenuRepository
- * @author         : yong
- * @date           : 4/23/25
- * @description    :
- */
-public interface MenuRepository extends JpaRepository<Menu, Long> {
+public interface MenuRepository extends BaseRepository<Menu, Long> {
 }
diff --git a/src/main/java/com/ddukbbegi/api/menu/service/MenuService.java b/src/main/java/com/ddukbbegi/api/menu/service/MenuService.java
index f62eb1a..ed1635d 100644
--- a/src/main/java/com/ddukbbegi/api/menu/service/MenuService.java
+++ b/src/main/java/com/ddukbbegi/api/menu/service/MenuService.java
@@ -1,14 +1,10 @@
 package com.ddukbbegi.api.menu.service;
 
 import com.ddukbbegi.api.menu.dto.request.NewMenuRequestDto;
+import com.ddukbbegi.api.menu.dto.response.DetailMenuResponseDto;
 
-/**
- * @packageName    : com.ddukbbegi.api.menu.service
- * @fileName       : MenuService
- * @author         : yong
- * @date           : 4/23/25
- * @description    :
- */
 public interface MenuService {
+	DetailMenuResponseDto findMenuById(long menuId);
+
 	Long addNewMenu(long storeId, NewMenuRequestDto dto);
 }
diff --git a/src/main/java/com/ddukbbegi/api/menu/service/MenuServiceImpl.java b/src/main/java/com/ddukbbegi/api/menu/service/MenuServiceImpl.java
index ed03d8b..8813738 100644
--- a/src/main/java/com/ddukbbegi/api/menu/service/MenuServiceImpl.java
+++ b/src/main/java/com/ddukbbegi/api/menu/service/MenuServiceImpl.java
@@ -3,23 +3,23 @@
 import org.springframework.stereotype.Service;
 
 import com.ddukbbegi.api.menu.dto.request.NewMenuRequestDto;
+import com.ddukbbegi.api.menu.dto.response.DetailMenuResponseDto;
 import com.ddukbbegi.api.menu.entity.Menu;
 import com.ddukbbegi.api.menu.repository.MenuRepository;
 
 import lombok.RequiredArgsConstructor;
 
-/**
- * @packageName    : com.ddukbbegi.api.menu.service
- * @fileName       : MenuServiceImpl
- * @author         : yong
- * @date           : 4/23/25
- * @description    :
- */
 @Service
 @RequiredArgsConstructor
 public class MenuServiceImpl implements MenuService{
 	private final MenuRepository menuRepository;
 
+	@Override
+	public DetailMenuResponseDto findMenuById(long id) {
+		Menu menu = menuRepository.findByIdOrElseThrow(id);
+		return DetailMenuResponseDto.toDto(menu);
+	}
+
 	@Override
 	public Long addNewMenu(long storeId, NewMenuRequestDto dto) {
 		Menu menu = menuRepository.save(dto.fromDto(storeId));


Reviews:
user: login: yeonjookang
body: 리뷰 달았습니당
state: COMMENTED
author_association: COLLABORATOR
submitted_at: 2025-04-23T08:24:04Z
user: login: YongLeeCode
state: COMMENTED
author_association: COLLABORATOR
submitted_at: 2025-04-23T08:27:09Z
user: login: YongLeeCode
state: COMMENTED
author_association: COLLABORATOR
submitted_at: 2025-04-23T08:28:15Z
user: login: NCookies
state: APPROVED
author_association: COLLABORATOR
submitted_at: 2025-04-23T08:31:43Z
user: login: yeonjookang
state: COMMENTED
author_association: COLLABORATOR
submitted_at: 2025-04-23T08:32:54Z
user: login: YongLeeCode
state: COMMENTED
author_association: COLLABORATOR
submitted_at: 2025-04-23T08:42:14Z
user: login: sinyoung0403
state: APPROVED
author_association: COLLABORATOR
submitted_at: 2025-04-23T11:04:54Z
user: login: YongLeeCode
state: COMMENTED
author_association: COLLABORATOR
submitted_at: 2025-04-23T11:15:42Z

Review comments:
diff_hunk: @@ -1,14 +1,10 @@
 package com.ddukbbegi.api.menu.service;
 
 import com.ddukbbegi.api.menu.dto.request.NewMenuRequestDto;
+import com.ddukbbegi.api.menu.dto.response.DetailMenuResponseDto;
 
-/**
- * @packageName    : com.ddukbbegi.api.menu.service
- * @fileName       : MenuService
- * @author         : yong
- * @date           : 4/23/25
- * @description    :
- */
 public interface MenuService {
+	DetailMenuResponseDto findMenuById(long menuId);
path: src/main/java/com/ddukbbegi/api/menu/service/MenuService.java
user: login: yeonjookang
body: Service 단계를 인터페이스와 구현체로 따로 구분한 이유가 있을까요? 만약 구현체에 변경 가능성이 있다면 구분하기 적절하다고 생각하는데, 현재는 구현체가 변경될 것 강진 않아서요!
created_at: 2025-04-23T08:22:37Z
author_association: COLLABORATOR
diff_hunk: @@ -1,15 +1,7 @@
 package com.ddukbbegi.api.menu.repository;
 
-import org.springframework.data.jpa.repository.JpaRepository;
-
+import com.ddukbbegi.api.common.repository.BaseRepository;
 import com.ddukbbegi.api.menu.entity.Menu;
 
-/**
- * @packageName    : com.ddukbbegi.api.menu.repository
- * @fileName       : MenuRepository
- * @author         : yong
- * @date           : 4/23/25
- * @description    :
- */
-public interface MenuRepository extends JpaRepository<Menu, Long> {
+public interface MenuRepository extends BaseRepository<Menu, Long> {
path: src/main/java/com/ddukbbegi/api/menu/repository/MenuRepository.java
user: login: yeonjookang
body: 수정 감사드립니다 👍 
created_at: 2025-04-23T08:22:59Z
author_association: COLLABORATOR
diff_hunk: @@ -1,32 +1,33 @@
 package com.ddukbbegi.api.menu.controller;
 
+import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.PathVariable;
 import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 
 import com.ddukbbegi.api.menu.dto.request.NewMenuRequestDto;
+import com.ddukbbegi.api.menu.dto.response.DetailMenuResponseDto;
 import com.ddukbbegi.api.menu.service.MenuService;
 
 import lombok.RequiredArgsConstructor;
 
-/**
- * @packageName    : com.ddukbbegi.api.menu.controller
- * @fileName       : MenuController
- * @author         : yong
- * @date           : 4/23/25
- * @description    :
- */
 @RestController
-@RequestMapping("/api/stores/{storeId}")
+@RequestMapping("/api/stores/{storeId}/menus")
 @RequiredArgsConstructor
 public class MenuController {
-
 	private final MenuService menuService;
 
-	@PostMapping("/menus")
+	@GetMapping("/{menuId}")
+	public DetailMenuResponseDto findDetailMenu(@PathVariable long storeId, @PathVariable long menuId) {
path: src/main/java/com/ddukbbegi/api/menu/controller/MenuController.java
user: login: yeonjookang
body: 혹시 공통 응답은 나중에 일괄처리하시는 걸까요? 제가 저번에 리뷰 달았는데 답변을 못받아서용!
created_at: 2025-04-23T08:23:58Z
author_association: COLLABORATOR
diff_hunk: @@ -1,32 +1,33 @@
 package com.ddukbbegi.api.menu.controller;
 
+import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.PathVariable;
 import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 
 import com.ddukbbegi.api.menu.dto.request.NewMenuRequestDto;
+import com.ddukbbegi.api.menu.dto.response.DetailMenuResponseDto;
 import com.ddukbbegi.api.menu.service.MenuService;
 
 import lombok.RequiredArgsConstructor;
 
-/**
- * @packageName    : com.ddukbbegi.api.menu.controller
- * @fileName       : MenuController
- * @author         : yong
- * @date           : 4/23/25
- * @description    :
- */
 @RestController
-@RequestMapping("/api/stores/{storeId}")
+@RequestMapping("/api/stores/{storeId}/menus")
 @RequiredArgsConstructor
 public class MenuController {
-
 	private final MenuService menuService;
 
-	@PostMapping("/menus")
+	@GetMapping("/{menuId}")
+	public DetailMenuResponseDto findDetailMenu(@PathVariable long storeId, @PathVariable long menuId) {
path: src/main/java/com/ddukbbegi/api/menu/controller/MenuController.java
user: login: YongLeeCode
body: 이번 브랜치는 기본적인 CRUD가 잘 동작만 하게 만드는게 목적이여서 공통 응답은 적용하지 않았어요!
나중에 refactoring 작업하면서 수정하려고합니다~
created_at: 2025-04-23T08:27:09Z
author_association: COLLABORATOR
diff_hunk: @@ -1,14 +1,10 @@
 package com.ddukbbegi.api.menu.service;
 
 import com.ddukbbegi.api.menu.dto.request.NewMenuRequestDto;
+import com.ddukbbegi.api.menu.dto.response.DetailMenuResponseDto;
 
-/**
- * @packageName    : com.ddukbbegi.api.menu.service
- * @fileName       : MenuService
- * @author         : yong
- * @date           : 4/23/25
- * @description    :
- */
 public interface MenuService {
+	DetailMenuResponseDto findMenuById(long menuId);
path: src/main/java/com/ddukbbegi/api/menu/service/MenuService.java
user: login: YongLeeCode
body: 저희가 테스트 코드도 작성해야한다고 들어서요.
그럼 따로 인터페이스를 만드는게 맞지 않을까 싶어서 구분했습니다.
created_at: 2025-04-23T08:28:15Z
author_association: COLLABORATOR
diff_hunk: @@ -1,14 +1,10 @@
 package com.ddukbbegi.api.menu.service;
 
 import com.ddukbbegi.api.menu.dto.request.NewMenuRequestDto;
+import com.ddukbbegi.api.menu.dto.response.DetailMenuResponseDto;
 
-/**
- * @packageName    : com.ddukbbegi.api.menu.service
- * @fileName       : MenuService
- * @author         : yong
- * @date           : 4/23/25
- * @description    :
- */
 public interface MenuService {
+	DetailMenuResponseDto findMenuById(long menuId);
path: src/main/java/com/ddukbbegi/api/menu/service/MenuService.java
user: login: yeonjookang
body: 아하 혹시 테스트코드할 때 인터페이스가 어떻게 활용되나요? 제가 인터페이스를 활용한 테스트코드는 잘 몰라서요..!!
created_at: 2025-04-23T08:32:54Z
author_association: COLLABORATOR
diff_hunk: @@ -20,6 +21,12 @@
 public class MenuServiceImpl implements MenuService{
 	private final MenuRepository menuRepository;
 
+	@Override
+	public DetailMenuResponseDto findMenuById(long id) {
+		Menu menu = menuRepository.findById(id).orElseThrow();
+		return DetailMenuResponseDto.toDto(menu);
+	}
+
 	@Override
 	public Long addNewMenu(long storeId, NewMenuRequestDto dto) {
 		Menu menu = menuRepository.save(dto.fromDto(storeId));
path: src/main/java/com/ddukbbegi/api/menu/service/MenuServiceImpl.java
user: login: sinyoung0403
body: `dto.fromDto(storeId)` 에서
Dto 를 Entity 로 변환하는 건가요 ?
혹시 그렇다면 fromDto 가 아니라 `toEntity()` 가 자연스러울 거 같아요 ! 
현재 코드는 dto 를 dto 로 만든다. 느낌이라서... 
created_at: 2025-04-23T08:40:28Z
author_association: COLLABORATOR
diff_hunk: @@ -1,14 +1,10 @@
 package com.ddukbbegi.api.menu.service;
 
 import com.ddukbbegi.api.menu.dto.request.NewMenuRequestDto;
+import com.ddukbbegi.api.menu.dto.response.DetailMenuResponseDto;
 
-/**
- * @packageName    : com.ddukbbegi.api.menu.service
- * @fileName       : MenuService
- * @author         : yong
- * @date           : 4/23/25
- * @description    :
- */
 public interface MenuService {
+	DetailMenuResponseDto findMenuById(long menuId);
path: src/main/java/com/ddukbbegi/api/menu/service/MenuService.java
user: login: YongLeeCode
body: 저도 테스트는 거의 안 해봐서 이번에 해보려고요 ㅎㅎ;;
괜찮은 블로그 찾으면 공유하겠습니다.

created_at: 2025-04-23T08:42:14Z
author_association: COLLABORATOR
diff_hunk: @@ -20,6 +21,12 @@
 public class MenuServiceImpl implements MenuService{
 	private final MenuRepository menuRepository;
 
+	@Override
+	public DetailMenuResponseDto findMenuById(long id) {
+		Menu menu = menuRepository.findById(id).orElseThrow();
+		return DetailMenuResponseDto.toDto(menu);
+	}
+
 	@Override
 	public Long addNewMenu(long storeId, NewMenuRequestDto dto) {
 		Menu menu = menuRepository.save(dto.fromDto(storeId));
path: src/main/java/com/ddukbbegi/api/menu/service/MenuServiceImpl.java
user: login: YongLeeCode
body: 그렇군요. 그럼 이 부분은 다음 브랜치에서 리팩토링할 때 수정할게요.
created_at: 2025-04-23T11:15:41Z
author_association: COLLABORATOR

PR comments:
user: login: NCookies
created_at: 2025-04-23T08:28:13Z
body: 혹시 PR 제목의 / 슬래시는 오타인걸까요? 이 부분도 형식이 변경된걸까요?
author_association: COLLABORATOR
user: login: YongLeeCode
created_at: 2025-04-23T08:29:32Z
body: PR 제목 / 잘못 작성했군요.
알려주셔서 감사합니다~
author_association: COLLABORATOR