방선주 방선주 03-22
Merge branch 'master' of http://210.180.118.83/jhpark/cms_backend
@a0e7e7b4459f9a38a0ea1822e01377b387eab155
src/main/java/com/takensoft/cms/bbs/service/BbsCnService.java
--- src/main/java/com/takensoft/cms/bbs/service/BbsCnService.java
+++ src/main/java/com/takensoft/cms/bbs/service/BbsCnService.java
@@ -3,6 +3,8 @@
 import com.takensoft.cms.bbs.vo.BbsCnVO;
 import com.takensoft.cms.popup.vo.PopupVO;
 import com.takensoft.common.Pagination;
+import com.takensoft.common.exception.CustomDataDuplicationException;
+import org.springframework.dao.DataAccessException;
 import org.springframework.web.multipart.MultipartFile;
 
 import java.util.HashMap;
@@ -10,124 +12,158 @@
 import java.util.Map;
 
 /**
- * @author  : 하석형
- * @since   : 2024.05.09
+ * @author 하석형
+ * @since 2024.05.09
+ * @modification
+ *     since    |    author    | description
+ *  2024.05.09  |    하석형     | 최초 등록
+ *  2024.05.22  |    방선주     | updateVwCnt 추가
+ *  2024.05.23  |    방선주     | findPrevBbsCn, findNextBbsCn 추가
+ *  2024.05.28  |    박정하     | selectBbsCnListByNew 추가
+ *  2024.05.30  |    방선주     | fileListPathChange 추가
+ *  2024.05.31  |    방선주     | saveAnswer, updateAnswer 추가
+ *  2024.06.07  |    방선주     | deleteAns 추가
+ *  2024.06.13  |    방선주     | findFiveNotice 추가
+ *  2025.03.20  |    하석형     | 코드 리펙토링
  *
- * 게시판 관리 관련 인터페이스
+ * 게시판 내용 관련 인터페이스
  */
 public interface BbsCnService {
+
     /**
-     * @author  하석형
-     * @since   2024.05.09
+     * @param bbsCnVO - 게시판 정보
+     * @return boolean - 게시판 아이디 중복 여부
+     *
      * 게시판 아이디 중복 검사
      */
     public boolean bbsCnIdCheck(BbsCnVO bbsCnVO);
 
     /**
-     * @author  하석형
-     * @since   2024.05.09
+     * @param bbsCn - 게시판 내용 정보
+     * @param multipartFileList - 첨부파일 목록
+     * @param multipartImgList - 이미지파일 목록
+     * @return HashMap<String, Object>
+     *  - bbsId : 게시판 아이디
+     *  - result : 게시판 내용 등록 결과
+     *
      * 게시판 내용 등록
      */
     public HashMap<String, Object> saveBbsCn(BbsCnVO bbsCn, List<MultipartFile> multipartFileList, List<MultipartFile> multipartImgList);
 
     /**
-     * @author  하석형
-     * @since   2024.05.13
+     * @param pagination - 페이징 정보
+     * @return int - 게시판 내용 목록 조회 개수
+     *
      * 게시판 내용 목록 조회 개수
      */
     public int findAllCnt(Pagination pagination);
 
     /**
-     * @author  하석형
-     * @since   2024.05.09
+     * @param params - 게시판 정보
+     * @return Map<String, Object>
+     *  - list : 게시판 내용 목록
+     *  - pagination : 페이징 정보
+     *  - codeList : 검색 조건
+     *  - bbsMng : 게시판 관리 정보
+     *
      * 게시판 내용 목록 조회
      */
     public Map<String, Object> findAllBbsCn(HashMap<String, String> params);
 
     /**
-     * @author 하석형
-     * @since  2024.05.09
+     * @param bbsId - 게시판 아이디
+     * @return BbsCnVO - 게시판 내용 정보를 담고 있는 객체
+     * @throws DataAccessException - db 관련 예외 발생 시
+     * @throws Exception - 그 외 예외 발생 시
      *
-     * 게시판 관리 상세 조회
+     * 게시판 내용 상세 조회
      */
     public BbsCnVO findByBbsId(String bbsId);
 
     /**
-     * @author 하석형
-     * @since  2024.05.09
+     * @param params - 게시판 정보
+     * @param deleteFileList - 삭제 파일 목록
+     * @param multipartFileList - 파일 목록
+     * @param deleteImgFileList - 삭제 이미지 파일 목록
+     * @param multipartImgList - 이미지 파일 목록
+     * @return HashMap<String, Object>
+     *  - result : 게시판 내용 수정 결과
      *
-     * 게시판 관리 수정
+     * 게시판 내용 수정
      */
     public HashMap<String, Object> updateBbsCn(HashMap<String, Object> params, List<HashMap<String, Object>> deleteFileList, List<MultipartFile> multipartFileList, List<HashMap<String, Object>> deleteImgFileList, List<MultipartFile> multipartImgList);
 
     /**
-     * @author 하석형
-     * @since  2024.05.09
+     * @param bbsCnVO - 게시판 정보
+     * @return int - 게시판 내용 삭제 결과
      *
-     * 게시판 관리 삭제
+     * 게시판 내용 삭제
      */
     public int deleteBbsCn(BbsCnVO bbsCnVO);
 
     /**
-     * @author 방선주
-     * @since  2024.05.22
+     * @param params - 게시판 정보
+     * @return int - 조회수 증가 결과
      *
      * 조회수 증가
      */
     public int updateVwCnt(HashMap<String, Object> params);
 
     /**
-     * @author 방선주
-     * @since  2024.05.23
+     * @param bbsCnVO - 게시판 정보
+     * @return BbsCnVO - 게시판 내용 정보를 담고 있는 객체
      *
      * 이전글 조회
      */
      public BbsCnVO findPrevBbsCn(BbsCnVO bbsCnVO);
 
     /**
-     * @author 방선주
-     * @since  2024.05.23
+     * @param bbsCnVO - 게시판 정보
+     * @return BbsCnVO - 게시판 내용 정보를 담고 있는 객체
      *
      * 다음글 조회
      */
     public BbsCnVO findNextBbsCn(BbsCnVO bbsCnVO);
+
     /**
-     * @author 방선주
-     * @since  2024.05.30
+     * @param fileMngId - 파일매니저 아이디
+     * @return List<HashMap<String, Object>> - 파일매니저 목록
      *
      * 첨부파일 이미지 경로 변경
      */
     public List<HashMap<String, Object>> fileListPathChange(String fileMngId);
 
     /**
-     * @author 방선주
-     * @since  2024.05.31
+     * @param bbsCnVO - 게시판 내용 정보
+     * @return HashMap<String, Object> - 답변 등록 결과
      *
-     * 질의형 답변 등록
+     * 질의형 게시판 답변 등록
      */
     public HashMap<String, Object> saveAnswer(BbsCnVO bbsCnVO);
 
     /**
-     * @author 방선주
-     * @since  2024.05.31
+     * @param bbsCnVO - 게시판 내용 정보
+     * @return HashMap<String, Object> - 답변 수정 결과
      *
-     * 질의형 답변 수정
+     * 질의형 게시판 답변 수정
      */
     public HashMap<String, Object> updateAnswer(BbsCnVO bbsCnVO);
 
     /**
-     * @author 방선주
-     * @since  2024.06.07
+     * @param bbsCnVO - 게시판 정보
+     * @return int - 답변 삭제 결과
      *
-     * 질의형 답변 삭제
+     * 질의형 게시판 답변 삭제
      */
     public int deleteAns(BbsCnVO bbsCnVO);
 
     /**
-     * @author 방선주
-     * @since  2024.06.13
+     * @param bbsCn - 게시판 정보
+     * @return List<BbsCnVO> - 게시판 내용 정보를 담고 있는 객체 목록
      *
      * 최신 공지 5개
      */
     public List<BbsCnVO> findFiveNotice(BbsCnVO bbsCn);
+
+
 }
(No newline at end of file)
src/main/java/com/takensoft/cms/bbs/service/Impl/BbsCnServiceImpl.java
--- src/main/java/com/takensoft/cms/bbs/service/Impl/BbsCnServiceImpl.java
+++ src/main/java/com/takensoft/cms/bbs/service/Impl/BbsCnServiceImpl.java
@@ -35,11 +35,14 @@
  * @modification
  *     since    |    author    | description
  *  2024.05.09  |    하석형     | 최초 등록
- *  2024.05.22  |    방선주     | updateVwCnt 추가
+ *  2024.05.22  |    방선주     | vdoUrlCheck, updateVwCnt 추가
  *  2024.05.23  |    방선주     | findPrevBbsCn, findNextBbsCn 추가
  *  2024.05.28  |    박정하     | selectBbsCnListByNew 추가
