방선주 방선주 03-14
250314 방선주 Main, menu 코드 개선
@84e89c9910715cf73fc74090c98360de8b6aeb81
src/main/java/com/takensoft/cms/main/web/MainController.java
--- src/main/java/com/takensoft/cms/main/web/MainController.java
+++ src/main/java/com/takensoft/cms/main/web/MainController.java
@@ -67,7 +67,7 @@
             }
             responseData.setStatus(HttpStatus.OK.value());
             responseData.setStatusText(HttpStatus.OK);
-            responseData.setMessage("정상적으로 처리되었습니다.");
+            responseData.setMessage("캐시가 초기화 되었습니다.");
             return new ResponseEntity<>(responseData, headers, HttpStatus.OK);
         } catch (Exception e) {
             responseData.setStatus(HttpStatus.INTERNAL_SERVER_ERROR.value());
@@ -75,19 +75,5 @@
             responseData.setMessage("캐시 초기화에 실패했습니다.");
             return new ResponseEntity<>(responseData, headers, HttpStatus.INTERNAL_SERVER_ERROR);
         }
-    }
-
-    /**
-     * @param
-     * @return ResponseEntity - 기업상담신청 알람 응답 객체
-     *
-     * 관리자 메인페이지 기업상담신청 알람
-     */
-    @PostMapping("/findAplyToastsProc.json")
-    public ResponseEntity<?> findAplyToastsProc(){
-        List<HashMap<String, Object>> result = mainService.findAplyToasts();
-
-        // 응답 처리
-        return resUtil.successRes(result, MessageCode.COMMON_SUCCESS);
     }
 }
(파일 끝에 줄바꿈 문자 없음)
src/main/java/com/takensoft/cms/menu/service/Impl/MenuServiceImpl.java
--- src/main/java/com/takensoft/cms/menu/service/Impl/MenuServiceImpl.java
+++ src/main/java/com/takensoft/cms/menu/service/Impl/MenuServiceImpl.java
@@ -46,7 +46,7 @@
  * 팝업 관련 서비스 구현체
  */
 
-@Service("menuServiceImpl")
+@Service("menuService")
 @RequiredArgsConstructor
 public class MenuServiceImpl extends EgovAbstractServiceImpl implements MenuService {
     private final MenuDAO menuDAO;
@@ -114,6 +114,9 @@
             }
             // 메뉴 등록
             int result = menuDAO.save(menuVO);
+            if(result == 0) {
+                throw new CustomInsertFailException("메뉴 등록에 실패했습니다.");
+            }
 
             // 메뉴별 권한 등록
             if (result > 0 && menuVO.getMenuGrd() != 0) {
@@ -123,15 +126,18 @@
                 }
                 if (oriMenuId.equals("MENU_000000000000001")) {
                     MenuAuthorVO menuAuthor = saveMenuAuthor(menuId, "ROLE_ADMIN");
-                    result += menuAuthorDAO.menuAuthrtSave(menuAuthor);
+                    int subResult = menuAuthorDAO.menuAuthrtSave(menuAuthor);
+                    if (subResult == 0) {
+                        throw new CustomInsertFailException("메뉴 권한 등록에 실패했습니다.");
+                    }
                 } else {
-                    result += menuAuthorService.menuAuthrtSave(menuId, "menu");
+                    int subResult = menuAuthorService.menuAuthrtSave(menuId, "menu");
                 }
             }
             return result;
