하석형 하석형 04-21
250421 하석형 변경할 내용이 없을 시 CustomNoChangeException 추가
@d585c91811ba83216c7e72338fed3c14b6419ded
src/main/java/com/takensoft/cms/menu/service/Impl/MenuAuthorServiceImpl.java
--- src/main/java/com/takensoft/cms/menu/service/Impl/MenuAuthorServiceImpl.java
+++ src/main/java/com/takensoft/cms/menu/service/Impl/MenuAuthorServiceImpl.java
@@ -8,6 +8,7 @@
 import com.takensoft.cms.menu.vo.MenuAuthorVO;
 import com.takensoft.cms.menu.vo.MenuVO;
 import com.takensoft.common.exception.CustomInsertFailException;
+import com.takensoft.common.exception.CustomNoChangeException;
 import com.takensoft.common.exception.CustomUpdateFailException;
 import com.takensoft.common.util.JWTUtil;
 import lombok.RequiredArgsConstructor;
@@ -111,13 +112,14 @@
         } catch (NullPointerException ne) {
             throw ne;
         } catch (Exception e) {
-            throw new RuntimeException(e);
+            throw e;
         }
     }
 
     /**
      * @param params - 메뉴 권한 수정 정보
      * @return int - 수정 결과
+     * @throws CustomNoChangeException - 변경할 내용이 없는 예외 발생 시
      * @throws CustomUpdateFailException - 수정 실패 예외 발생 시
      * @throws DataAccessException - 데이터베이스 접근 예외 발생 시
      * @throws NullPointerException - Null 값이 발생할 경우
@@ -131,16 +133,58 @@
     public int updateMenuAuthrtProc(HashMap<String, Object> params){
         try {
             int result = 0;
-            List<HashMap<String, Object>> menuList = (List<HashMap<String, Object>>) params.get("menuList");
+            List<HashMap<String, Object>> menuList = (List<HashMap<String, Object>>) params.get("menuList"); // 수정할 메뉴 권한 목록
             String authrtCd = params.get("authrtCd").toString();
-            for (HashMap<String, Object> menu : menuList) {
-                menu.put("mdfr", jwtUtil.getWriter());
-                menu.put("authrtCd", authrtCd);
-                int updateResult = menuAuthorDAO.updateMenuAuthrt(menu);
-                if (updateResult == 0) {
-                    throw new CustomUpdateFailException("메뉴 권한 수정에 실패헸습니다.");
+
+            // 현재 메뉴 권한 목록 조회
+            AuthorVO authorVO = new AuthorVO();
+            authorVO.setAuthrtCd(authrtCd);
+            List<HashMap<String, Object>> rawMenuList = findAll(authorVO); // 현재 메뉴 권한 목록
+
+            // 현재 메뉴 권한 목록과 수정할 메뉴 권한 목록 비교
+            boolean isSame = rawMenuList.equals(menuList);
+            if(isSame) {
+                throw new CustomNoChangeException("메뉴 권한에 변경할 내용이 없습니다.");
+            }
+
+            // 변경된 메뉴 권한만 추출
+            List<HashMap<String, Object>> changedMenuList = new ArrayList<>();
+
+            for (HashMap<String, Object> newMenu : menuList) {
+                String menuId = (String) newMenu.get("menuId");
+
+                // 현재 rawMenuList에서 동일 menuId를 가진 메뉴 찾기
+                Optional<HashMap<String, Object>> existingMenuOpt = rawMenuList.stream()
+                        .filter(m -> menuId.equals(m.get("menuId")))
+                        .findFirst();
+
+                if (existingMenuOpt.isPresent()) {
+                    HashMap<String, Object> existingMenu = existingMenuOpt.get();
+
+                    // 수정 필요 여부 판단 (하나라도 값이 다르면)
+                    boolean needsUpdate = !Objects.equals(existingMenu.get("inqAuthrt"), newMenu.get("inqAuthrt"))
+                            || !Objects.equals(existingMenu.get("regAuthrt"), newMenu.get("regAuthrt"))
+                            || !Objects.equals(existingMenu.get("mdfcnAuthrt"), newMenu.get("mdfcnAuthrt"))
+                            || !Objects.equals(existingMenu.get("delAuthrt"), newMenu.get("delAuthrt"))
+                            || !Objects.equals(existingMenu.get("fileDwnldAuthrt"), newMenu.get("fileDwnldAuthrt"));
+
+                    if (needsUpdate) {
+                        changedMenuList.add(newMenu); // 변경된 메뉴만 따로 추가
+                    }
                 }
-                result += updateResult;
+            }
+
+            // 변경된 메뉴 권한 수정
+            if(!changedMenuList.isEmpty()) {
+                for (HashMap<String, Object> menu : changedMenuList) {
+                    menu.put("mdfr", jwtUtil.getWriter());
+                    menu.put("authrtCd", authrtCd);
+                    int updateResult = menuAuthorDAO.updateMenuAuthrt(menu);
+                    if (updateResult == 0) {
+                        throw new CustomUpdateFailException("메뉴 권한 수정에 실패헸습니다.");
+                    }
+                    result += updateResult;
+                }
             }
             return result;
         } catch (DataAccessException dae) {
@@ -148,7 +192,7 @@
         } catch (NullPointerException ne) {
             throw ne;
         } catch (Exception e) {
-            throw new RuntimeException(e);
+            throw e;
         }
     }
 
 
src/main/java/com/takensoft/common/exception/CustomNoChangeException.java (added)
+++ src/main/java/com/takensoft/common/exception/CustomNoChangeException.java
@@ -0,0 +1,26 @@
+package com.takensoft.common.exception;
+
+/**
+ * @author 하석형
+ * @since 2025.04.21
+ * @modification
+ *     since    |    author    | description
+ *  2025.04.21  |    하석형     | 최초 등록
+ *
+ * RuntimeException - 실행 중 발생하는 예외를 처리하는 기본 클래스
+ *
+ * 변경할 내용이 없을 시 발생하는 예외
+ */
+public class CustomNoChangeException extends RuntimeException {
+
+    public CustomNoChangeException() {
+    }
+
+    public CustomNoChangeException(String message) {
+        super(message);
+    }
+
+    public CustomNoChangeException(String message, Throwable cause) {
+        super(message, cause);
+    }
+}(파일 끝에 줄바꿈 문자 없음)
src/main/java/com/takensoft/common/exception/GlobalExceptionHandler.java
--- src/main/java/com/takensoft/common/exception/GlobalExceptionHandler.java
+++ src/main/java/com/takensoft/common/exception/GlobalExceptionHandler.java
@@ -116,7 +116,7 @@
 
     /**
      * @param nrfe - NoResourceFoundException 예외 객체
-     * @return NoResourceFoundException 대한 HTTP 응답
+     * @return NoResourceFoundException에 대한 HTTP 응답
      *
      * NoResourceFoundException이 발생한 경우
      */