- *  2024.06.04  |    방선주     | saveAnswer 추가
+ *  2024.05.30  |    방선주     | fileListPathChange 추가
+ *  2024.06.04  |    방선주     | saveAnswer, updateAnswer 추가
+ *  2024.06.07  |    방선주     | deleteAns 추가
  *  2024.06.13  |    방선주     | findFiveNotice 추가
+ *  2025.03.21  |    하석형     | 코드 리펙토링
  *
  * EgovAbstractServiceImpl : 전자정부 상속
  * BbsCnService : 게시판 내용 관련 인터페이스 상속
@@ -97,89 +100,104 @@
     }
 
     /**
-     * @author  하석형
-     * @since   2024.05.09
+     * @param bbsCn - 게시판 내용 정보
+     * @param multipartFileList - 첨부파일 목록
+     * @param multipartImgList - 이미지파일 목록
+     * @return HashMap<String, Object>
+     *  - bbsId : 게시판 아이디
+     *  - result : 게시판 내용 등록 결과
+     * @throws CustomPrhibtWordException - 금지어 포함 예외 발생 시
+     * @throws CustomNotFoundException - 사용자 정보 조회 예외 발생 시
+     * @throws CustomInsertFailException - 게시판 내용 등록 예외 발생 시
+     * @throws DataAccessException - db 관련 예외 발생 시
+     * @throws Exception - 그 외 예외 발생 시
+     *
      * 게시판 내용 등록
      */
     @Transactional(rollbackFor = Exception.class)
     @Override
     public HashMap<String, Object> saveBbsCn(BbsCnVO bbsCn, List<MultipartFile> multipartFileList, List<MultipartFile> multipartImgList) {
-        HashMap<String, Object> result = new HashMap<>();
-        List<String> wordList = wordMngDAO.findWordList();
+        try {
+            HashMap<String, Object> result = new HashMap<>();
+            List<String> wordList = wordMngDAO.findWordList();
 
-        // 금지어 포함 여부 체크
-        // 제목에 금지어가 포함되어있는가?
-        if(bbsCn.getBbsNm() != null && !bbsCn.getBbsNm().isEmpty()) {
-        String bbsNm = bbsCn.getBbsNm();
-        for (String word : wordList) {
-            if (bbsNm.contains(word)) {
-                result.put("result", -1);
-                result.put("word", word);
-                return result;
+            // 금지어 포함 여부 체크
+            if (bbsCn.getBbsNm() != null && !bbsCn.getBbsNm().isEmpty()) {
+                String bbsNm = bbsCn.getBbsNm();
+                String content = bbsCn.getBbsCn();
+                for (String word : wordList) {
+                    // 제목에 금지어가 포함되어있는가?
+                    if (bbsNm.contains(word)) {
+                        throw new CustomPrhibtWordException("제목에 금지어가 포함되어있습니다.", word);
+                    }
+                    // 내용에 금지어가 포함되어있는가?
+                    if (content.contains(word)) {
+                        throw new CustomPrhibtWordException("내용에 금지어가 포함되어있습니다.", word);
+                    }
+                }
             }
-        }
-        }
 
-        // 내용에 금지어가 포함되어있는가?
-        String content = bbsCn.getBbsCn();
-        for (String word : wordList) {
-            if (content.contains(word)) {
-                result.put("result", -1);
-                result.put("word", word);
-                return result;
+            // 게시판 내용 아이디 생성
+            String bbsId = bbsIdgn.getNextStringId();
+            bbsCn.setBbsId(bbsId);
+
+            // 등록된 토큰에서 사용자 정보 조회
+            String writer = jwtUtil.getWriter();
+            if (writer == null || writer.isEmpty()) {
+                throw new CustomNotFoundException("사용자 정보 조회에 실패했습니다.");
             }
+            bbsCn.setRgtr(writer);
+
+            // youtube 링크 여부에 따라 처리
+            if (bbsCn.getVdoUrl() != null) {
+                bbsCn.setVdoUrl(vdoUrlCheck(bbsCn.getVdoUrl()));
+            }
+
+            // 첨부파일 유무
+            if (multipartFileList != null && !multipartFileList.isEmpty()) {
+                FileMngVO fileMngVO = new FileMngVO();
+
+                // 파일매니저 등록
+                HashMap<String, Object> fileMng = fileMngService.fileMngInsert(fileMngVO, multipartFileList);
+//                result.put("multipartFileMngResult", fileMng);
+
+                // 파일매니저 아이디 삽입
+                bbsCn.setAtchFileMngId(fileMng.get("fileMngId").toString());
+            }
+            // 이미지파일 유무
+            if (multipartImgList != null && !multipartImgList.isEmpty()) {
+                FileMngVO fileMngVO = new FileMngVO();
+
+                // 파일매니저 등록
+                HashMap<String, Object> imgFileMng = fileMngService.fileMngInsert(fileMngVO, multipartImgList);
+//                result.put("multipartFileMngResult", imgFileMng);
+
+                // 이미지 파일매니저 아이디 삽입
+                bbsCn.setImgFileMngId(imgFileMng.get("fileMngId").toString());
+            }
+
+            // 질의형인 경우 \n을 <br>로 변경
+            if (bbsCn.getBbsNm() == null) {
+                String text = bbsCn.getBbsCn().replaceAll("\n", "<br/>");
+                bbsCn.setBbsCn(text);
+            }
+
+            // 기본정보 DB 등록
+            int saveBbsCnResult = bbsCnDAO.save(bbsCn);
+            if(saveBbsCnResult == 0) {
+                throw new CustomInsertFailException("게시판 내용 등록에 실패했습니다.");
+            }
+            result.put("bbsId", bbsId);
+            result.put("result", saveBbsCnResult);
+
+            return result;
+        } catch (CustomNotFoundException | CustomFileUploadFailException | CustomInsertFailException | IllegalArgumentException le) {
+            throw le;
+        }  catch (DataAccessException dae) {
+            throw dae;
+        } catch (Exception e) {
+            throw e;
         }
-
-
-        // 게시판 내용 아이디 생성
-        String bbsId = bbsIdgn.getNextStringId();
-        bbsCn.setBbsId(bbsId);
-
-        // 등록된 토큰에서 사용자 정보 조회
-        String writer = jwtUtil.getWriter();
-        bbsCn.setRgtr(writer);
-
-        // youtube 링크 여부에 따라 처리
-        if(bbsCn.getVdoUrl() != null){
-            bbsCn.setVdoUrl(vdoUrlCheck(bbsCn.getVdoUrl()));
-        }
-
-
-        // 첨부파일 유무
-        if (multipartFileList != null && !multipartFileList.isEmpty()) {
-            FileMngVO fileMngVO = new FileMngVO();
-
-            // 파일매니저 등록
-            HashMap<String, Object> fileMng = fileMngService.fileMngInsert(fileMngVO, multipartFileList);
-            result.put("multipartFileMngResult", fileMng);
-
-            // 파일매니저 아이디 삽입
-            bbsCn.setAtchFileMngId(fileMng.get("fileMngId").toString());
-        }
-        // 이미지파일 유무
-        if (multipartImgList != null && !multipartImgList.isEmpty()) {
-            FileMngVO fileMngVO = new FileMngVO();
-
-            // 파일매니저 등록
-            HashMap<String, Object> imgFileMng = fileMngService.fileMngInsert(fileMngVO, multipartImgList);
-            result.put("multipartFileMngResult", imgFileMng);
-
-            // 이미지 파일매니저 아이디 삽입
-            bbsCn.setImgFileMngId(imgFileMng.get("fileMngId").toString());
-        }
-
-        // 질의형인 경우 \n을 <br>로 변경
-        if(bbsCn.getBbsNm() == null){
-            String text = bbsCn.getBbsCn().replaceAll("\n", "<br/>");
-            bbsCn.setBbsCn(text);
-        }
-
-        // 기본정보 DB 등록
-        int saveBbsCnResult = bbsCnDAO.save(bbsCn);
-        result.put("bbsId", bbsId);
-        result.put("result", saveBbsCnResult);
-
-        return result;
     }
 
     /**
@@ -190,6 +208,7 @@
      *
      * 게시판 내용 목록 조회 개수
      */
+    @Override
     public int findAllCnt(Pagination pagination){
         try {
             return bbsCnDAO.findAllCnt(pagination);
@@ -201,38 +220,50 @@
     }
 
     /**
-     * @author  하석형
-     * @since   2024.05.09
+     * @param params - 게시판 정보
+     * @return Map<String, Object>
+     *  - list : 게시판 내용 목록
+     *  - pagination : 페이징 정보
+     *  - codeList : 검색 조건
+     *  - bbsMng : 게시판 관리 정보
+     * @throws DataAccessException - db 관련 예외 발생 시
+     * @throws Exception - 그 외 예외 발생 시
+     *
      * 게시판 내용 목록 조회
      */
     @Override
     public Map<String, Object> findAllBbsCn(HashMap<String, String> params) {
-        Map<String, Object> result = new HashMap<>();
+        try {
+            Map<String, Object> result = new HashMap<>();
 
-        // 게시판 관리 정보
-        BbsMngVO bbsMng = bbsMngDAO.findByBbsMngId(params.get("id"));
-        params.put("recordSize", String.valueOf(bbsMng.getArtclCnt()));
+            // 게시판 관리 정보
+            BbsMngVO bbsMng = bbsMngDAO.findByBbsMngId(params.get("id"));
+            params.put("recordSize", String.valueOf(bbsMng.getArtclCnt()));
 
-        // 게시판 보여줄 갯수 설정
-        Pagination search = new Pagination(0, params);
-        int cnt = bbsCnDAO.findAllCnt(search);
-        Pagination pagination = new Pagination(cnt, params);
-        List<BbsCnVO> list = bbsCnDAO.findAll(pagination);
+            // 게시판 보여줄 갯수 설정
+            Pagination search = new Pagination(0, params);
+            int cnt = bbsCnDAO.findAllCnt(search);
+            Pagination pagination = new Pagination(cnt, params);
+            List<BbsCnVO> list = bbsCnDAO.findAll(pagination);
 
-        list.forEach(entity -> {
-            String imagePath = entity.getAbsltPath();
-            entity.setAbsltPath(convertPathToUrl(imagePath));
-        });
+            list.forEach(entity -> {
+                String imagePath = entity.getAbsltPath();
+                entity.setAbsltPath(convertPathToUrl(imagePath));
+            });
 
-        result.put("list", list);
-        result.put("pagination", pagination);
-        result.put("codeList", null); // 검색 조건
-        result.put("bbsMng", bbsMng); // 게시판 관리 정보
-        return result;
+            result.put("list", list);
+            result.put("pagination", pagination);
+            result.put("codeList", null); // 검색 조건
+            result.put("bbsMng", bbsMng); // 게시판 관리 정보
+            return result;
+        } catch (DataAccessException dae) {
+            throw dae;
+        } catch (Exception e) {
+            throw e;
+        }
     }
 
     private String convertPathToUrl(String filePath) {
-
         String previewPath = null;
         String[] pathArray = locationPath.split("/, ");
         for (String path : pathArray) {
@@ -286,90 +317,112 @@
     }
 
     /**
-     * @author 하석형
-     * @since  2024.05.09
+     * @param params - 게시판 정보
+     * @param deleteFileList - 삭제 파일 목록
+     * @param multipartFileList - 파일 목록
+     * @param deleteImgFileList - 삭제 이미지 파일 목록
+     * @param multipartImgList - 이미지 파일 목록
+     * @return HashMap<String, Object>
+     *  - result : 게시판 내용 수정 결과
+     * @throws CustomPrhibtWordException - 금지어 포함 예외 발생 시
+     * @throws CustomNotFoundException - 사용자 정보 조회 예외 발생 시
+     * @throws CustomUpdateFailException - 게시판 내용 수정 예외 발생 시
+     * @throws DataAccessException - db 관련 예외 발생 시
+     * @throws Exception - 그 외 예외 발생 시
      *
      * 게시판 내용 수정
      */
     @Transactional(rollbackFor = Exception.class)
     @Override
     public HashMap<String, Object> updateBbsCn(HashMap<String, Object> params, List<HashMap<String, Object>> deleteFileList, List<MultipartFile> multipartFileList, List<HashMap<String, Object>> deleteImgFileList, List<MultipartFile> multipartImgList) {
-        HashMap<String, Object> result = new HashMap<>();
-        int intResult= 0;
+        try {
+            HashMap<String, Object> result = new HashMap<>();
+            int intResult = 0;
+            int fileUpdateResult = 0;
+            int fileInsertResult = 0;
+            int imgFileUpdateResult = 0;
+            int imgFileInsertResult = 0;
 
-        List<String> wordList = wordMngDAO.findWordList();
+            List<String> wordList = wordMngDAO.findWordList();
 
-        // 금지어 포함 여부 체크
-        // 제목에 금지어가 포함되어있는가?
-        String bbsNm = (params.get("bbsNm") != null) ? params.get("bbsNm").toString() : null;
-        if(bbsNm != null && !bbsNm.isEmpty()) {
-            for (String word : wordList) {
-                if (bbsNm.contains(word)) {
-                    result.put("result", -1);
-                    result.put("word", word);
-                    return result;
+            // 금지어 포함 여부 체크
+            String bbsNm = (params.get("bbsNm") != null) ? params.get("bbsNm").toString() : null;
+            String content = params.get("bbsCn").toString();
+            if (bbsNm != null && !bbsNm.isEmpty()) {
+                for (String word : wordList) {
+                    // 제목에 금지어가 포함되어있는가?
+                    if (bbsNm.contains(word)) {
+                        throw new CustomPrhibtWordException("제목에 금지어가 포함되어있습니다.", word);
+                    }
+                    // 내용에 금지어가 포함되어있는가?
+                    if (content.contains(word)) {
+                        throw new CustomPrhibtWordException("내용에 금지어가 포함되어있습니다.", word);
+                    }
                 }
             }
-        }
 
-        // 내용에 금지어가 포함되어있는가?
-        String content = params.get("bbsCn").toString();
-        for (String word : wordList) {
-            if (content.contains(word)) {
-                result.put("result", -1);
-                result.put("word", word);
-                return result;
+            // 등록된 토큰에서 사용자 정보 조회
+            String writer = jwtUtil.getWriter();
+            if (writer == null || writer.isEmpty()) {
+                throw new CustomNotFoundException("사용자 정보 조회에 실패했습니다.");
             }
+            params.put("mdfr", writer);
+
+            // youtube 링크 여부에 따라 처리
+            if (params.get("vdoUrl") != null) {
+                params.put("vdoUrl", vdoUrlCheck(params.get("vdoUrl").toString()));
+            }
+
+            // 파일 업로드
+            FileMngVO fileMngVO = new FileMngVO();
+            if (params.get("atchFileMngId") != null) {
+                // 파일매니저 수정
+                String fileMngId = params.get("atchFileMngId").toString();
+                fileMngVO.setFileMngId(fileMngId);
+                fileUpdateResult = fileMngService.fileMngUpadate(fileMngVO, deleteFileList, multipartFileList);
+            } else if (multipartFileList != null && !multipartFileList.isEmpty()) {
+                // 파일매니저 등록
+                HashMap<String, Object> fileMng = fileMngService.fileMngInsert(fileMngVO, multipartFileList);
+                fileInsertResult = (int) fileMng.get("fileMngResult");
+                params.put("atchFileMngId", fileMng.get("fileMngId").toString());
+            }
+
+            // 이미지 파일 업로드
+            FileMngVO fileImgMngVO = new FileMngVO();
+            if (params.get("imgFileMngId") != null) {
+                // 파일매니저 수정
+                String imgFileMng = params.get("imgFileMngId").toString();
+                fileImgMngVO.setFileMngId(imgFileMng);
+                imgFileUpdateResult = fileMngService.fileMngUpadate(fileImgMngVO, deleteImgFileList, multipartImgList);
+            } else if (multipartImgList != null && !multipartImgList.isEmpty()) {
+                // 파일매니저 등록
+                HashMap<String, Object> imgFileMng = fileMngService.fileMngInsert(fileImgMngVO, multipartImgList);
+                imgFileInsertResult = (int) imgFileMng.get("fileMngResult");
+                params.put("imgFileMngId", imgFileMng.get("fileMngId").toString());
+            }
+
+            // 질의형인 경우 \n을 <br>로 변경
+            if (params.get("bbsNm") == null) {
+                String text = params.get("bbsCn").toString().replaceAll("\n", "<br/>");
+                params.put("bbsCn", text);
+            }
+
+            // 게시판 내용 수정
+            intResult = bbsCnDAO.update(params);
+            if (intResult == 0) {
+                throw new CustomUpdateFailException("게시판 내용 수정에 실패했습니다.");
+            }
+
+            result.put("result", intResult);
+            return result;
+        } catch (CustomNotFoundException | CustomFileUploadFailException | CustomInsertFailException | CustomUpdateFailException | IllegalArgumentException
+                | CustomDeleteFailException le) {
+            throw le;
+        }  catch (DataAccessException dae) {
+            throw dae;
+        } catch (Exception e) {
+            throw e;
         }
-
-        // 등록된 토큰에서 사용자 정보 조회
-        String writer = jwtUtil.getWriter();
-        params.put("mdfr", writer);
-
-        // youtube 링크 여부에 따라 처리
-        if(params.get("vdoUrl") != null){
-            params.put("vdoUrl", vdoUrlCheck(params.get("vdoUrl").toString()));
-        }
-
-        // 파일 업로드
-        FileMngVO fileMngVO = new FileMngVO();
-        if (params.get("atchFileMngId") != null) {
-            // 파일매니저 수정
-            String fileMngId = params.get("atchFileMngId").toString();
-            fileMngVO.setFileMngId(fileMngId);
-            intResult += fileMngService.fileMngUpadate(fileMngVO, deleteFileList, multipartFileList);
-        } else if (multipartFileList != null && !multipartFileList.isEmpty()){
-            // 파일매니저 등록
-            HashMap<String, Object> fileMng = fileMngService.fileMngInsert(fileMngVO, multipartFileList);
-            intResult += (int)fileMng.get("fileMngResult");
-            params.put("atchFileMngId", fileMng.get("fileMngId").toString());
-        }
-
-        // 이미지 파일 업로드
-        FileMngVO fileImgMngVO = new FileMngVO();
-        if (params.get("imgFileMngId") != null) {
-            // 파일매니저 수정
-            String imgFileMng = params.get("imgFileMngId").toString();
-            fileImgMngVO.setFileMngId(imgFileMng);
-            intResult += fileMngService.fileMngUpadate(fileImgMngVO, deleteImgFileList, multipartImgList);
-        } else if (multipartImgList != null && !multipartImgList.isEmpty()){
-            // 파일매니저 등록
-            HashMap<String, Object> imgFileMng = fileMngService.fileMngInsert(fileImgMngVO, multipartImgList);
-            intResult += (int)imgFileMng.get("fileMngResult");
-            params.put("imgFileMngId", imgFileMng.get("fileMngId").toString());
-        }
-
-        // 질의형인 경우 \n을 <br>로 변경
-        if(params.get("bbsNm") == null){
-            String text = params.get("bbsCn").toString().replaceAll("\n", "<br/>");
-            params.put("bbsCn", text);
-        }
-
-        // 게시판 내용 수정
-        intResult += bbsCnDAO.update(params);
-
-        result.put("result", intResult);
-        return result;
     }
 
     /**
@@ -400,10 +453,11 @@
             throw e;
         }
     }
+
     /**
-     * @author 방선주
-     * @since  2024.05.21
-     *
+     * @param vdoUrl - 비디오 링크
+     * @return String - 변환 비디오 링크
+     * 
      * vdoUrl 조건 처리
      */
      private String vdoUrlCheck(String vdoUrl) {
@@ -425,7 +479,7 @@
      * @throws DataAccessException - db 관련 예외 발생 시
      * @throws Exception - 그 외 예외 발생 시
      *
-     * 조회수 증가 처리
+     * 조회수 증가
      */
     @Override
     public int updateVwCnt(HashMap<String, Object> params) {
@@ -484,91 +538,128 @@
     }
 
     /**
+     * @param fileMngId - 파일매니저 아이디
+     * @return List<HashMap<String, Object>> - 파일매니저 목록
+     * @throws DataAccessException - db 관련 예외 발생 시
+     * @throws Exception - 그 외 예외 발생 시
+     *
      * 첨부파일 이미지 경로 변경
-     * @param fileMngId
-     * @return
-     * @throws Exception
      */
     @Override
     public List<HashMap<String, Object>> fileListPathChange(String fileMngId) {
+        try {
+            List<HashMap<String, Object>> fileList = fileDAO.fileSelectList(fileMngId);
 
-        List<HashMap<String, Object>> fileList = fileDAO.fileSelectList(fileMngId);
-
-        for (HashMap<String, Object> file : fileList) {
-            String absltPath = file.get("absltPath").toString();
-            file.put("absltPath", convertPathToUrl(absltPath));
+            for (HashMap<String, Object> file : fileList) {
+                String absltPath = file.get("absltPath").toString();
+                file.put("absltPath", convertPathToUrl(absltPath));
+            }
+            return fileList;
+        } catch (DataAccessException dae) {
+            throw dae;
+        } catch (Exception e) {
+            throw e;
         }
-        return fileList;
     }
 
     /**
+     * @param bbsCnVO - 게시판 내용 정보
+     * @return HashMap<String, Object> - 답변 등록 결과
+     * @throws CustomNotFoundException - 사용자 정보 조회 예외 발생 시
+     * @throws CustomPrhibtWordException - 금지어 포함 예외 발생 시
+     * @throws CustomInsertFailException - 답변 등록 예외 발생 시
+     * @throws DataAccessException - db 관련 예외 발생 시
+     * @throws Exception - 그 외 예외 발생 시
+     *
      * 질의형 게시판 답변 등록
-     * @param bbsCnVO
-     * @return
-     * @throws Exception
      */
     @Override
     public HashMap<String, Object> saveAnswer(BbsCnVO bbsCnVO) {
-        HashMap<String, Object> result = new HashMap<>();
-        // 등록된 토큰에서 사용자 정보 조회
-        String writer = jwtUtil.getWriter();
-        bbsCnVO.setAnswer(writer);
-
-        // 답변 금지어 포함 여부 체크
-        List<String> wordList = wordMngDAO.findWordList();
-        String ansCn = bbsCnVO.getAnsCn();
-        for (String word : wordList) {
-            if (ansCn.contains(word)) {
-                result.put("result", -1);
-                result.put("word", word);
-                return result;
+        try {
+            HashMap<String, Object> result = new HashMap<>();
+            // 등록된 토큰에서 사용자 정보 조회
+            String writer = jwtUtil.getWriter();
+            if (writer == null || writer.isEmpty()) {
+                throw new CustomNotFoundException("사용자 정보 조회에 실패했습니다.");
             }
+            bbsCnVO.setAnswer(writer);
+
+            // 답변 금지어 포함 여부 체크
+            List<String> wordList = wordMngDAO.findWordList();
+            String ansCn = bbsCnVO.getAnsCn();
+            for (String word : wordList) {
+                if (ansCn.contains(word)) {
+                    throw new CustomPrhibtWordException("내용에 금지어가 포함되어있습니다.", word);
+                }
+            }
+
+            // 질의형인 경우 \n을 <br>로 변경
+            if (bbsCnVO.getBbsNm() == null) {
+                String text = bbsCnVO.getAnsCn().replaceAll("\n", "<br/>");
+                bbsCnVO.setAnsCn(text);
+            }
+
+            int saveAns = bbsCnDAO.saveAnswer(bbsCnVO);
+            if (saveAns == 0) {
+                throw new CustomInsertFailException("답변 등록에 실패했습니다.");
+            }
+
+            result.put("result", saveAns);
+            return result;
+        } catch (DataAccessException dae) {
+            throw dae;
+        } catch (Exception e) {
+            throw e;
         }
-
-        // 질의형인 경우 \n을 <br>로 변경
-        if(bbsCnVO.getBbsNm() == null){
-            String text = bbsCnVO.getAnsCn().replaceAll("\n", "<br/>");
-            bbsCnVO.setAnsCn(text);
-        }
-
-        int saveAns = bbsCnDAO.saveAnswer(bbsCnVO);
-
-        result.put("result", saveAns);
-        return result;
     }
 
     /**
+     * @param bbsCnVO - 게시판 내용 정보
+     * @return HashMap<String, Object> - 답변 수정 결과
+     * @throws CustomNotFoundException - 사용자 정보 조회 예외 발생 시
+     * @throws CustomPrhibtWordException - 금지어 포함 예외 발생 시
+     * @throws CustomUpdateFailException - 답변 등록 예외 발생 시
+     * @throws DataAccessException - db 관련 예외 발생 시
+     * @throws Exception - 그 외 예외 발생 시
+     *
      * 질의형 게시판 답변 수정
-     * @param bbsCnVO
-     * @return
-     * @throws Exception
      */
     @Override
     public HashMap<String, Object> updateAnswer(BbsCnVO bbsCnVO) {
-        HashMap<String, Object> result = new HashMap<>();
+        try {
+            HashMap<String, Object> result = new HashMap<>();
 
-        // 등록된 토큰에서 사용자 정보 조회
-        String writer = jwtUtil.getWriter();
-        bbsCnVO.setAnswer(writer);
-
-        // 답변 금지어 포함 여부 체크
-        List<String> wordList = wordMngDAO.findWordList();
-        String ansCn = bbsCnVO.getAnsCn();
-        for (String word : wordList) {
-            if (ansCn.contains(word)) {
-                result.put("result", -1);
-                result.put("word", word);
-                return result;
+            // 등록된 토큰에서 사용자 정보 조회
+            String writer = jwtUtil.getWriter();
+            if (writer == null || writer.isEmpty()) {
+                throw new CustomNotFoundException("사용자 정보 조회에 실패했습니다.");
             }
+            bbsCnVO.setAnswer(writer);
+
+            // 답변 금지어 포함 여부 체크
+            List<String> wordList = wordMngDAO.findWordList();
+            String ansCn = bbsCnVO.getAnsCn();
+            for (String word : wordList) {
+                if (ansCn.contains(word)) {
+                    throw new CustomPrhibtWordException("내용에 금지어가 포함되어있습니다.", word);
+                }
+            }
+
+            String text = bbsCnVO.getAnsCn().replaceAll("\n", "<br/>");
+            bbsCnVO.setAnsCn(text);
+
+            int saveAns = bbsCnDAO.saveAnswer(bbsCnVO);
+            if (saveAns == 0) {
+                throw new CustomUpdateFailException("답변 수정에 실패했습니다.");
+            }
+
+            result.put("result", saveAns);
+            return result;
+        } catch (DataAccessException dae) {
+            throw dae;
+        } catch (Exception e) {
+            throw e;
         }
-
-        String text = bbsCnVO.getAnsCn().replaceAll("\n", "<br/>");
-        bbsCnVO.setAnsCn(text);
-
-        int saveAns = bbsCnDAO.saveAnswer(bbsCnVO);
-
-        result.put("result", saveAns);
-        return result;
     }
 
     /**
src/main/java/com/takensoft/cms/bbs/web/BbsCnController.java
--- src/main/java/com/takensoft/cms/bbs/web/BbsCnController.java
+++ src/main/java/com/takensoft/cms/bbs/web/BbsCnController.java
@@ -35,6 +35,12 @@
  * @modification
  *     since    |    author    | description
  *  2024.05.09  |    하석형     | 최초 등록
+ *  2024.05.21  |    방선주     | saveBbsCn, updateBbsCn, fileDownload 추가
+ *  2024.05.22  |    방선주     | updateVwCnt 추가
+ *  2024.05.31  |    방선주     | ansSaveProc, ansUpdateProc 추가
+ *  2024.06.07  |    방선주     | ansDeleteProc 추가
+ *  2024.06.13  |    방선주     | findFiveNotice 추가
+ *  2025.03.21  |    하석형     | 코드 리펙토링
  *
  * 게시판 내용 관련 컨트롤러
  */
@@ -50,73 +56,23 @@
     private final FileService fileService;
 
     /**
-     * @author  하석형
-     * @since   2024.05.09
-     * @param   bbsCnVO
-     * @return
-     * @throws  Exception
-     *
-     * 게시판 내용 등록
-     */
-//    @PostMapping("/saveProc.json")
-//    public ResponseEntity<?> saveProc(@RequestBody BbsCnVO bbsCnVO) throws Exception {
-//        // 응답 처리
-//        HttpHeaders headers = new HttpHeaders();
-//        headers.setContentType(new MediaType("application", "json", Charset.forName("UTF-8")));
-//        ResponseData responseData = new ResponseData();
-//
-//        // 게시판 내용 등록
-//        int result = bbsCnService.saveBbsCn(bbsCnVO);
-//        if(result > 0) {
-//            responseData.setStatus(HttpStatus.OK);
-//            responseData.setMessage("정상적으로 등록 처리되었습니다.");
-//            responseData.setData(result);
-//            return new ResponseEntity<>(responseData, headers, HttpStatus.OK);
-//        } else {
-//            responseData.setStatus(HttpStatus.INTERNAL_SERVER_ERROR);
-//            responseData.setMessage("등록에 실패하였습니다.\n담당자에게 문의하세요.");
-//            return new ResponseEntity<>(responseData, headers, HttpStatus.INTERNAL_SERVER_ERROR);
-//        }
-//    }
-    /**
-     * @author 방선주
-     * @since 2024.05.21
-     * @param bbsCn, multipartFileList
-     * @return
-     * @throws Exception
+     * @param bbsCn - 게시판 내용 정보
+     * @param multipartFileList - 첨부파일 목록
+     * @param multipartImgList - 이미지 파일 목록
+     * @return ResponseEntity - 게시판 내용 등록 결과를 포함하는 응답
      *
      * 게시판 내용 등록
      */
     @PostMapping(path = "/saveBbsCn.file")
     public ResponseEntity<?> saveBbsCn(@RequestPart BbsCnVO bbsCn, List<MultipartFile> multipartFileList, List<MultipartFile> multipartImgList) throws Exception {
-
-        // 응답 처리
-        HttpHeaders headers = new HttpHeaders();
-        headers.setContentType(new MediaType("application", "json", Charset.forName("UTF-8")));
-        ResponseData responseData = new ResponseData();
-
         // 게시판 내용 등록
         HashMap<String, Object> result = bbsCnService.saveBbsCn(bbsCn, multipartFileList, multipartImgList);
-        int insertResult = (int) result.get("result");
-
-        if (insertResult > 0) {
-            return resUtil.successRes(result, MessageCode.COMMON_SUCCESS);
-        } else if (insertResult == -1){
-            responseData.setStatus(HttpStatus.INTERNAL_SERVER_ERROR.value());
-            responseData.setStatusText(HttpStatus.INTERNAL_SERVER_ERROR);
-            responseData.setMessage("아래의 금지어가 포함되어 있습니다.\n* " + result.get("word"));
-            return new ResponseEntity<>(responseData, headers, HttpStatus.INTERNAL_SERVER_ERROR);
-        } else {
-            return resUtil.errorRes(MessageCode.COMMON_INSERT_FAIL);
-        }
+        return resUtil.successRes(result, MessageCode.COMMON_SUCCESS);
     }
 
     /**
-     * @author  하석형
-     * @since   2024.05.09
-     * @param   params
-     * @return
-     * @throws  Exception
+     * @param params - 검색조건 및 페이징 정보
+     * @return ResponseEntity - 게시판 내용 목록 조회 결과를 포함하는 응답
      *
      * 게시판 내용 목록 조회
      */
@@ -124,23 +80,17 @@
     public ResponseEntity<?> findAll(@RequestBody HashMap<String, String> params) throws Exception {
         // 게시판 내용 목록 조회
         Map<String, Object> result = bbsCnService.findAllBbsCn(params);
-
-        // 응답처리
         return resUtil.successRes(result, MessageCode.COMMON_SUCCESS);
     }
 
     /**
-     * @author 하석형
-     * @since  2024.05.09
-     * @param  bbsCnVO
-     * @return
-     * @throws Exception
+     * @param bbsCnVO - 게시판 내용 정보
+     * @return ResponseEntity - 게시판 내용 상세 조회 결과를 포함하는 응답
      *
      * 게시판 내용 상세 조회
      */
     @PostMapping("/findByBbsCn.json")
     public ResponseEntity<?> findByBbsCn(@RequestBody BbsCnVO bbsCnVO) throws Exception {
-
         // 게시판 관리 정보 조회
         BbsMngVO bbsMng = bbsMngService.findByBbsMngId(bbsCnVO.getBbsMngId());
         // 게시판 내용 상세 조회
@@ -151,7 +101,6 @@
         //이미지 파일 목록 조회
         String imgFileMngId = bbsCn.getImgFileMngId();
         List<HashMap<String,Object>> imgFileList = bbsCnService.fileListPathChange(imgFileMngId);
-
 
         // 이전글 다음글 조회
         BbsCnVO prevBbsCn = bbsCnService.findPrevBbsCn(bbsCnVO);
@@ -169,119 +118,53 @@
         return resUtil.successRes(result, MessageCode.COMMON_SUCCESS);
     }
 
-//    /**
-//     * @author 하석형
-//     * @since  2024.05.09
-//     * @param  bbsCnVO
-//     * @return
-//     * @throws Exception
-//     *
-//     * 게시판 내용 수정
-//     */
-//    @PostMapping("/updateProc.json")
-//    public ResponseEntity<?> updateProc(@RequestBody BbsCnVO bbsCnVO) throws Exception {
-//        HttpHeaders headers = new HttpHeaders();
-//        headers.setContentType(new MediaType("application", "json", Charset.forName("UTF-8")));
-//        ResponseData responseData = new ResponseData();
-//
-//        // 게시판 내용 수정
-//        int result = bbsCnService.updateBbsCn(bbsCnVO);
-//
-//        // 응답 처리
-//        if(result > 0) {
-//            responseData.setStatus(HttpStatus.OK);
-//            responseData.setMessage("정상적으로 수정 처리되었습니다.");
-//            return new ResponseEntity<>(responseData, headers, HttpStatus.OK);
-//        } else {
-//            responseData.setStatus(HttpStatus.INTERNAL_SERVER_ERROR);
-//            responseData.setMessage("수정에 실패하였습니다.\n담당자에게 문의하세요.");
-//            return new ResponseEntity<>(responseData, headers, HttpStatus.INTERNAL_SERVER_ERROR);
-//        }
-//    }
     /**
-     * @author 방선주
-     * @since 2024.05.21
-     * @param params, multipartFileList
-     * @return
-     * @throws Exception
+     * @param params - 게시판 내용 정보
+     * @param deleteFileList - 삭제할 파일 목록
+     * @param multipartFileList - 첨부파일 목록
+     * @param deleteImgFileList - 삭제할 이미지 파일 목록
+     * @param multipartImgList - 이미지 파일 목록
+     * @return ResponseEntity - 게시판 내용 수정 결과를 포함하는 응답
      *
      * 게시판 내용 수정
      */
     @PostMapping(path = "/updateBbsCn.file")
     public ResponseEntity<?> updateBbsCn(@RequestPart HashMap<String, Object> params, @RequestPart List<HashMap<String, Object>> deleteFileList, List<MultipartFile> multipartFileList, @RequestPart List<HashMap<String, Object>> deleteImgFileList, List<MultipartFile> multipartImgList) throws Exception {
-
         // 게시판 내용 수정
         HashMap<String, Object> result = bbsCnService.updateBbsCn(params, deleteFileList, multipartFileList, deleteImgFileList, multipartImgList);
-
-        int updateResult = (int) result.get("result");
-        // 응답 처리
-        HttpHeaders headers = new HttpHeaders();
-        headers.setContentType(new MediaType("application", "json", Charset.forName("UTF-8")));
-        ResponseData responseData = new ResponseData();
-        if (updateResult > 0) {
-            return resUtil.successRes(result, MessageCode.COMMON_SUCCESS);
-        } else if (updateResult == -1){
-            responseData.setStatus(HttpStatus.INTERNAL_SERVER_ERROR.value());
-            responseData.setStatusText(HttpStatus.INTERNAL_SERVER_ERROR);
-            responseData.setMessage("아래의 금지어가 포함되어 있습니다.\n* " + result.get("word"));
-            return new ResponseEntity<>(responseData, headers, HttpStatus.INTERNAL_SERVER_ERROR);
-
-        } else {
-            return resUtil.errorRes(MessageCode.COMMON_UPDATE_FAIL);
-        }
+        return resUtil.successRes(result, MessageCode.COMMON_SUCCESS);
     }
 
     /**
-     * @author 하석형
-     * @since  2024.05.09
-     * @param  bbsCnVO
-     * @return
-     * @throws Exception
+     * @param bbsCnVO - 게시판 내용 정보
+     * @return ResponseEntity - 게시판 내용 삭제 결과를 포함하는 응답
      *
      * 게시판 내용 삭제
      */
     @PostMapping("/deleteProc.json")
-    public ResponseEntity<?> deleteProc(@RequestBody BbsCnVO bbsCnVO) throws Exception {
-
+    public ResponseEntity<?> deleteProc(@RequestBody BbsCnVO bbsCnVO) {
         // 게시판 내용 수정
         int result = bbsCnService.deleteBbsCn(bbsCnVO);
-
-        // 응답 처리
-        if(result > 0) {
-            return resUtil.successRes(result, MessageCode.COMMON_SUCCESS);
-        } else {
-            return resUtil.errorRes(MessageCode.COMMON_DELETE_FAIL);
-        }
+        return resUtil.successRes(result, MessageCode.COMMON_SUCCESS);
     }
+    
     /**
-     * @author 방선주
-     * @since  2024.05.22
-     * @param  params
-     * @return
-     * @throws Exception
+     * @param params - 게시판 내용 정보
+     * @return ResponseEntity - 조회수 증가 결과를 포함하는 응답
      *
      * 조회수 증가
      */
     @PostMapping("/updateVwCnt.json")
-    public ResponseEntity<?> updateVwCnt(@RequestBody HashMap<String, Object> params) throws Exception {
-        
+    public ResponseEntity<?> updateVwCnt(@RequestBody HashMap<String, Object> params) {
         // 조회수 증가
         int result = bbsCnService.updateVwCnt(params);
-
-        // 응답 처리
-        if(result > 0) {
-            return resUtil.successRes(result, MessageCode.COMMON_SUCCESS);
-        } else {
-            return resUtil.errorRes(MessageCode.COMMON_UPDATE_FAIL);
-        }
+        return resUtil.successRes(result, MessageCode.COMMON_SUCCESS);
     }
 
     /**
-     * @author 방선주
-     * @since  2024.05.21
-     * @param  fileId
-     * @return
-     * @throws Exception
+     * @param fileId - 첨부파일 아이디
+     * @param response - HTTP 응답 객체
+     * @return ResponseEntity - 댓글 등록 결과를 포함하는 응답
      *
      * 게시판 첨부 파일 다운로드
      */
@@ -314,105 +197,51 @@
     /********* 질의형 게시판 **********/
 
     /**
-     * @author  방선주
-     * @since   2024.05.31
-     * @param   bbsCnVO
-     * @return
-     * @throws  Exception
+     * @param bbsCnVO - 게시판 내용 정보
+     * @return ResponseEntity - 답변 등록 결과를 포함하는 응답
      *
      * 질의형 게시판 답변 등록
      */
     @PostMapping("/ansSaveProc.json")
-    public ResponseEntity<?> ansSaveProc(@RequestBody BbsCnVO bbsCnVO) throws Exception {
-        // 응답 처리
-        HttpHeaders headers = new HttpHeaders();
-        headers.setContentType(new MediaType("application", "json", Charset.forName("UTF-8")));
-        ResponseData responseData = new ResponseData();
-
-//        int result = 1;
+    public ResponseEntity<?> ansSaveProc(@RequestBody BbsCnVO bbsCnVO) {
         HashMap<String, Object> result = bbsCnService.saveAnswer(bbsCnVO);
-        int insertResult = (int) result.get("result");
-
-
-        if(insertResult > 0) {
-            return resUtil.successRes(result, MessageCode.COMMON_SUCCESS);
-        } else if (insertResult == -1){
-            responseData.setStatus(HttpStatus.INTERNAL_SERVER_ERROR.value());
-            responseData.setStatusText(HttpStatus.INTERNAL_SERVER_ERROR);
-            responseData.setMessage("아래의 금지어가 포함되어 있습니다.\n* " + result.get("word"));
-            return new ResponseEntity<>(responseData, headers, HttpStatus.INTERNAL_SERVER_ERROR);
-        } else {
-            return resUtil.errorRes(MessageCode.COMMON_INSERT_FAIL);
-        }
+        return resUtil.successRes(result, MessageCode.COMMON_SUCCESS);
     }
+
     /**
-     * @author  방선주
-     * @since   2024.05.31
-     * @param   bbsCnVO
-     * @return
-     * @throws  Exception
+     * @param bbsCnVO - 게시판 내용 정보
+     * @return ResponseEntity - 답변 등록 결과를 포함하는 응답
      *
      * 질의형 게시판 답변 수정
      */
     @PostMapping("/ansUpdateProc.json")
-    public ResponseEntity<?> ansUpdateProc(@RequestBody BbsCnVO bbsCnVO) throws Exception {
-        // 응답 처리
-        HttpHeaders headers = new HttpHeaders();
-        headers.setContentType(new MediaType("application", "json", Charset.forName("UTF-8")));
-        ResponseData responseData = new ResponseData();
-
-//        int result = 1;
+    public ResponseEntity<?> ansUpdateProc(@RequestBody BbsCnVO bbsCnVO) {
         HashMap<String, Object> result = bbsCnService.updateAnswer(bbsCnVO);
-        int updateResult = (int) result.get("result");
-
-        if(updateResult > 0) {
-            return resUtil.successRes(result, MessageCode.COMMON_SUCCESS);
-        } else if (updateResult == -1){
-            responseData.setStatus(HttpStatus.INTERNAL_SERVER_ERROR.value());
-            responseData.setStatusText(HttpStatus.INTERNAL_SERVER_ERROR);
-            responseData.setMessage("아래의 금지어가 포함되어 있습니다.\n* " + result.get("word"));
-            return new ResponseEntity<>(responseData, headers, HttpStatus.INTERNAL_SERVER_ERROR);
-        } else {
-            return resUtil.errorRes(MessageCode.COMMON_UPDATE_FAIL);
-        }
+        return resUtil.successRes(result, MessageCode.COMMON_SUCCESS);
     }
+
     /**
-     * @author  방선주
-     * @since   2024.06.07
-     * @param   bbsCnVO
-     * @return
-     * @throws  Exception
+     * @param bbsCnVO - 게시판 내용 정보
+     * @return ResponseEntity - 답변 삭제 결과를 포함하는 응답
      *
      * 질의형 게시판 답변 삭제
      */
     @PostMapping("/ansDeleteProc.json")
-    public ResponseEntity<?> ansDeleteProc(@RequestBody BbsCnVO bbsCnVO) throws Exception {
-        // 응답 처리
-
-//        int result = 1;
+    public ResponseEntity<?> ansDeleteProc(@RequestBody BbsCnVO bbsCnVO) {
         int result = bbsCnService.deleteAns(bbsCnVO);
-
-        if(result > 0) {
-            return resUtil.successRes(result, MessageCode.COMMON_SUCCESS);
-        } else {
-            return resUtil.errorRes(MessageCode.COMMON_DELETE_FAIL);
-        }
+        return resUtil.successRes(result, MessageCode.COMMON_SUCCESS);
     }
+
     /**
-     * @author  방선주
-     * @since   2024.06.13
-     * @param
-     * @return
-     * @throws  Exception
+     * @param bbsCn - 게시판 내용 정보
+     * @return ResponseEntity - 게시판 내용 목록 조회 결과를 포함하는 응답
      *
      * 공지사항 최신 5개 조회
      */
     @PostMapping("/findFiveNotice.json")
-    public ResponseEntity<?> findFiveNotice(@RequestBody BbsCnVO bbsCn) throws Exception {
+    public ResponseEntity<?> findFiveNotice(@RequestBody BbsCnVO bbsCn) {
         // 공지사항 최신 5개 조회
         List<BbsCnVO> result = bbsCnService.findFiveNotice(bbsCn);
-
-        // 응답 처리
         return resUtil.successRes(result, MessageCode.COMMON_SUCCESS);
     }
 }
(No newline at end of file)
 
src/main/java/com/takensoft/common/exception/CustomPrhibtWordException.java (added)
+++ src/main/java/com/takensoft/common/exception/CustomPrhibtWordException.java
@@ -0,0 +1,33 @@
+package com.takensoft.common.exception;
+
+/**
+ * @author 하석형
+ * @since 2025.03.21
+ * @modification
+ *     since    |    author    | description
+ *  2025.03.21  |    하석형     | 최초 등록
+ *
+ * RuntimeException - 실행 중 발생하는 예외를 처리하는 기본 클래스
+ *
+ * 금칙어 포함 시 발생하는 예외
+ */
+public class CustomPrhibtWordException extends RuntimeException {
+
+    private String word; // 금지어
+
+    public CustomPrhibtWordException() {
+    }
+
+    public CustomPrhibtWordException(String message, String word) {
+        super(message);
+        this.word = word;
+    }
+
+    public CustomPrhibtWordException(String message, Throwable cause) {
+        super(message, cause);
+    }
+
+    public String getWord() {
+        return word;
+    }
+}(No newline at end of file)
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
@@ -23,7 +23,7 @@
  *     since    |    author    | description
  *  2025.01.22  |  takensoft   | 최초 등록
  *  2025.03.12  |    하석형     | handleCustomCodeDuplicationException, handleCustomDataDuplicationException 추가
- *  2025.03.20  |    하석형     | handleFileSizeLimitExceededException, CustomFileUploadFailException 추가
+ *  2025.03.21  |    하석형     | handleFileSizeLimitExceededException, handleCustomFileUploadFailException, handleCustomPrhibtWordException 추가
  *
  * 스프링 MVC 컨트롤러에서 발생하는 예외를 처리하는 공통 클래스
  */
@@ -295,6 +295,18 @@
     }
 
     /**
+     * @param cpwe - CustomPrhibtWordException 예외 객체
+     * @return CustomPrhibtWordException 대한 HTTP 응답
+     *
+     * CustomPrhibtWordException 발생한 경우
+     */
+    @ExceptionHandler(CustomPrhibtWordException.class)
+    public ResponseEntity<?> handleCustomPrhibtWordException(CustomPrhibtWordException cpwe) {
+        logError(cpwe);
+        return resUtil.errorRes(MessageCode.COMMON_PROHIBITION_WORD, "\n* " + cpwe.getWord());
+    }
+
+    /**
      * @param e - Exception 예외 객체
      * @return 기타 예외에 대한 HTTP 응답
      *
src/main/java/com/takensoft/common/file/service/Impl/FileMngServiceImpl.java
--- src/main/java/com/takensoft/common/file/service/Impl/FileMngServiceImpl.java
+++ src/main/java/com/takensoft/common/file/service/Impl/FileMngServiceImpl.java
@@ -47,39 +47,49 @@
      *  - fileMngResult : 파일매니저 등록 결과
      * @throws CustomNotFoundException - 사용자 정보 조회 예외 발생 시
      * @throws CustomInsertFailException - 파일매니저 등록 예외 발생 시
+     * @throws DataAccessException - db 관련 예외 발생 시
+     * @throws Exception - 그 외 예외 발생 시
      *
      * 파일매니저 등록
      */
     @Override
     public HashMap<String, Object> fileMngInsert(FileMngVO fileMngVO, List<MultipartFile> multipartFileList) {
-        HashMap<String, Object> result = new HashMap<>();
-        result.put("fileInsertResult", 0);
+        try {
+            HashMap<String, Object> result = new HashMap<>();
+            result.put("fileInsertResult", 0);
 
-        // 파일관리 아이디 생성
-        String fileMngId = fileMngIdgn.getNextStringId();
-        fileMngVO.setFileMngId(fileMngId);
+            // 파일관리 아이디 생성
+            String fileMngId = fileMngIdgn.getNextStringId();
+            fileMngVO.setFileMngId(fileMngId);
 
-        // 작성자 생성
-        String writer = jwtUtil.getWriter();
-        if (writer == null || writer.isEmpty()) {
-            throw new CustomNotFoundException("사용자 정보 조회에 실패했습니다.");
+            // 작성자 생성
+            String writer = jwtUtil.getWriter();
+            if (writer == null || writer.isEmpty()) {
+                throw new CustomNotFoundException("사용자 정보 조회에 실패했습니다.");
+            }
+            fileMngVO.setRgtr(writer);
+
+            // 파일 등록
+            result.put("fileInsertResult", fileService.fileInsert(fileMngId, multipartFileList));
+
+            // 파일매니저 아이디 삽입
+            result.put("fileMngId", fileMngId);
+
+            // DB 등록
+            int fileMngResult = fileMngDAO.fileMngInsert(fileMngVO);
+            if (fileMngResult == 0) {
+                throw new CustomInsertFailException("파일매니저 등록에 실패했습니다.");
+            }
+            result.put("fileMngResult", fileMngResult);
+
+            return result;
+        } catch (CustomNotFoundException | CustomFileUploadFailException | CustomInsertFailException | IllegalArgumentException le) {
+            throw le;
+        }  catch (DataAccessException dae) {
+            throw dae;
+        } catch (Exception e) {
+            throw e;
         }
-        fileMngVO.setRgtr(writer);
-
-        // 파일 등록
-        result.put("fileInsertResult", fileService.fileInsert(fileMngId, multipartFileList));
-
-        // 파일매니저 아이디 삽입
-        result.put("fileMngId", fileMngId);
-
-        // DB 등록
-        int fileMngResult = fileMngDAO.fileMngInsert(fileMngVO);
-        if (fileMngResult == 0) {
-            throw new CustomInsertFailException("파일매니저 등록에 실패했습니다.");
-        }
-        result.put("fileMngResult", fileMngResult);
-
-        return result;
     }
 
     /**
@@ -89,65 +99,86 @@
      * @return int - 파일매니저 수정 결과
      * @throws CustomNotFoundException - 사용자 정보 조회 예외 발생 시
      * @throws CustomUpdateFailException - 파일매니저 수정 예외 발생 시
+     * @throws DataAccessException - db 관련 예외 발생 시
+     * @throws Exception - 그 외 예외 발생 시
      *
      * 파일매니저 수정
      */
     @Override
     public int fileMngUpadate(FileMngVO fileMngVO, List<HashMap<String, Object>> deleteFileList, List<MultipartFile> multipartFileList) {
-        int insertResult = 0;
-        int deleteResult = 0;
-        int result = 0;
+        try {
+            int insertResult = 0;
+            int deleteResult = 0;
+            int result = 0;
 
-        // 수정자 생성
-        String writer = jwtUtil.getWriter();
-        if(writer == null || writer.isEmpty()){
-            throw new CustomNotFoundException("사용자 정보 조회에 실패했습니다.");
-        }
-        fileMngVO.setMdfr(writer);
+            // 수정자 생성
+            String writer = jwtUtil.getWriter();
+            if (writer == null || writer.isEmpty()) {
+                throw new CustomNotFoundException("사용자 정보 조회에 실패했습니다.");
+            }
+            fileMngVO.setMdfr(writer);
 
-        // 파일 추가
-        if (multipartFileList != null && multipartFileList.size() > 0) {
+            // 파일 추가
+            if (multipartFileList != null && multipartFileList.size() > 0) {
+                // DB 등록
+                String fileMngId = fileMngVO.getFileMngId();
+                insertResult = fileService.fileInsert(fileMngId, multipartFileList);
+            }
+
+            // 파일 삭제
+            if (deleteFileList != null && deleteFileList.size() > 0) {
+                deleteResult = fileService.fileDelete(deleteFileList);
+            }
+
             // DB 등록
-            String fileMngId = fileMngVO.getFileMngId();
-            insertResult = fileService.fileInsert(fileMngId, multipartFileList);
-        }
+            result = fileMngDAO.fileMngUpadate(fileMngVO);
+            if (result == 0) {
+                throw new CustomUpdateFailException("파일매니저 수정에 실패했습니다.");
+            }
 
-        // 파일 삭제
-        if (deleteFileList != null && deleteFileList.size() > 0) {
-            deleteResult = fileService.fileDelete(deleteFileList);
+            return result;
+        } catch (CustomNotFoundException | CustomFileUploadFailException | CustomInsertFailException | IllegalArgumentException
+                 | CustomDeleteFailException le) {
+            throw le;
+        } catch (DataAccessException dae) {
+            throw dae;
+        } catch (Exception e) {
+            throw e;
         }
-
-        // DB 등록
-        result = fileMngDAO.fileMngUpadate(fileMngVO);
-        if(result == 0){
-            throw new CustomUpdateFailException("파일매니저 수정에 실패했습니다.");
-        }
-
-        return result;
     }
 
     /**
      * @param params - 파일매니저 아이디
      * @return int - 파일매니저 삭제 결과
      * @throws CustomDeleteFailException - 파일매니저 삭제 예외 발생 시
+     * @throws DataAccessException - db 관련 예외 발생 시
+     * @throws Exception - 그 외 예외 발생 시
      *
      * 파일매니저 삭제
      */
     @Override
     public int fileMngDelete(HashMap<String, Object> params) {
-        int deleteResult = 0;
-        int result = 0;
+        try {
+            int deleteResult = 0;
+            int result = 0;
 
-        // 파일 삭제
-        List<HashMap<String, Object>> fileList = fileService.fileSelectList(params.get("fileMngId").toString());
-        deleteResult = fileService.fileDelete(fileList);
+            // 파일 삭제
+            List<HashMap<String, Object>> fileList = fileService.fileSelectList(params.get("fileMngId").toString());
+            deleteResult = fileService.fileDelete(fileList);
 
-        // DB 등록
-        result = fileMngDAO.fileMngDelete(params);
-        if(result == 0){
-            throw new CustomDeleteFailException("파일매니저 삭제에 실패했습니다.");
+            // DB 등록
+            result = fileMngDAO.fileMngDelete(params);
+            if (result == 0) {
+                throw new CustomDeleteFailException("파일매니저 삭제에 실패했습니다.");
+            }
+
+            return result;
+        } catch (CustomDeleteFailException le) {
+            throw le;
+        } catch (DataAccessException dae) {
+            throw dae;
+        } catch (Exception e) {
+            throw e;
         }
-
-        return result;
     }
 }
(No newline at end of file)
src/main/java/com/takensoft/common/file/service/Impl/FileServiceImpl.java
--- src/main/java/com/takensoft/common/file/service/Impl/FileServiceImpl.java
+++ src/main/java/com/takensoft/common/file/service/Impl/FileServiceImpl.java
@@ -69,11 +69,11 @@
      * @param fileMngId - 파일관리아이디
      * @param multipartFileList - 파일 목록
      * @return int - 파일 등록 결과
+     * @throws IllegalArgumentException - 잘못된 인자 예외 발생 시
      * @throws RuntimeException - 파일 크기 초과 예외 발생 시
      * @throws CustomInsertFailException - 파일 등록 예외 발생 시
      * @throws CustomNotFoundException - 사용자 정보 조회 예외 발생 시
      * @throws CustomFileUploadFailException - 파일 업로드 예외 발생 시
-     * @throws IllegalArgumentException - 잘못된 인자 예외 발생 시
      * @throws DataAccessException - db 관련 예외 발생 시
      * @throws Exception - 그 외 예외 발생 시
      *
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
@@ -10,6 +10,7 @@
  * @modification
  *     since    |    author    | description
  *  2025.01.22  |  takensoft   | 최초 등록
+ *  2025.03.21  |    하석형     | FILE_UPLOAD_FAIL, COMMON_PROHIBITION_WORD 추가
  *
  * 시스템에서 발생할 수 있는 코드 메시지들을 정의
  */
@@ -30,6 +31,7 @@
     COMMON_PAYLOAD_TOO_LARGE("common.payload_too_large",HttpStatus.PAYLOAD_TOO_LARGE), //파일 용량 초과 시
     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), //금지어 사용 시
 
     //네트워크 관련
     NETWORK_UNKNOWN_HOST("network.unknown_host", HttpStatus.BAD_REQUEST), // 알 수 없는 호스트
src/main/java/com/takensoft/common/util/ResponseUtil.java
--- src/main/java/com/takensoft/common/util/ResponseUtil.java
+++ src/main/java/com/takensoft/common/util/ResponseUtil.java
@@ -19,6 +19,7 @@
  * @modification
  *     since    |    author    | description
  *  2025.01.22  |  takensoft   | 최초 등록
+ *  2025.03.21  |    하석형     | 에러 응답 추가 메세지 추가
  *
  * HTTP 응답 처리를 위한 유틸리티
  */
@@ -87,10 +88,21 @@
      * 에러 응답 생성
      */
     public ResponseEntity<?> errorRes(MessageCode messageCode) {
+        return errorRes(messageCode, "");
+    }
+
+    /**
+     * @param messageCode - 응답 메시지 코드
+     * @param addMessage  - 추가 메시지
+     * @return 에러 응답 결과
+     *
+     * 에러 응답 생성
+     */
+    public ResponseEntity<?> errorRes(MessageCode messageCode, String addMessage) {
         ResponseData responseData = new ResponseData();
                      responseData.setStatus(messageCode.getStatus().value());
                      responseData.setStatusText(messageCode.getStatus());
-                     responseData.setMessage(getMessage(messageCode));
+                     responseData.setMessage(getMessage(messageCode) + (addMessage != null ? addMessage : ""));
         return new ResponseEntity<>(responseData, createHeaders(), messageCode.getStatus());
     }
 }
src/main/resources/message/messages_en.yml
--- src/main/resources/message/messages_en.yml
+++ src/main/resources/message/messages_en.yml
@@ -13,6 +13,7 @@
   payload_too_large : "File size limit exceeded."
   duplication_code: "This code already exists."
   duplication_data: "This data already exists."
+  prohibition_word: "Contains prohibited words."
 
 
 # 네트워크 관련
src/main/resources/message/messages_ko.yml
--- src/main/resources/message/messages_ko.yml
+++ src/main/resources/message/messages_ko.yml
@@ -13,6 +13,7 @@
   payload_too_large: "파일 용량 제한을 초과했습니다."
   duplication_code: "이미 존재하는 코드입니다."
   duplication_data: "이미 존재하는 정보입니다."
+  prohibition_word: "금지어가 포함되어 있습니다."
 
 # 네트워크 관련
 network:
Add a comment
List