-        } catch (CustomInsertFailException cife){
+        } catch (CustomInsertFailException cife) {
             throw cife;
-        } catch (DataAccessException dae) {
+        } catch(DataAccessException dae) {
             throw dae;
         } catch (NullPointerException ne) {
             throw ne;
@@ -227,11 +233,11 @@
         try{
             // 토큰정보에서 사용자 아이디 조회 후 등록
             menuVO.setMdfr(jwtUtil.getWriter());
-            return menuDAO.update(menuVO);
-        } catch (CustomUpdateFailException cufe){
-            throw cufe;
-        } catch (DataAccessException dae) {
-            throw dae;
+            int updateResult = menuDAO.update(menuVO);
+            if(updateResult == 0) {
+                throw new CustomUpdateFailException("메뉴 수정에 실패했습니다.");
+            }
+            return updateResult;
         } catch (NullPointerException ne) {
             throw ne;
         } catch (Exception e) {
@@ -251,6 +257,7 @@
     @Override
     public List<HierachyVO> findByTopNode() {
         try {
+            // 최상위 부서 조회
             List<HierachyVO> topDeptList = menuDAO.findByTopNode();
             for (HierachyVO vo : topDeptList) {
                 List<HierachyVO> child = findChildNode(vo.getId());
@@ -303,10 +310,13 @@
     public int menuDelete(MenuVO menuVO) {
         try {
             menuVO.setMdfr(jwtUtil.getWriter());
-            return menuDAO.deleteMenu(menuVO);
-        } catch (CustomUpdateFailException cufe){
-            throw cufe;
-        } catch (DataAccessException dae) {
+            // 삭제에 대한 결과
+            int deleteResult = menuDAO.deleteMenu(menuVO);
+            if(deleteResult == 0) {
+                throw new CustomDeleteFailException("메뉴 삭제에 실패했습니다.");
+            }
+            return deleteResult;
+        }  catch (DataAccessException dae) {
             throw dae;
         } catch (Exception e) {
             throw new RuntimeException(e);
@@ -377,18 +387,25 @@
                     vo.setMenuGrd(0);
                     vo.setMenuSn(sn);
                     vo.setMdfr(writer);
-                    result += menuDAO.menuUpdateByHierachy(vo);
+                    // 최상이 노드 수정 결과
+                    int highUpdateResult = menuDAO.menuUpdateByHierachy(vo);
+                    if(highUpdateResult == 0) {
+                        throw new CustomUpdateFailException("메뉴 수정에 실패했습니다.");
+                    }
+                    result += highUpdateResult;
 
                     // 하위 노드 수정
                     if (hierachyVO.getChildList() != null && hierachyVO.getChildList().size() > 0) {
-                        result += updateChildNode(hierachyVO.getChildList(), vo);
+                        int updateResult = updateChildNode(hierachyVO.getChildList(), vo);
+                        if(updateResult == 0) {
+                            throw new CustomUpdateFailException("메뉴 수정에 실패했습니다.");
+                        }
+                        result += updateResult;
                     }
                     sn++;
                 }
             }
             return result;
-        } catch (CustomUpdateFailException cufe){
-            throw cufe;
         } catch (DataAccessException dae) {
             throw dae;
         } catch (NullPointerException ne) {
@@ -409,6 +426,7 @@
      */
     @Override
     @CacheEvict(value = "findByMenuWithRouter", allEntries = true)
+    @Transactional
     public int updateChildNode(List<HierachyVO> childList, MenuVO upMenuVO) {
         int result = 0;
         try {
@@ -424,11 +442,19 @@
                 vo.setMenuGrd(grd);
                 vo.setMenuSn(sn);
                 vo.setMdfr(mdfr);
-                result += menuDAO.menuUpdateByHierachy(vo);
+
+                result =  menuDAO.menuUpdateByHierachy(vo);
+                if(result == 0) {
+                    throw new CustomUpdateFailException("메뉴 수정에 실패했습니다.");
+                }
 
                 // 하위 노드 수정
                 if (hierachyVO.getChildList() != null && hierachyVO.getChildList().size() > 0) {
-                    result += updateChildNode(hierachyVO.getChildList(), vo);
+                    // 하위 노드 수정결과
+                    int childResult = updateChildNode(hierachyVO.getChildList(), vo);
+                    if(childResult == 0) {
+                        throw new CustomUpdateFailException("하위 메뉴 수정에 실패했습니다.");
+                    }
                 }
                 sn++;
             }
@@ -457,9 +483,12 @@
     @CacheEvict(value = "findByMenuWithRouter", allEntries = true)
     public int bbsMngMenuDelete(MenuVO menuVO) {
         try {
-            return menuDAO.bbsMngMenuDelete(menuVO);
-        } catch (CustomUpdateFailException cufe){
-            throw cufe;
+            // 게시판 삭제에 대한 결과
+            int result = menuDAO.bbsMngMenuDelete(menuVO);
+            if(result == 0) {
+                throw new CustomUpdateFailException("게시판 메뉴 삭제에 실패했습니다.");
+            }
+            return result;
         } catch (DataAccessException dae) {
             throw dae;
         } catch (NullPointerException ne) {
src/main/java/com/takensoft/cms/menu/web/MenuController.java
--- src/main/java/com/takensoft/cms/menu/web/MenuController.java
+++ src/main/java/com/takensoft/cms/menu/web/MenuController.java
@@ -55,13 +55,8 @@
     public ResponseEntity<?> SaveProc(@RequestBody MenuVO menuVO) {
         // 메뉴 등록
         int result = menuService.menuSave(menuVO);
-
         // 응답 처리
-        if(result > 0) {
-            return resUtil.successRes(result, MessageCode.COMMON_SUCCESS);
-        } else {
-            return resUtil.errorRes(MessageCode.COMMON_INSERT_FAIL);
-        }
+        return resUtil.successRes(result, MessageCode.COMMON_SUCCESS);
     }
 
     /**
Add a comment
List