@@ -128,7 +128,7 @@
 
     /**
      * @param hrmnse - HttpRequestMethodNotSupportedException 예외 객체
-     * @return HttpRequestMethodNotSupportedException 대한 HTTP 응답
+     * @return HttpRequestMethodNotSupportedException에 대한 HTTP 응답
      *
      * HttpRequestMethodNotSupportedException이 발생한 경우
      */
@@ -190,7 +190,7 @@
      * @param cfe - CustomNotFoundException 예외 객체
      * @return CustomNotFoundException에 대한 HTTP 응답
      *
-     * CustomNotFoundException 발생한 경우
+     * CustomNotFoundException이 발생한 경우
      */
     @ExceptionHandler(CustomNotFoundException.class)
     public ResponseEntity<?> handleNotFoundException(CustomNotFoundException cfe) {
@@ -226,7 +226,7 @@
      * @param cdfe - CustomDeleteFailException 예외 객체
      * @return CustomDeleteFailException에 대한 HTTP 응답
      *
-     * CustomDeleteFailException 발생한 경우
+     * CustomDeleteFailException이 발생한 경우
      */
     @ExceptionHandler(CustomDeleteFailException.class)
     public ResponseEntity<?> handleCustomDeleteFailException(CustomDeleteFailException cdfe) {
@@ -238,7 +238,7 @@
      * @param ukhe - UnknownHostException 예외 객체
      * @return UnknownHostException에 대한 HTTP 응답
      *
-     * UnknownHostException 발생한 경우
+     * UnknownHostException이 발생한 경우
      */
     @ExceptionHandler(UnknownHostException.class)
     public ResponseEntity<?> handleUnknownHostException(UnknownHostException ukhe) {
@@ -248,9 +248,9 @@
 
     /**
      * @param ccde - CustomCodeDuplicationException 예외 객체
-     * @return CustomCodeDuplicationException 대한 HTTP 응답
+     * @return CustomCodeDuplicationException에 대한 HTTP 응답
      *
-     * CustomCodeDuplicationException 발생한 경우
+     * CustomCodeDuplicationException이 발생한 경우
      */
     @ExceptionHandler(CustomCodeDuplicationException.class)
     public ResponseEntity<?> handleCustomCodeDuplicationException(CustomCodeDuplicationException ccde) {
@@ -260,9 +260,9 @@
 
     /**
      * @param cdde - CustomDataDuplicationException 예외 객체
-     * @return CustomDataDuplicationException 대한 HTTP 응답
+     * @return CustomDataDuplicationException에 대한 HTTP 응답
      *
-     * CustomDataDuplicationException 발생한 경우
+     * CustomDataDuplicationException이 발생한 경우
      */
     @ExceptionHandler(CustomDataDuplicationException.class)
     public ResponseEntity<?> handleCustomDataDuplicationException(CustomDataDuplicationException cdde) {
@@ -272,9 +272,9 @@
 
     /**
      * @param fsle - FileSizeLimitExceededException 예외 객체
-     * @return FileSizeLimitExceededException 대한 HTTP 응답
+     * @return FileSizeLimitExceededException에 대한 HTTP 응답
      *
-     * FileSizeLimitExceededException 발생한 경우
+     * FileSizeLimitExceededException이 발생한 경우
      */
     @ExceptionHandler(FileSizeLimitExceededException.class)
     public ResponseEntity<?> handleFileSizeLimitExceededException(FileSizeLimitExceededException fsle) {
@@ -284,9 +284,9 @@
 
     /**
      * @param cfufe - CustomFileUploadFailException 예외 객체
-     * @return CustomFileUploadFailException 대한 HTTP 응답
+     * @return CustomFileUploadFailException에 대한 HTTP 응답
      *
-     * CustomFileUploadFailException 발생한 경우
+     * CustomFileUploadFailException이 발생한 경우
      */
     @ExceptionHandler(CustomFileUploadFailException.class)
     public ResponseEntity<?> handleCustomFileUploadFailException(CustomFileUploadFailException cfufe) {
@@ -296,9 +296,9 @@
 
     /**
      * @param cpwe - CustomPrhibtWordException 예외 객체
-     * @return CustomPrhibtWordException 대한 HTTP 응답
+     * @return CustomPrhibtWordException에 대한 HTTP 응답
      *
-     * CustomPrhibtWordException 발생한 경우
+     * CustomPrhibtWordException이 발생한 경우
      */
     @ExceptionHandler(CustomPrhibtWordException.class)
     public ResponseEntity<?> handleCustomPrhibtWordException(CustomPrhibtWordException cpwe) {
@@ -307,6 +307,18 @@
     }
 
     /**
+     * @param cnce - CustomNoChangeException 예외 객체
+     * @return CustomNoChangeException에 대한 HTTP 응답
+     *
+     * CustomNoChangeException이 발생한 경우
+     */
+    @ExceptionHandler(CustomNoChangeException.class)
+    public ResponseEntity<?> handleCustomInsertFailException(CustomNoChangeException cnce) {
+        logError(cnce);
+        return resUtil.errorRes(MessageCode.COMMON_NO_CHANGE);
+    }
+
+    /**
      * @param e - Exception 예외 객체
      * @return 기타 예외에 대한 HTTP 응답
      *
src/main/java/com/takensoft/common/message/MessageCode.java
--- src/main/java/com/takensoft/common/message/MessageCode.java
+++ src/main/java/com/takensoft/common/message/MessageCode.java
@@ -32,6 +32,7 @@
     COMMON_DUPLICATION_CODE("common.duplication_code",HttpStatus.INTERNAL_SERVER_ERROR), //중복 코드
     COMMON_DUPLICATION_DATA("common.duplication_data",HttpStatus.INTERNAL_SERVER_ERROR), //중복 데이터
     COMMON_PROHIBITION_WORD("common.prohibition_word",HttpStatus.INTERNAL_SERVER_ERROR), //금지어 사용 시
+    COMMON_NO_CHANGE("common.no_change",HttpStatus.INTERNAL_SERVER_ERROR), //변경할 내용이 없음
 
     //네트워크 관련
     NETWORK_UNKNOWN_HOST("network.unknown_host", HttpStatus.BAD_REQUEST), // 알 수 없는 호스트
src/main/resources/message/messages_en.yml
--- src/main/resources/message/messages_en.yml
+++ src/main/resources/message/messages_en.yml
@@ -14,7 +14,7 @@
   duplication_code: "This code already exists."
   duplication_data: "This data already exists."
   prohibition_word: "Contains prohibited words."
-
+  no_change: "Nothing to change."
 
 # 네트워크 관련
 network:
src/main/resources/message/messages_ko.yml
--- src/main/resources/message/messages_ko.yml
+++ src/main/resources/message/messages_ko.yml
@@ -14,6 +14,7 @@
   duplication_code: "이미 존재하는 코드입니다."
   duplication_data: "이미 존재하는 정보입니다."
   prohibition_word: "금지어가 포함되어 있습니다."
+  no_change: "변경할 내용이 없습니다."
 
 # 네트워크 관련
 network:
src/main/resources/mybatis/mapper/author/author-SQL.xml
--- src/main/resources/mybatis/mapper/author/author-SQL.xml
+++ src/main/resources/mybatis/mapper/author/author-SQL.xml
@@ -57,6 +57,7 @@
         <if test="sysPvsnYn != null and sysPvsnYn != ''">
             AND ai.sys_pvsn_yn = #{sysPvsnYn}
         </if>
+        ORDER BY ai.reg_dt ASC
     </select>
 
     <!--
src/main/resources/mybatis/mapper/mber/admMbr-SQL.xml
--- src/main/resources/mybatis/mapper/mber/admMbr-SQL.xml
+++ src/main/resources/mybatis/mapper/mber/admMbr-SQL.xml
@@ -276,7 +276,7 @@
             , 'S'
             , NOW()
             , #{frstRegIp}
-            , 'Y'
+            , '1'
             , #{rgtr}
             , NOW()
         )
src/main/resources/mybatis/mapper/mber/mber-SQL.xml
--- src/main/resources/mybatis/mapper/mber/mber-SQL.xml
+++ src/main/resources/mybatis/mapper/mber/mber-SQL.xml
@@ -152,7 +152,7 @@
             , 'S'
             , NOW()
             , #{frstRegIp}
-            , 'Y'
+            , '1'
             , #{rgtr}
             , NOW()
         )
Add a comment
List