--- src/main/java/kcc/web/MainController.java
+++ src/main/java/kcc/web/MainController.java
... | ... | @@ -36,6 +36,7 @@ |
| 36 | 36 |
import javax.servlet.http.HttpSession; |
| 37 | 37 |
|
| 38 | 38 |
import org.springframework.beans.factory.annotation.Value; |
| 39 |
+import org.springframework.http.HttpStatus; |
|
| 39 | 40 |
import org.springframework.http.ResponseEntity; |
| 40 | 41 |
import org.springframework.stereotype.Controller; |
| 41 | 42 |
import org.springframework.ui.Model; |
... | ... | @@ -713,16 +714,50 @@ |
| 713 | 714 |
@ResponseBody |
| 714 | 715 |
@RequestMapping(value = "/web/com/subMenu.do") |
| 715 | 716 |
public ResponseEntity<RestResponse> webCommonSubMenu( |
| 716 |
- @RequestBody MenuManageJTreeVO menuManageVO ) throws Exception {
|
|
| 717 |
- |
|
| 717 |
+ @RequestBody Map<String, Object> paramMap) throws Exception {
|
|
| 718 |
+ // 1. 파라미터 추출 |
|
| 719 |
+ String depth1MenuNm = (String) paramMap.get("depth1MenuNm");
|
|
| 720 |
+ String depth2MenuNm = (String) paramMap.get("depth2MenuNm");
|
|
| 718 | 721 |
|
| 719 |
- System.out.println("?????");
|
|
| 722 |
+ // 2. 전체 메뉴 조회 및 1Depth 리스트 생성 (URL 세팅 포함) |
|
| 723 |
+ List<MenuManageJTreeVO> menuResultList = menuCreateManageService.selectMenuListJtree(new MenuManageJTreeVO()); |
|
| 724 |
+ |
|
| 725 |
+ List<MenuManageJTreeVO> depth1List = menuResultList.stream() |
|
| 726 |
+ .filter(menu -> "1".equals(menu.getUpperMenuId())) |
|
| 727 |
+ .peek(menu -> menu.setUrl("/web/content.do?proFn=" + menu.getMenuNo())) // 스트림 안에서 URL 세팅
|
|
| 728 |
+ .collect(Collectors.toList()); |
|
| 729 |
+ |
|
| 730 |
+ // 3. 현재 선택된 1Depth 찾기 (이미 필터링된 depth1List에서 찾음) |
|
| 731 |
+ MenuManageJTreeVO selectedDepth1 = depth1List.stream() |
|
| 732 |
+ .filter(menu -> depth1MenuNm != null && depth1MenuNm.equalsIgnoreCase(menu.getMenuNm())) |
|
| 733 |
+ .findFirst() |
|
| 734 |
+ .orElse(null); |
|
| 735 |
+ |
|
| 736 |
+ // 4. 2Depth 리스트 생성 (selectedDepth1이 있을 때만 진행) |
|
| 737 |
+ List<MenuManageJTreeVO> depth2List = new ArrayList<>(); |
|
| 738 |
+ MenuManageJTreeVO selectedDepth2 = null; |
|
| 739 |
+ |
|
| 740 |
+ if (selectedDepth1 != null) {
|
|
| 741 |
+ depth2List = menuResultList.stream() |
|
| 742 |
+ .filter(menu -> selectedDepth1.getMenuNo().equals(menu.getUpperMenuId())) |
|
| 743 |
+ .peek(menu -> menu.setUrl("/web/content.do?proFn=" + menu.getMenuNo()))
|
|
| 744 |
+ .collect(Collectors.toList()); |
|
| 720 | 745 |
|
| 721 |
- |
|
| 722 |
- |
|
| 723 |
- RestResponse restResponse = new RestResponse(); |
|
| 724 |
- |
|
| 725 |
- |
|
| 746 |
+ // 5. 현재 선택된 2Depth 찾기 |
|
| 747 |
+ selectedDepth2 = depth2List.stream() |
|
| 748 |
+ .filter(menu -> depth2MenuNm != null && depth2MenuNm.equalsIgnoreCase(menu.getMenuNm())) |
|
| 749 |
+ .findFirst() |
|
| 750 |
+ .orElse(null); |
|
| 751 |
+ } |
|
| 752 |
+ |
|
| 753 |
+ // 6. 결과 맵 구성 및 반환 |
|
| 754 |
+ Map<String, Object> resultMap = new HashMap<>(); |
|
| 755 |
+ resultMap.put("depth1List", depth1List);
|
|
| 756 |
+ resultMap.put("selectedDepth1", selectedDepth1);
|
|
| 757 |
+ resultMap.put("depth2List", depth2List);
|
|
| 758 |
+ resultMap.put("selectedDepth2", selectedDepth2);
|
|
| 759 |
+ |
|
| 760 |
+ RestResponse restResponse = new RestResponse(HttpStatus.OK, "", resultMap); |
|
| 726 | 761 |
return ResponseEntity.ok(restResponse); |
| 727 | 762 |
|
| 728 | 763 |
} |
Add a comment
Delete comment
Once you delete this comment, you won't be able to recover it. Are you sure you want to delete this comment?