
250321 하석형 게시판 내용 관련 throws Exception -> try catch 변경
@3de6e1a16519dcbc2f502c1505f1d7396e3c4788
--- src/main/java/com/takensoft/cms/bbs/service/BbsCnService.java
+++ src/main/java/com/takensoft/cms/bbs/service/BbsCnService.java
... | ... | @@ -3,6 +3,8 @@ |
3 | 3 |
import com.takensoft.cms.bbs.vo.BbsCnVO; |
4 | 4 |
import com.takensoft.cms.popup.vo.PopupVO; |
5 | 5 |
import com.takensoft.common.Pagination; |
6 |
+import com.takensoft.common.exception.CustomDataDuplicationException; |
|
7 |
+import org.springframework.dao.DataAccessException; |
|
6 | 8 |
import org.springframework.web.multipart.MultipartFile; |
7 | 9 |
|
8 | 10 |
import java.util.HashMap; |
... | ... | @@ -10,124 +12,158 @@ |
10 | 12 |
import java.util.Map; |
11 | 13 |
|
12 | 14 |
/** |
13 |
- * @author : 하석형 |
|
14 |
- * @since : 2024.05.09 |
|
15 |
+ * @author 하석형 |
|
16 |
+ * @since 2024.05.09 |
|
17 |
+ * @modification |
|
18 |
+ * since | author | description |
|
19 |
+ * 2024.05.09 | 하석형 | 최초 등록 |
|
20 |
+ * 2024.05.22 | 방선주 | updateVwCnt 추가 |
|
21 |
+ * 2024.05.23 | 방선주 | findPrevBbsCn, findNextBbsCn 추가 |
|
22 |
+ * 2024.05.28 | 박정하 | selectBbsCnListByNew 추가 |
|
23 |
+ * 2024.05.30 | 방선주 | fileListPathChange 추가 |
|
24 |
+ * 2024.05.31 | 방선주 | saveAnswer, updateAnswer 추가 |
|
25 |
+ * 2024.06.07 | 방선주 | deleteAns 추가 |
|
26 |
+ * 2024.06.13 | 방선주 | findFiveNotice 추가 |
|
27 |
+ * 2025.03.20 | 하석형 | 코드 리펙토링 |
|
15 | 28 |
* |
16 |
- * 게시판 관리 관련 인터페이스 |
|
29 |
+ * 게시판 내용 관련 인터페이스 |
|
17 | 30 |
*/ |
18 | 31 |
public interface BbsCnService { |
32 |
+ |
|
19 | 33 |
/** |
20 |
- * @author 하석형 |
|
21 |
- * @since 2024.05.09 |
|
34 |
+ * @param bbsCnVO - 게시판 정보 |
|
35 |
+ * @return boolean - 게시판 아이디 중복 여부 |
|
36 |
+ * |
|
22 | 37 |
* 게시판 아이디 중복 검사 |
23 | 38 |
*/ |
24 | 39 |
public boolean bbsCnIdCheck(BbsCnVO bbsCnVO); |
25 | 40 |
|
26 | 41 |
/** |
27 |
- * @author 하석형 |
|
28 |
- * @since 2024.05.09 |
|
42 |
+ * @param bbsCn - 게시판 내용 정보 |
|
43 |
+ * @param multipartFileList - 첨부파일 목록 |
|
44 |
+ * @param multipartImgList - 이미지파일 목록 |
|
45 |
+ * @return HashMap<String, Object> |
|
46 |
+ * - bbsId : 게시판 아이디 |
|
47 |
+ * - result : 게시판 내용 등록 결과 |
|
48 |
+ * |
|
29 | 49 |
* 게시판 내용 등록 |
30 | 50 |
*/ |
31 | 51 |
public HashMap<String, Object> saveBbsCn(BbsCnVO bbsCn, List<MultipartFile> multipartFileList, List<MultipartFile> multipartImgList); |
32 | 52 |
|
33 | 53 |
/** |
34 |
- * @author 하석형 |
|
35 |
- * @since 2024.05.13 |
|
54 |
+ * @param pagination - 페이징 정보 |
|
55 |
+ * @return int - 게시판 내용 목록 조회 개수 |
|
56 |
+ * |
|
36 | 57 |
* 게시판 내용 목록 조회 개수 |
37 | 58 |
*/ |
38 | 59 |
public int findAllCnt(Pagination pagination); |
39 | 60 |
|
40 | 61 |
/** |
41 |
- * @author 하석형 |
|
42 |
- * @since 2024.05.09 |
|
62 |
+ * @param params - 게시판 정보 |
|
63 |
+ * @return Map<String, Object> |
|
64 |
+ * - list : 게시판 내용 목록 |
|
65 |
+ * - pagination : 페이징 정보 |
|
66 |
+ * - codeList : 검색 조건 |
|
67 |
+ * - bbsMng : 게시판 관리 정보 |
|
68 |
+ * |
|
43 | 69 |
* 게시판 내용 목록 조회 |
44 | 70 |
*/ |
45 | 71 |
public Map<String, Object> findAllBbsCn(HashMap<String, String> params); |
46 | 72 |
|
47 | 73 |
/** |
48 |
- * @author 하석형 |
|
49 |
- * @since 2024.05.09 |
|
74 |
+ * @param bbsId - 게시판 아이디 |
|
75 |
+ * @return BbsCnVO - 게시판 내용 정보를 담고 있는 객체 |
|
76 |
+ * @throws DataAccessException - db 관련 예외 발생 시 |
|
77 |
+ * @throws Exception - 그 외 예외 발생 시 |
|
50 | 78 |
* |
51 |
- * 게시판 관리 상세 조회 |
|
79 |
+ * 게시판 내용 상세 조회 |
|
52 | 80 |
*/ |
53 | 81 |
public BbsCnVO findByBbsId(String bbsId); |
54 | 82 |
|
55 | 83 |
/** |
56 |
- * @author 하석형 |
|
57 |
- * @since 2024.05.09 |
|
84 |
+ * @param params - 게시판 정보 |
|
85 |
+ * @param deleteFileList - 삭제 파일 목록 |
|
86 |
+ * @param multipartFileList - 파일 목록 |
|
87 |
+ * @param deleteImgFileList - 삭제 이미지 파일 목록 |
|
88 |
+ * @param multipartImgList - 이미지 파일 목록 |
|
89 |
+ * @return HashMap<String, Object> |
|
90 |
+ * - result : 게시판 내용 수정 결과 |
|
58 | 91 |
* |
59 |
- * 게시판 관리 수정 |
|
92 |
+ * 게시판 내용 수정 |
|
60 | 93 |
*/ |
61 | 94 |
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); |
62 | 95 |
|
63 | 96 |
/** |
64 |
- * @author 하석형 |
|
65 |
- * @since 2024.05.09 |
|
97 |
+ * @param bbsCnVO - 게시판 정보 |
|
98 |
+ * @return int - 게시판 내용 삭제 결과 |
|
66 | 99 |
* |
67 |
- * 게시판 관리 삭제 |
|
100 |
+ * 게시판 내용 삭제 |
|
68 | 101 |
*/ |
69 | 102 |
public int deleteBbsCn(BbsCnVO bbsCnVO); |
70 | 103 |
|
71 | 104 |
/** |
72 |
- * @author 방선주 |
|
73 |
- * @since 2024.05.22 |
|
105 |
+ * @param params - 게시판 정보 |
|
106 |
+ * @return int - 조회수 증가 결과 |
|
74 | 107 |
* |
75 | 108 |
* 조회수 증가 |
76 | 109 |
*/ |
77 | 110 |
public int updateVwCnt(HashMap<String, Object> params); |
78 | 111 |
|
79 | 112 |
/** |
80 |
- * @author 방선주 |
|
81 |
- * @since 2024.05.23 |
|
113 |
+ * @param bbsCnVO - 게시판 정보 |
|
114 |
+ * @return BbsCnVO - 게시판 내용 정보를 담고 있는 객체 |
|
82 | 115 |
* |
83 | 116 |
* 이전글 조회 |
84 | 117 |
*/ |
85 | 118 |
public BbsCnVO findPrevBbsCn(BbsCnVO bbsCnVO); |
86 | 119 |
|
87 | 120 |
/** |
88 |
- * @author 방선주 |
|
89 |
- * @since 2024.05.23 |
|
121 |
+ * @param bbsCnVO - 게시판 정보 |
|
122 |
+ * @return BbsCnVO - 게시판 내용 정보를 담고 있는 객체 |
|
90 | 123 |
* |
91 | 124 |
* 다음글 조회 |
92 | 125 |
*/ |
93 | 126 |
public BbsCnVO findNextBbsCn(BbsCnVO bbsCnVO); |
127 |
+ |
|
94 | 128 |
/** |
95 |
- * @author 방선주 |
|
96 |
- * @since 2024.05.30 |
|
129 |
+ * @param fileMngId - 파일매니저 아이디 |
|
130 |
+ * @return List<HashMap<String, Object>> - 파일매니저 목록 |
|
97 | 131 |
* |
98 | 132 |
* 첨부파일 이미지 경로 변경 |
99 | 133 |
*/ |
100 | 134 |
public List<HashMap<String, Object>> fileListPathChange(String fileMngId); |
101 | 135 |
|
102 | 136 |
/** |
103 |
- * @author 방선주 |
|
104 |
- * @since 2024.05.31 |
|
137 |
+ * @param bbsCnVO - 게시판 내용 정보 |
|
138 |
+ * @return HashMap<String, Object> - 답변 등록 결과 |
|
105 | 139 |
* |
106 |
- * 질의형 답변 등록 |
|
140 |
+ * 질의형 게시판 답변 등록 |
|
107 | 141 |
*/ |
108 | 142 |
public HashMap<String, Object> saveAnswer(BbsCnVO bbsCnVO); |
109 | 143 |
|
110 | 144 |
/** |
111 |
- * @author 방선주 |
|
112 |
- * @since 2024.05.31 |
|
145 |
+ * @param bbsCnVO - 게시판 내용 정보 |
|
146 |
+ * @return HashMap<String, Object> - 답변 수정 결과 |
|
113 | 147 |
* |
114 |
- * 질의형 답변 수정 |
|
148 |
+ * 질의형 게시판 답변 수정 |
|
115 | 149 |
*/ |
116 | 150 |
public HashMap<String, Object> updateAnswer(BbsCnVO bbsCnVO); |
117 | 151 |
|
118 | 152 |
/** |
119 |
- * @author 방선주 |
|
120 |
- * @since 2024.06.07 |
|
153 |
+ * @param bbsCnVO - 게시판 정보 |
|
154 |
+ * @return int - 답변 삭제 결과 |
|
121 | 155 |
* |
122 |
- * 질의형 답변 삭제 |
|
156 |
+ * 질의형 게시판 답변 삭제 |
|
123 | 157 |
*/ |
124 | 158 |
public int deleteAns(BbsCnVO bbsCnVO); |
125 | 159 |
|
126 | 160 |
/** |
127 |
- * @author 방선주 |
|
128 |
- * @since 2024.06.13 |
|
161 |
+ * @param bbsCn - 게시판 정보 |
|
162 |
+ * @return List<BbsCnVO> - 게시판 내용 정보를 담고 있는 객체 목록 |
|
129 | 163 |
* |
130 | 164 |
* 최신 공지 5개 |
131 | 165 |
*/ |
132 | 166 |
public List<BbsCnVO> findFiveNotice(BbsCnVO bbsCn); |
167 |
+ |
|
168 |
+ |
|
133 | 169 |
}(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
... | ... | @@ -35,11 +35,14 @@ |
35 | 35 |
* @modification |
36 | 36 |
* since | author | description |
37 | 37 |
* 2024.05.09 | 하석형 | 최초 등록 |
38 |
- * 2024.05.22 | 방선주 | updateVwCnt 추가 |
|
38 |
+ * 2024.05.22 | 방선주 | vdoUrlCheck, updateVwCnt 추가 |
|
39 | 39 |
* 2024.05.23 | 방선주 | findPrevBbsCn, findNextBbsCn 추가 |
40 | 40 |
* 2024.05.28 | 박정하 | selectBbsCnListByNew 추가 |
41 |
- * 2024.06.04 | 방선주 | saveAnswer 추가 |
|
41 |
+ * 2024.05.30 | 방선주 | fileListPathChange 추가 |
|
42 |
+ * 2024.06.04 | 방선주 | saveAnswer, updateAnswer 추가 |
|
43 |
+ * 2024.06.07 | 방선주 | deleteAns 추가 |
|
42 | 44 |
* 2024.06.13 | 방선주 | findFiveNotice 추가 |
45 |
+ * 2025.03.21 | 하석형 | 코드 리펙토링 |
|
43 | 46 |
* |
44 | 47 |
* EgovAbstractServiceImpl : 전자정부 상속 |
45 | 48 |
* BbsCnService : 게시판 내용 관련 인터페이스 상속 |
... | ... | @@ -97,89 +100,104 @@ |
97 | 100 |
} |
98 | 101 |
|
99 | 102 |
/** |
100 |
- * @author 하석형 |
|
101 |
- * @since 2024.05.09 |
|
103 |
+ * @param bbsCn - 게시판 내용 정보 |
|
104 |
+ * @param multipartFileList - 첨부파일 목록 |
|
105 |
+ * @param multipartImgList - 이미지파일 목록 |
|
106 |
+ * @return HashMap<String, Object> |
|
107 |
+ * - bbsId : 게시판 아이디 |
|
108 |
+ * - result : 게시판 내용 등록 결과 |
|
109 |
+ * @throws CustomPrhibtWordException - 금지어 포함 예외 발생 시 |
|
110 |
+ * @throws CustomNotFoundException - 사용자 정보 조회 예외 발생 시 |
|
111 |
+ * @throws CustomInsertFailException - 게시판 내용 등록 예외 발생 시 |
|
112 |
+ * @throws DataAccessException - db 관련 예외 발생 시 |
|
113 |
+ * @throws Exception - 그 외 예외 발생 시 |
|
114 |
+ * |
|
102 | 115 |
* 게시판 내용 등록 |
103 | 116 |
*/ |
104 | 117 |
@Transactional(rollbackFor = Exception.class) |
105 | 118 |
@Override |
106 | 119 |
public HashMap<String, Object> saveBbsCn(BbsCnVO bbsCn, List<MultipartFile> multipartFileList, List<MultipartFile> multipartImgList) { |
107 |
- HashMap<String, Object> result = new HashMap<>(); |
|
108 |
- List<String> wordList = wordMngDAO.findWordList(); |
|
120 |
+ try { |
|
121 |
+ HashMap<String, Object> result = new HashMap<>(); |
|
122 |
+ List<String> wordList = wordMngDAO.findWordList(); |
|
109 | 123 |
|
110 |
- // 금지어 포함 여부 체크 |
|
111 |
- // 제목에 금지어가 포함되어있는가? |
|
112 |
- if(bbsCn.getBbsNm() != null && !bbsCn.getBbsNm().isEmpty()) { |
|
113 |
- String bbsNm = bbsCn.getBbsNm(); |
|
114 |
- for (String word : wordList) { |
|
115 |
- if (bbsNm.contains(word)) { |
|
116 |
- result.put("result", -1); |
|
117 |
- result.put("word", word); |
|
118 |
- return result; |
|
124 |
+ // 금지어 포함 여부 체크 |
|
125 |
+ if (bbsCn.getBbsNm() != null && !bbsCn.getBbsNm().isEmpty()) { |
|
126 |
+ String bbsNm = bbsCn.getBbsNm(); |
|
127 |
+ String content = bbsCn.getBbsCn(); |
|
128 |
+ for (String word : wordList) { |
|
129 |
+ // 제목에 금지어가 포함되어있는가? |
|
130 |
+ if (bbsNm.contains(word)) { |
|
131 |
+ throw new CustomPrhibtWordException("제목에 금지어가 포함되어있습니다.", word); |
|
132 |
+ } |
|
133 |
+ // 내용에 금지어가 포함되어있는가? |
|
134 |
+ if (content.contains(word)) { |
|
135 |
+ throw new CustomPrhibtWordException("내용에 금지어가 포함되어있습니다.", word); |
|
136 |
+ } |
|
137 |
+ } |
|
119 | 138 |
} |
120 |
- } |
|
121 |
- } |
|
122 | 139 |
|
123 |
- // 내용에 금지어가 포함되어있는가? |
|
124 |
- String content = bbsCn.getBbsCn(); |
|
125 |
- for (String word : wordList) { |
|
126 |
- if (content.contains(word)) { |
|
127 |
- result.put("result", -1); |
|
128 |
- result.put("word", word); |
|
129 |
- return result; |
|
140 |
+ // 게시판 내용 아이디 생성 |
|
141 |
+ String bbsId = bbsIdgn.getNextStringId(); |
|
142 |
+ bbsCn.setBbsId(bbsId); |
|
143 |
+ |
|
144 |
+ // 등록된 토큰에서 사용자 정보 조회 |
|
145 |
+ String writer = jwtUtil.getWriter(); |
|
146 |
+ if (writer == null || writer.isEmpty()) { |
|
147 |
+ throw new CustomNotFoundException("사용자 정보 조회에 실패했습니다."); |
|
130 | 148 |
} |
149 |
+ bbsCn.setRgtr(writer); |
|
150 |
+ |
|
151 |
+ // youtube 링크 여부에 따라 처리 |
|
152 |
+ if (bbsCn.getVdoUrl() != null) { |
|
153 |
+ bbsCn.setVdoUrl(vdoUrlCheck(bbsCn.getVdoUrl())); |
|
154 |
+ } |
|
155 |
+ |
|
156 |
+ // 첨부파일 유무 |
|
157 |
+ if (multipartFileList != null && !multipartFileList.isEmpty()) { |
|
158 |
+ FileMngVO fileMngVO = new FileMngVO(); |
|
159 |
+ |
|
160 |
+ // 파일매니저 등록 |
|
161 |
+ HashMap<String, Object> fileMng = fileMngService.fileMngInsert(fileMngVO, multipartFileList); |
|
162 |
+// result.put("multipartFileMngResult", fileMng); |
|
163 |
+ |
|
164 |
+ // 파일매니저 아이디 삽입 |
|
165 |
+ bbsCn.setAtchFileMngId(fileMng.get("fileMngId").toString()); |
|
166 |
+ } |
|
167 |
+ // 이미지파일 유무 |
|
168 |
+ if (multipartImgList != null && !multipartImgList.isEmpty()) { |
|
169 |
+ FileMngVO fileMngVO = new FileMngVO(); |
|
170 |
+ |
|
171 |
+ // 파일매니저 등록 |
|
172 |
+ HashMap<String, Object> imgFileMng = fileMngService.fileMngInsert(fileMngVO, multipartImgList); |
|
173 |
+// result.put("multipartFileMngResult", imgFileMng); |
|
174 |
+ |
|
175 |
+ // 이미지 파일매니저 아이디 삽입 |
|
176 |
+ bbsCn.setImgFileMngId(imgFileMng.get("fileMngId").toString()); |
|
177 |
+ } |
|
178 |
+ |
|
179 |
+ // 질의형인 경우 \n을 <br>로 변경 |
|
180 |
+ if (bbsCn.getBbsNm() == null) { |
|
181 |
+ String text = bbsCn.getBbsCn().replaceAll("\n", "<br/>"); |
|
182 |
+ bbsCn.setBbsCn(text); |
|
183 |
+ } |
|
184 |
+ |
|
185 |
+ // 기본정보 DB 등록 |
|
186 |
+ int saveBbsCnResult = bbsCnDAO.save(bbsCn); |
|
187 |
+ if(saveBbsCnResult == 0) { |
|
188 |
+ throw new CustomInsertFailException("게시판 내용 등록에 실패했습니다."); |
|
189 |
+ } |
|
190 |
+ result.put("bbsId", bbsId); |
|
191 |
+ result.put("result", saveBbsCnResult); |
|
192 |
+ |
|
193 |
+ return result; |
|
194 |
+ } catch (CustomNotFoundException | CustomFileUploadFailException | CustomInsertFailException | IllegalArgumentException le) { |
|
195 |
+ throw le; |
|
196 |
+ } catch (DataAccessException dae) { |
|
197 |
+ throw dae; |
|
198 |
+ } catch (Exception e) { |
|
199 |
+ throw e; |
|
131 | 200 |
} |
132 |
- |
|
133 |
- |
|
134 |
- // 게시판 내용 아이디 생성 |
|
135 |
- String bbsId = bbsIdgn.getNextStringId(); |
|
136 |
- bbsCn.setBbsId(bbsId); |
|
137 |
- |
|
138 |
- // 등록된 토큰에서 사용자 정보 조회 |
|
139 |
- String writer = jwtUtil.getWriter(); |
|
140 |
- bbsCn.setRgtr(writer); |
|
141 |
- |
|
142 |
- // youtube 링크 여부에 따라 처리 |
|
143 |
- if(bbsCn.getVdoUrl() != null){ |
|
144 |
- bbsCn.setVdoUrl(vdoUrlCheck(bbsCn.getVdoUrl())); |
|
145 |
- } |
|
146 |
- |
|
147 |
- |
|
148 |
- // 첨부파일 유무 |
|
149 |
- if (multipartFileList != null && !multipartFileList.isEmpty()) { |
|
150 |
- FileMngVO fileMngVO = new FileMngVO(); |
|
151 |
- |
|
152 |
- // 파일매니저 등록 |
|
153 |
- HashMap<String, Object> fileMng = fileMngService.fileMngInsert(fileMngVO, multipartFileList); |
|
154 |
- result.put("multipartFileMngResult", fileMng); |
|
155 |
- |
|
156 |
- // 파일매니저 아이디 삽입 |
|
157 |
- bbsCn.setAtchFileMngId(fileMng.get("fileMngId").toString()); |
|
158 |
- } |
|
159 |
- // 이미지파일 유무 |
|
160 |
- if (multipartImgList != null && !multipartImgList.isEmpty()) { |
|
161 |
- FileMngVO fileMngVO = new FileMngVO(); |
|
162 |
- |
|
163 |
- // 파일매니저 등록 |
|
164 |
- HashMap<String, Object> imgFileMng = fileMngService.fileMngInsert(fileMngVO, multipartImgList); |
|
165 |
- result.put("multipartFileMngResult", imgFileMng); |
|
166 |
- |
|
167 |
- // 이미지 파일매니저 아이디 삽입 |
|
168 |
- bbsCn.setImgFileMngId(imgFileMng.get("fileMngId").toString()); |
|
169 |
- } |
|
170 |
- |
|
171 |
- // 질의형인 경우 \n을 <br>로 변경 |
|
172 |
- if(bbsCn.getBbsNm() == null){ |
|
173 |
- String text = bbsCn.getBbsCn().replaceAll("\n", "<br/>"); |
|
174 |
- bbsCn.setBbsCn(text); |
|
175 |
- } |
|
176 |
- |
|
177 |
- // 기본정보 DB 등록 |
|
178 |
- int saveBbsCnResult = bbsCnDAO.save(bbsCn); |
|
179 |
- result.put("bbsId", bbsId); |
|
180 |
- result.put("result", saveBbsCnResult); |
|
181 |
- |
|
182 |
- return result; |
|
183 | 201 |
} |
184 | 202 |
|
185 | 203 |
/** |
... | ... | @@ -190,6 +208,7 @@ |
190 | 208 |
* |
191 | 209 |
* 게시판 내용 목록 조회 개수 |
192 | 210 |
*/ |
211 |
+ @Override |
|
193 | 212 |
public int findAllCnt(Pagination pagination){ |
194 | 213 |
try { |
195 | 214 |
return bbsCnDAO.findAllCnt(pagination); |
... | ... | @@ -201,38 +220,50 @@ |
201 | 220 |
} |
202 | 221 |
|
203 | 222 |
/** |
204 |
- * @author 하석형 |
|
205 |
- * @since 2024.05.09 |
|
223 |
+ * @param params - 게시판 정보 |
|
224 |
+ * @return Map<String, Object> |
|
225 |
+ * - list : 게시판 내용 목록 |
|
226 |
+ * - pagination : 페이징 정보 |
|
227 |
+ * - codeList : 검색 조건 |
|
228 |
+ * - bbsMng : 게시판 관리 정보 |
|
229 |
+ * @throws DataAccessException - db 관련 예외 발생 시 |
|
230 |
+ * @throws Exception - 그 외 예외 발생 시 |
|
231 |
+ * |
|
206 | 232 |
* 게시판 내용 목록 조회 |
207 | 233 |
*/ |
208 | 234 |
@Override |
209 | 235 |
public Map<String, Object> findAllBbsCn(HashMap<String, String> params) { |
210 |
- Map<String, Object> result = new HashMap<>(); |
|
236 |
+ try { |
|
237 |
+ Map<String, Object> result = new HashMap<>(); |
|
211 | 238 |
|
212 |
- // 게시판 관리 정보 |
|
213 |
- BbsMngVO bbsMng = bbsMngDAO.findByBbsMngId(params.get("id")); |
|
214 |
- params.put("recordSize", String.valueOf(bbsMng.getArtclCnt())); |
|
239 |
+ // 게시판 관리 정보 |
|
240 |
+ BbsMngVO bbsMng = bbsMngDAO.findByBbsMngId(params.get("id")); |
|
241 |
+ params.put("recordSize", String.valueOf(bbsMng.getArtclCnt())); |
|
215 | 242 |
|
216 |
- // 게시판 보여줄 갯수 설정 |
|
217 |
- Pagination search = new Pagination(0, params); |
|
218 |
- int cnt = bbsCnDAO.findAllCnt(search); |
|
219 |
- Pagination pagination = new Pagination(cnt, params); |
|
220 |
- List<BbsCnVO> list = bbsCnDAO.findAll(pagination); |
|
243 |
+ // 게시판 보여줄 갯수 설정 |
|
244 |
+ Pagination search = new Pagination(0, params); |
|
245 |
+ int cnt = bbsCnDAO.findAllCnt(search); |
|
246 |
+ Pagination pagination = new Pagination(cnt, params); |
|
247 |
+ List<BbsCnVO> list = bbsCnDAO.findAll(pagination); |
|
221 | 248 |
|
222 |
- list.forEach(entity -> { |
|
223 |
- String imagePath = entity.getAbsltPath(); |
|
224 |
- entity.setAbsltPath(convertPathToUrl(imagePath)); |
|
225 |
- }); |
|
249 |
+ list.forEach(entity -> { |
|
250 |
+ String imagePath = entity.getAbsltPath(); |
|
251 |
+ entity.setAbsltPath(convertPathToUrl(imagePath)); |
|
252 |
+ }); |
|
226 | 253 |
|
227 |
- result.put("list", list); |
|
228 |
- result.put("pagination", pagination); |
|
229 |
- result.put("codeList", null); // 검색 조건 |
|
230 |
- result.put("bbsMng", bbsMng); // 게시판 관리 정보 |
|
231 |
- return result; |
|
254 |
+ result.put("list", list); |
|
255 |
+ result.put("pagination", pagination); |
|
256 |
+ result.put("codeList", null); // 검색 조건 |
|
257 |
+ result.put("bbsMng", bbsMng); // 게시판 관리 정보 |
|
258 |
+ return result; |
|
259 |
+ } catch (DataAccessException dae) { |
|
260 |
+ throw dae; |
|
261 |
+ } catch (Exception e) { |
|
262 |
+ throw e; |
|
263 |
+ } |
|
232 | 264 |
} |
233 | 265 |
|
234 | 266 |
private String convertPathToUrl(String filePath) { |
235 |
- |
|
236 | 267 |
String previewPath = null; |
237 | 268 |
String[] pathArray = locationPath.split("/, "); |
238 | 269 |
for (String path : pathArray) { |
... | ... | @@ -286,90 +317,112 @@ |
286 | 317 |
} |
287 | 318 |
|
288 | 319 |
/** |
289 |
- * @author 하석형 |
|
290 |
- * @since 2024.05.09 |
|
320 |
+ * @param params - 게시판 정보 |
|
321 |
+ * @param deleteFileList - 삭제 파일 목록 |
|
322 |
+ * @param multipartFileList - 파일 목록 |
|
323 |
+ * @param deleteImgFileList - 삭제 이미지 파일 목록 |
|
324 |
+ * @param multipartImgList - 이미지 파일 목록 |
|
325 |
+ * @return HashMap<String, Object> |
|
326 |
+ * - result : 게시판 내용 수정 결과 |
|
327 |
+ * @throws CustomPrhibtWordException - 금지어 포함 예외 발생 시 |
|
328 |
+ * @throws CustomNotFoundException - 사용자 정보 조회 예외 발생 시 |
|
329 |
+ * @throws CustomUpdateFailException - 게시판 내용 수정 예외 발생 시 |
|
330 |
+ * @throws DataAccessException - db 관련 예외 발생 시 |
|
331 |
+ * @throws Exception - 그 외 예외 발생 시 |
|
291 | 332 |
* |
292 | 333 |
* 게시판 내용 수정 |
293 | 334 |
*/ |
294 | 335 |
@Transactional(rollbackFor = Exception.class) |
295 | 336 |
@Override |
296 | 337 |
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) { |
297 |
- HashMap<String, Object> result = new HashMap<>(); |
|
298 |
- int intResult= 0; |
|
338 |
+ try { |
|
339 |
+ HashMap<String, Object> result = new HashMap<>(); |
|
340 |
+ int intResult = 0; |
|
341 |
+ int fileUpdateResult = 0; |
|
342 |
+ int fileInsertResult = 0; |
|
343 |
+ int imgFileUpdateResult = 0; |
|
344 |
+ int imgFileInsertResult = 0; |
|
299 | 345 |
|
300 |
- List<String> wordList = wordMngDAO.findWordList(); |
|
346 |
+ List<String> wordList = wordMngDAO.findWordList(); |
|
301 | 347 |
|
302 |
- // 금지어 포함 여부 체크 |
|
303 |
- // 제목에 금지어가 포함되어있는가? |
|
304 |
- String bbsNm = (params.get("bbsNm") != null) ? params.get("bbsNm").toString() : null; |
|
305 |
- if(bbsNm != null && !bbsNm.isEmpty()) { |
|
306 |
- for (String word : wordList) { |
|
307 |
- if (bbsNm.contains(word)) { |
|
308 |
- result.put("result", -1); |
|
309 |
- result.put("word", word); |
|
310 |
- return result; |
|
348 |
+ // 금지어 포함 여부 체크 |
|
349 |
+ String bbsNm = (params.get("bbsNm") != null) ? params.get("bbsNm").toString() : null; |
|
350 |
+ String content = params.get("bbsCn").toString(); |
|
351 |
+ if (bbsNm != null && !bbsNm.isEmpty()) { |
|
352 |
+ for (String word : wordList) { |
|
353 |
+ // 제목에 금지어가 포함되어있는가? |
|
354 |
+ if (bbsNm.contains(word)) { |
|
355 |
+ throw new CustomPrhibtWordException("제목에 금지어가 포함되어있습니다.", word); |
|
356 |
+ } |
|
357 |
+ // 내용에 금지어가 포함되어있는가? |
|
358 |
+ if (content.contains(word)) { |
|
359 |
+ throw new CustomPrhibtWordException("내용에 금지어가 포함되어있습니다.", word); |
|
360 |
+ } |
|
311 | 361 |
} |
312 | 362 |
} |
313 |
- } |
|
314 | 363 |
|
315 |
- // 내용에 금지어가 포함되어있는가? |
|
316 |
- String content = params.get("bbsCn").toString(); |
|
317 |
- for (String word : wordList) { |
|
318 |
- if (content.contains(word)) { |
|
319 |
- result.put("result", -1); |
|
320 |
- result.put("word", word); |
|
321 |
- return result; |
|
364 |
+ // 등록된 토큰에서 사용자 정보 조회 |
|
365 |
+ String writer = jwtUtil.getWriter(); |
|
366 |
+ if (writer == null || writer.isEmpty()) { |
|
367 |
+ throw new CustomNotFoundException("사용자 정보 조회에 실패했습니다."); |
|
322 | 368 |
} |
369 |
+ params.put("mdfr", writer); |
|
370 |
+ |
|
371 |
+ // youtube 링크 여부에 따라 처리 |
|
372 |
+ if (params.get("vdoUrl") != null) { |
|
373 |
+ params.put("vdoUrl", vdoUrlCheck(params.get("vdoUrl").toString())); |
|
374 |
+ } |
|
375 |
+ |
|
376 |
+ // 파일 업로드 |
|
377 |
+ FileMngVO fileMngVO = new FileMngVO(); |
|
378 |
+ if (params.get("atchFileMngId") != null) { |
|
379 |
+ // 파일매니저 수정 |
|
380 |
+ String fileMngId = params.get("atchFileMngId").toString(); |
|
381 |
+ fileMngVO.setFileMngId(fileMngId); |
|
382 |
+ fileUpdateResult = fileMngService.fileMngUpadate(fileMngVO, deleteFileList, multipartFileList); |
|
383 |
+ } else if (multipartFileList != null && !multipartFileList.isEmpty()) { |
|
384 |
+ // 파일매니저 등록 |
|
385 |
+ HashMap<String, Object> fileMng = fileMngService.fileMngInsert(fileMngVO, multipartFileList); |
|
386 |
+ fileInsertResult = (int) fileMng.get("fileMngResult"); |
|
387 |
+ params.put("atchFileMngId", fileMng.get("fileMngId").toString()); |
|
388 |
+ } |
|
389 |
+ |
|
390 |
+ // 이미지 파일 업로드 |
|
391 |
+ FileMngVO fileImgMngVO = new FileMngVO(); |
|
392 |
+ if (params.get("imgFileMngId") != null) { |
|
393 |
+ // 파일매니저 수정 |
|
394 |
+ String imgFileMng = params.get("imgFileMngId").toString(); |
|
395 |
+ fileImgMngVO.setFileMngId(imgFileMng); |
|
396 |
+ imgFileUpdateResult = fileMngService.fileMngUpadate(fileImgMngVO, deleteImgFileList, multipartImgList); |
|
397 |
+ } else if (multipartImgList != null && !multipartImgList.isEmpty()) { |
|
398 |
+ // 파일매니저 등록 |
|
399 |
+ HashMap<String, Object> imgFileMng = fileMngService.fileMngInsert(fileImgMngVO, multipartImgList); |
|
400 |
+ imgFileInsertResult = (int) imgFileMng.get("fileMngResult"); |
|
401 |
+ params.put("imgFileMngId", imgFileMng.get("fileMngId").toString()); |
|
402 |
+ } |
|
403 |
+ |
|
404 |
+ // 질의형인 경우 \n을 <br>로 변경 |
|
405 |
+ if (params.get("bbsNm") == null) { |
|
406 |
+ String text = params.get("bbsCn").toString().replaceAll("\n", "<br/>"); |
|
407 |
+ params.put("bbsCn", text); |
|
408 |
+ } |
|
409 |
+ |
|
410 |
+ // 게시판 내용 수정 |
|
411 |
+ intResult = bbsCnDAO.update(params); |
|
412 |
+ if (intResult == 0) { |
|
413 |
+ throw new CustomUpdateFailException("게시판 내용 수정에 실패했습니다."); |
|
414 |
+ } |
|
415 |
+ |
|
416 |
+ result.put("result", intResult); |
|
417 |
+ return result; |
|
418 |
+ } catch (CustomNotFoundException | CustomFileUploadFailException | CustomInsertFailException | CustomUpdateFailException | IllegalArgumentException |
|
419 |
+ | CustomDeleteFailException le) { |
|
420 |
+ throw le; |
|
421 |
+ } catch (DataAccessException dae) { |
|
422 |
+ throw dae; |
|
423 |
+ } catch (Exception e) { |
|
424 |
+ throw e; |
|
323 | 425 |
} |
324 |
- |
|
325 |
- // 등록된 토큰에서 사용자 정보 조회 |
|
326 |
- String writer = jwtUtil.getWriter(); |
|
327 |
- params.put("mdfr", writer); |
|
328 |
- |
|
329 |
- // youtube 링크 여부에 따라 처리 |
|
330 |
- if(params.get("vdoUrl") != null){ |
|
331 |
- params.put("vdoUrl", vdoUrlCheck(params.get("vdoUrl").toString())); |
|
332 |
- } |
|
333 |
- |
|
334 |
- // 파일 업로드 |
|
335 |
- FileMngVO fileMngVO = new FileMngVO(); |
|
336 |
- if (params.get("atchFileMngId") != null) { |
|
337 |
- // 파일매니저 수정 |
|
338 |
- String fileMngId = params.get("atchFileMngId").toString(); |
|
339 |
- fileMngVO.setFileMngId(fileMngId); |
|
340 |
- intResult += fileMngService.fileMngUpadate(fileMngVO, deleteFileList, multipartFileList); |
|
341 |
- } else if (multipartFileList != null && !multipartFileList.isEmpty()){ |
|
342 |
- // 파일매니저 등록 |
|
343 |
- HashMap<String, Object> fileMng = fileMngService.fileMngInsert(fileMngVO, multipartFileList); |
|
344 |
- intResult += (int)fileMng.get("fileMngResult"); |
|
345 |
- params.put("atchFileMngId", fileMng.get("fileMngId").toString()); |
|
346 |
- } |
|
347 |
- |
|
348 |
- // 이미지 파일 업로드 |
|
349 |
- FileMngVO fileImgMngVO = new FileMngVO(); |
|
350 |
- if (params.get("imgFileMngId") != null) { |
|
351 |
- // 파일매니저 수정 |
|
352 |
- String imgFileMng = params.get("imgFileMngId").toString(); |
|
353 |
- fileImgMngVO.setFileMngId(imgFileMng); |
|
354 |
- intResult += fileMngService.fileMngUpadate(fileImgMngVO, deleteImgFileList, multipartImgList); |
|
355 |
- } else if (multipartImgList != null && !multipartImgList.isEmpty()){ |
|
356 |
- // 파일매니저 등록 |
|
357 |
- HashMap<String, Object> imgFileMng = fileMngService.fileMngInsert(fileImgMngVO, multipartImgList); |
|
358 |
- intResult += (int)imgFileMng.get("fileMngResult"); |
|
359 |
- params.put("imgFileMngId", imgFileMng.get("fileMngId").toString()); |
|
360 |
- } |
|
361 |
- |
|
362 |
- // 질의형인 경우 \n을 <br>로 변경 |
|
363 |
- if(params.get("bbsNm") == null){ |
|
364 |
- String text = params.get("bbsCn").toString().replaceAll("\n", "<br/>"); |
|
365 |
- params.put("bbsCn", text); |
|
366 |
- } |
|
367 |
- |
|
368 |
- // 게시판 내용 수정 |
|
369 |
- intResult += bbsCnDAO.update(params); |
|
370 |
- |
|
371 |
- result.put("result", intResult); |
|
372 |
- return result; |
|
373 | 426 |
} |
374 | 427 |
|
375 | 428 |
/** |
... | ... | @@ -400,10 +453,11 @@ |
400 | 453 |
throw e; |
401 | 454 |
} |
402 | 455 |
} |
456 |
+ |
|
403 | 457 |
/** |
404 |
- * @author 방선주 |
|
405 |
- * @since 2024.05.21 |
|
406 |
- * |
|
458 |
+ * @param vdoUrl - 비디오 링크 |
|
459 |
+ * @return String - 변환 비디오 링크 |
|
460 |
+ * |
|
407 | 461 |
* vdoUrl 조건 처리 |
408 | 462 |
*/ |
409 | 463 |
private String vdoUrlCheck(String vdoUrl) { |
... | ... | @@ -425,7 +479,7 @@ |
425 | 479 |
* @throws DataAccessException - db 관련 예외 발생 시 |
426 | 480 |
* @throws Exception - 그 외 예외 발생 시 |
427 | 481 |
* |
428 |
- * 조회수 증가 처리 |
|
482 |
+ * 조회수 증가 |
|
429 | 483 |
*/ |
430 | 484 |
@Override |
431 | 485 |
public int updateVwCnt(HashMap<String, Object> params) { |
... | ... | @@ -484,91 +538,128 @@ |
484 | 538 |
} |
485 | 539 |
|
486 | 540 |
/** |
541 |
+ * @param fileMngId - 파일매니저 아이디 |
|
542 |
+ * @return List<HashMap<String, Object>> - 파일매니저 목록 |
|
543 |
+ * @throws DataAccessException - db 관련 예외 발생 시 |
|
544 |
+ * @throws Exception - 그 외 예외 발생 시 |
|
545 |
+ * |
|
487 | 546 |
* 첨부파일 이미지 경로 변경 |
488 |
- * @param fileMngId |
|
489 |
- * @return |
|
490 |
- * @throws Exception |
|
491 | 547 |
*/ |
492 | 548 |
@Override |
493 | 549 |
public List<HashMap<String, Object>> fileListPathChange(String fileMngId) { |
550 |
+ try { |
|
551 |
+ List<HashMap<String, Object>> fileList = fileDAO.fileSelectList(fileMngId); |
|
494 | 552 |
|
495 |
- List<HashMap<String, Object>> fileList = fileDAO.fileSelectList(fileMngId); |
|
496 |
- |
|
497 |
- for (HashMap<String, Object> file : fileList) { |
|
498 |
- String absltPath = file.get("absltPath").toString(); |
|
499 |
- file.put("absltPath", convertPathToUrl(absltPath)); |
|
553 |
+ for (HashMap<String, Object> file : fileList) { |
|
554 |
+ String absltPath = file.get("absltPath").toString(); |
|
555 |
+ file.put("absltPath", convertPathToUrl(absltPath)); |
|
556 |
+ } |
|
557 |
+ return fileList; |
|
558 |
+ } catch (DataAccessException dae) { |
|
559 |
+ throw dae; |
|
560 |
+ } catch (Exception e) { |
|
561 |
+ throw e; |
|
500 | 562 |
} |
501 |
- return fileList; |
|
502 | 563 |
} |
503 | 564 |
|
504 | 565 |
/** |
566 |
+ * @param bbsCnVO - 게시판 내용 정보 |
|
567 |
+ * @return HashMap<String, Object> - 답변 등록 결과 |
|
568 |
+ * @throws CustomNotFoundException - 사용자 정보 조회 예외 발생 시 |
|
569 |
+ * @throws CustomPrhibtWordException - 금지어 포함 예외 발생 시 |
|
570 |
+ * @throws CustomInsertFailException - 답변 등록 예외 발생 시 |
|
571 |
+ * @throws DataAccessException - db 관련 예외 발생 시 |
|
572 |
+ * @throws Exception - 그 외 예외 발생 시 |
|
573 |
+ * |
|
505 | 574 |
* 질의형 게시판 답변 등록 |
506 |
- * @param bbsCnVO |
|
507 |
- * @return |
|
508 |
- * @throws Exception |
|
509 | 575 |
*/ |
510 | 576 |
@Override |
511 | 577 |
public HashMap<String, Object> saveAnswer(BbsCnVO bbsCnVO) { |
512 |
- HashMap<String, Object> result = new HashMap<>(); |
|
513 |
- // 등록된 토큰에서 사용자 정보 조회 |
|
514 |
- String writer = jwtUtil.getWriter(); |
|
515 |
- bbsCnVO.setAnswer(writer); |
|
516 |
- |
|
517 |
- // 답변 금지어 포함 여부 체크 |
|
518 |
- List<String> wordList = wordMngDAO.findWordList(); |
|
519 |
- String ansCn = bbsCnVO.getAnsCn(); |
|
520 |
- for (String word : wordList) { |
|
521 |
- if (ansCn.contains(word)) { |
|
522 |
- result.put("result", -1); |
|
523 |
- result.put("word", word); |
|
524 |
- return result; |
|
578 |
+ try { |
|
579 |
+ HashMap<String, Object> result = new HashMap<>(); |
|
580 |
+ // 등록된 토큰에서 사용자 정보 조회 |
|
581 |
+ String writer = jwtUtil.getWriter(); |
|
582 |
+ if (writer == null || writer.isEmpty()) { |
|
583 |
+ throw new CustomNotFoundException("사용자 정보 조회에 실패했습니다."); |
|
525 | 584 |
} |
585 |
+ bbsCnVO.setAnswer(writer); |
|
586 |
+ |
|
587 |
+ // 답변 금지어 포함 여부 체크 |
|
588 |
+ List<String> wordList = wordMngDAO.findWordList(); |
|
589 |
+ String ansCn = bbsCnVO.getAnsCn(); |
|
590 |
+ for (String word : wordList) { |
|
591 |
+ if (ansCn.contains(word)) { |
|
592 |
+ throw new CustomPrhibtWordException("내용에 금지어가 포함되어있습니다.", word); |
|
593 |
+ } |
|
594 |
+ } |
|
595 |
+ |
|
596 |
+ // 질의형인 경우 \n을 <br>로 변경 |
|
597 |
+ if (bbsCnVO.getBbsNm() == null) { |
|
598 |
+ String text = bbsCnVO.getAnsCn().replaceAll("\n", "<br/>"); |
|
599 |
+ bbsCnVO.setAnsCn(text); |
|
600 |
+ } |
|
601 |
+ |
|
602 |
+ int saveAns = bbsCnDAO.saveAnswer(bbsCnVO); |
|
603 |
+ if (saveAns == 0) { |
|
604 |
+ throw new CustomInsertFailException("답변 등록에 실패했습니다."); |
|
605 |
+ } |
|
606 |
+ |
|
607 |
+ result.put("result", saveAns); |
|
608 |
+ return result; |
|
609 |
+ } catch (DataAccessException dae) { |
|
610 |
+ throw dae; |
|
611 |
+ } catch (Exception e) { |
|
612 |
+ throw e; |
|
526 | 613 |
} |
527 |
- |
|
528 |
- // 질의형인 경우 \n을 <br>로 변경 |
|
529 |
- if(bbsCnVO.getBbsNm() == null){ |
|
530 |
- String text = bbsCnVO.getAnsCn().replaceAll("\n", "<br/>"); |
|
531 |
- bbsCnVO.setAnsCn(text); |
|
532 |
- } |
|
533 |
- |
|
534 |
- int saveAns = bbsCnDAO.saveAnswer(bbsCnVO); |
|
535 |
- |
|
536 |
- result.put("result", saveAns); |
|
537 |
- return result; |
|
538 | 614 |
} |
539 | 615 |
|
540 | 616 |
/** |
617 |
+ * @param bbsCnVO - 게시판 내용 정보 |
|
618 |
+ * @return HashMap<String, Object> - 답변 수정 결과 |
|
619 |
+ * @throws CustomNotFoundException - 사용자 정보 조회 예외 발생 시 |
|
620 |
+ * @throws CustomPrhibtWordException - 금지어 포함 예외 발생 시 |
|
621 |
+ * @throws CustomUpdateFailException - 답변 등록 예외 발생 시 |
|
622 |
+ * @throws DataAccessException - db 관련 예외 발생 시 |
|
623 |
+ * @throws Exception - 그 외 예외 발생 시 |
|
624 |
+ * |
|
541 | 625 |
* 질의형 게시판 답변 수정 |
542 |
- * @param bbsCnVO |
|
543 |
- * @return |
|
544 |
- * @throws Exception |
|
545 | 626 |
*/ |
546 | 627 |
@Override |
547 | 628 |
public HashMap<String, Object> updateAnswer(BbsCnVO bbsCnVO) { |
548 |
- HashMap<String, Object> result = new HashMap<>(); |
|
629 |
+ try { |
|
630 |
+ HashMap<String, Object> result = new HashMap<>(); |
|
549 | 631 |
|
550 |
- // 등록된 토큰에서 사용자 정보 조회 |
|
551 |
- String writer = jwtUtil.getWriter(); |
|
552 |
- bbsCnVO.setAnswer(writer); |
|
553 |
- |
|
554 |
- // 답변 금지어 포함 여부 체크 |
|
555 |
- List<String> wordList = wordMngDAO.findWordList(); |
|
556 |
- String ansCn = bbsCnVO.getAnsCn(); |
|
557 |
- for (String word : wordList) { |
|
558 |
- if (ansCn.contains(word)) { |
|
559 |
- result.put("result", -1); |
|
560 |
- result.put("word", word); |
|
561 |
- return result; |
|
632 |
+ // 등록된 토큰에서 사용자 정보 조회 |
|
633 |
+ String writer = jwtUtil.getWriter(); |
|
634 |
+ if (writer == null || writer.isEmpty()) { |
|
635 |
+ throw new CustomNotFoundException("사용자 정보 조회에 실패했습니다."); |
|
562 | 636 |
} |
637 |
+ bbsCnVO.setAnswer(writer); |
|
638 |
+ |
|
639 |
+ // 답변 금지어 포함 여부 체크 |
|
640 |
+ List<String> wordList = wordMngDAO.findWordList(); |
|
641 |
+ String ansCn = bbsCnVO.getAnsCn(); |
|
642 |
+ for (String word : wordList) { |
|
643 |
+ if (ansCn.contains(word)) { |
|
644 |
+ throw new CustomPrhibtWordException("내용에 금지어가 포함되어있습니다.", word); |
|
645 |
+ } |
|
646 |
+ } |
|
647 |
+ |
|
648 |
+ String text = bbsCnVO.getAnsCn().replaceAll("\n", "<br/>"); |
|
649 |
+ bbsCnVO.setAnsCn(text); |
|
650 |
+ |
|
651 |
+ int saveAns = bbsCnDAO.saveAnswer(bbsCnVO); |
|
652 |
+ if (saveAns == 0) { |
|
653 |
+ throw new CustomUpdateFailException("답변 수정에 실패했습니다."); |
|
654 |
+ } |
|
655 |
+ |
|
656 |
+ result.put("result", saveAns); |
|
657 |
+ return result; |
|
658 |
+ } catch (DataAccessException dae) { |
|
659 |
+ throw dae; |
|
660 |
+ } catch (Exception e) { |
|
661 |
+ throw e; |
|
563 | 662 |
} |
564 |
- |
|
565 |
- String text = bbsCnVO.getAnsCn().replaceAll("\n", "<br/>"); |
|
566 |
- bbsCnVO.setAnsCn(text); |
|
567 |
- |
|
568 |
- int saveAns = bbsCnDAO.saveAnswer(bbsCnVO); |
|
569 |
- |
|
570 |
- result.put("result", saveAns); |
|
571 |
- return result; |
|
572 | 663 |
} |
573 | 664 |
|
574 | 665 |
/** |
--- src/main/java/com/takensoft/cms/bbs/web/BbsCnController.java
+++ src/main/java/com/takensoft/cms/bbs/web/BbsCnController.java
... | ... | @@ -35,6 +35,12 @@ |
35 | 35 |
* @modification |
36 | 36 |
* since | author | description |
37 | 37 |
* 2024.05.09 | 하석형 | 최초 등록 |
38 |
+ * 2024.05.21 | 방선주 | saveBbsCn, updateBbsCn, fileDownload 추가 |
|
39 |
+ * 2024.05.22 | 방선주 | updateVwCnt 추가 |
|
40 |
+ * 2024.05.31 | 방선주 | ansSaveProc, ansUpdateProc 추가 |
|
41 |
+ * 2024.06.07 | 방선주 | ansDeleteProc 추가 |
|
42 |
+ * 2024.06.13 | 방선주 | findFiveNotice 추가 |
|
43 |
+ * 2025.03.21 | 하석형 | 코드 리펙토링 |
|
38 | 44 |
* |
39 | 45 |
* 게시판 내용 관련 컨트롤러 |
40 | 46 |
*/ |
... | ... | @@ -50,73 +56,23 @@ |
50 | 56 |
private final FileService fileService; |
51 | 57 |
|
52 | 58 |
/** |
53 |
- * @author 하석형 |
|
54 |
- * @since 2024.05.09 |
|
55 |
- * @param bbsCnVO |
|
56 |
- * @return |
|
57 |
- * @throws Exception |
|
58 |
- * |
|
59 |
- * 게시판 내용 등록 |
|
60 |
- */ |
|
61 |
-// @PostMapping("/saveProc.json") |
|
62 |
-// public ResponseEntity<?> saveProc(@RequestBody BbsCnVO bbsCnVO) throws Exception { |
|
63 |
-// // 응답 처리 |
|
64 |
-// HttpHeaders headers = new HttpHeaders(); |
|
65 |
-// headers.setContentType(new MediaType("application", "json", Charset.forName("UTF-8"))); |
|
66 |
-// ResponseData responseData = new ResponseData(); |
|
67 |
-// |
|
68 |
-// // 게시판 내용 등록 |
|
69 |
-// int result = bbsCnService.saveBbsCn(bbsCnVO); |
|
70 |
-// if(result > 0) { |
|
71 |
-// responseData.setStatus(HttpStatus.OK); |
|
72 |
-// responseData.setMessage("정상적으로 등록 처리되었습니다."); |
|
73 |
-// responseData.setData(result); |
|
74 |
-// return new ResponseEntity<>(responseData, headers, HttpStatus.OK); |
|
75 |
-// } else { |
|
76 |
-// responseData.setStatus(HttpStatus.INTERNAL_SERVER_ERROR); |
|
77 |
-// responseData.setMessage("등록에 실패하였습니다.\n담당자에게 문의하세요."); |
|
78 |
-// return new ResponseEntity<>(responseData, headers, HttpStatus.INTERNAL_SERVER_ERROR); |
|
79 |
-// } |
|
80 |
-// } |
|
81 |
- /** |
|
82 |
- * @author 방선주 |
|
83 |
- * @since 2024.05.21 |
|
84 |
- * @param bbsCn, multipartFileList |
|
85 |
- * @return |
|
86 |
- * @throws Exception |
|
59 |
+ * @param bbsCn - 게시판 내용 정보 |
|
60 |
+ * @param multipartFileList - 첨부파일 목록 |
|
61 |
+ * @param multipartImgList - 이미지 파일 목록 |
|
62 |
+ * @return ResponseEntity - 게시판 내용 등록 결과를 포함하는 응답 |
|
87 | 63 |
* |
88 | 64 |
* 게시판 내용 등록 |
89 | 65 |
*/ |
90 | 66 |
@PostMapping(path = "/saveBbsCn.file") |
91 | 67 |
public ResponseEntity<?> saveBbsCn(@RequestPart BbsCnVO bbsCn, List<MultipartFile> multipartFileList, List<MultipartFile> multipartImgList) throws Exception { |
92 |
- |
|
93 |
- // 응답 처리 |
|
94 |
- HttpHeaders headers = new HttpHeaders(); |
|
95 |
- headers.setContentType(new MediaType("application", "json", Charset.forName("UTF-8"))); |
|
96 |
- ResponseData responseData = new ResponseData(); |
|
97 |
- |
|
98 | 68 |
// 게시판 내용 등록 |
99 | 69 |
HashMap<String, Object> result = bbsCnService.saveBbsCn(bbsCn, multipartFileList, multipartImgList); |
100 |
- int insertResult = (int) result.get("result"); |
|
101 |
- |
|
102 |
- if (insertResult > 0) { |
|
103 |
- return resUtil.successRes(result, MessageCode.COMMON_SUCCESS); |
|
104 |
- } else if (insertResult == -1){ |
|
105 |
- responseData.setStatus(HttpStatus.INTERNAL_SERVER_ERROR.value()); |
|
106 |
- responseData.setStatusText(HttpStatus.INTERNAL_SERVER_ERROR); |
|
107 |
- responseData.setMessage("아래의 금지어가 포함되어 있습니다.\n* " + result.get("word")); |
|
108 |
- return new ResponseEntity<>(responseData, headers, HttpStatus.INTERNAL_SERVER_ERROR); |
|
109 |
- } else { |
|
110 |
- return resUtil.errorRes(MessageCode.COMMON_INSERT_FAIL); |
|
111 |
- } |
|
70 |
+ return resUtil.successRes(result, MessageCode.COMMON_SUCCESS); |
|
112 | 71 |
} |
113 | 72 |
|
114 | 73 |
/** |
115 |
- * @author 하석형 |
|
116 |
- * @since 2024.05.09 |
|
117 |
- * @param params |
|
118 |
- * @return |
|
119 |
- * @throws Exception |
|
74 |
+ * @param params - 검색조건 및 페이징 정보 |
|
75 |
+ * @return ResponseEntity - 게시판 내용 목록 조회 결과를 포함하는 응답 |
|
120 | 76 |
* |
121 | 77 |
* 게시판 내용 목록 조회 |
122 | 78 |
*/ |
... | ... | @@ -124,23 +80,17 @@ |
124 | 80 |
public ResponseEntity<?> findAll(@RequestBody HashMap<String, String> params) throws Exception { |
125 | 81 |
// 게시판 내용 목록 조회 |
126 | 82 |
Map<String, Object> result = bbsCnService.findAllBbsCn(params); |
127 |
- |
|
128 |
- // 응답처리 |
|
129 | 83 |
return resUtil.successRes(result, MessageCode.COMMON_SUCCESS); |
130 | 84 |
} |
131 | 85 |
|
132 | 86 |
/** |
133 |
- * @author 하석형 |
|
134 |
- * @since 2024.05.09 |
|
135 |
- * @param bbsCnVO |
|
136 |
- * @return |
|
137 |
- * @throws Exception |
|
87 |
+ * @param bbsCnVO - 게시판 내용 정보 |
|
88 |
+ * @return ResponseEntity - 게시판 내용 상세 조회 결과를 포함하는 응답 |
|
138 | 89 |
* |
139 | 90 |
* 게시판 내용 상세 조회 |
140 | 91 |
*/ |
141 | 92 |
@PostMapping("/findByBbsCn.json") |
142 | 93 |
public ResponseEntity<?> findByBbsCn(@RequestBody BbsCnVO bbsCnVO) throws Exception { |
143 |
- |
|
144 | 94 |
// 게시판 관리 정보 조회 |
145 | 95 |
BbsMngVO bbsMng = bbsMngService.findByBbsMngId(bbsCnVO.getBbsMngId()); |
146 | 96 |
// 게시판 내용 상세 조회 |
... | ... | @@ -151,7 +101,6 @@ |
151 | 101 |
//이미지 파일 목록 조회 |
152 | 102 |
String imgFileMngId = bbsCn.getImgFileMngId(); |
153 | 103 |
List<HashMap<String,Object>> imgFileList = bbsCnService.fileListPathChange(imgFileMngId); |
154 |
- |
|
155 | 104 |
|
156 | 105 |
// 이전글 다음글 조회 |
157 | 106 |
BbsCnVO prevBbsCn = bbsCnService.findPrevBbsCn(bbsCnVO); |
... | ... | @@ -169,119 +118,53 @@ |
169 | 118 |
return resUtil.successRes(result, MessageCode.COMMON_SUCCESS); |
170 | 119 |
} |
171 | 120 |
|
172 |
-// /** |
|
173 |
-// * @author 하석형 |
|
174 |
-// * @since 2024.05.09 |
|
175 |
-// * @param bbsCnVO |
|
176 |
-// * @return |
|
177 |
-// * @throws Exception |
|
178 |
-// * |
|
179 |
-// * 게시판 내용 수정 |
|
180 |
-// */ |
|
181 |
-// @PostMapping("/updateProc.json") |
|
182 |
-// public ResponseEntity<?> updateProc(@RequestBody BbsCnVO bbsCnVO) throws Exception { |
|
183 |
-// HttpHeaders headers = new HttpHeaders(); |
|
184 |
-// headers.setContentType(new MediaType("application", "json", Charset.forName("UTF-8"))); |
|
185 |
-// ResponseData responseData = new ResponseData(); |
|
186 |
-// |
|
187 |
-// // 게시판 내용 수정 |
|
188 |
-// int result = bbsCnService.updateBbsCn(bbsCnVO); |
|
189 |
-// |
|
190 |
-// // 응답 처리 |
|
191 |
-// if(result > 0) { |
|
192 |
-// responseData.setStatus(HttpStatus.OK); |
|
193 |
-// responseData.setMessage("정상적으로 수정 처리되었습니다."); |
|
194 |
-// return new ResponseEntity<>(responseData, headers, HttpStatus.OK); |
|
195 |
-// } else { |
|
196 |
-// responseData.setStatus(HttpStatus.INTERNAL_SERVER_ERROR); |
|
197 |
-// responseData.setMessage("수정에 실패하였습니다.\n담당자에게 문의하세요."); |
|
198 |
-// return new ResponseEntity<>(responseData, headers, HttpStatus.INTERNAL_SERVER_ERROR); |
|
199 |
-// } |
|
200 |
-// } |
|
201 | 121 |
/** |
202 |
- * @author 방선주 |
|
203 |
- * @since 2024.05.21 |
|
204 |
- * @param params, multipartFileList |
|
205 |
- * @return |
|
206 |
- * @throws Exception |
|
122 |
+ * @param params - 게시판 내용 정보 |
|
123 |
+ * @param deleteFileList - 삭제할 파일 목록 |
|
124 |
+ * @param multipartFileList - 첨부파일 목록 |
|
125 |
+ * @param deleteImgFileList - 삭제할 이미지 파일 목록 |
|
126 |
+ * @param multipartImgList - 이미지 파일 목록 |
|
127 |
+ * @return ResponseEntity - 게시판 내용 수정 결과를 포함하는 응답 |
|
207 | 128 |
* |
208 | 129 |
* 게시판 내용 수정 |
209 | 130 |
*/ |
210 | 131 |
@PostMapping(path = "/updateBbsCn.file") |
211 | 132 |
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 { |
212 |
- |
|
213 | 133 |
// 게시판 내용 수정 |
214 | 134 |
HashMap<String, Object> result = bbsCnService.updateBbsCn(params, deleteFileList, multipartFileList, deleteImgFileList, multipartImgList); |
215 |
- |
|
216 |
- int updateResult = (int) result.get("result"); |
|
217 |
- // 응답 처리 |
|
218 |
- HttpHeaders headers = new HttpHeaders(); |
|
219 |
- headers.setContentType(new MediaType("application", "json", Charset.forName("UTF-8"))); |
|
220 |
- ResponseData responseData = new ResponseData(); |
|
221 |
- if (updateResult > 0) { |
|
222 |
- return resUtil.successRes(result, MessageCode.COMMON_SUCCESS); |
|
223 |
- } else if (updateResult == -1){ |
|
224 |
- responseData.setStatus(HttpStatus.INTERNAL_SERVER_ERROR.value()); |
|
225 |
- responseData.setStatusText(HttpStatus.INTERNAL_SERVER_ERROR); |
|
226 |
- responseData.setMessage("아래의 금지어가 포함되어 있습니다.\n* " + result.get("word")); |
|
227 |
- return new ResponseEntity<>(responseData, headers, HttpStatus.INTERNAL_SERVER_ERROR); |
|
228 |
- |
|
229 |
- } else { |
|
230 |
- return resUtil.errorRes(MessageCode.COMMON_UPDATE_FAIL); |
|
231 |
- } |
|
135 |
+ return resUtil.successRes(result, MessageCode.COMMON_SUCCESS); |
|
232 | 136 |
} |
233 | 137 |
|
234 | 138 |
/** |
235 |
- * @author 하석형 |
|
236 |
- * @since 2024.05.09 |
|
237 |
- * @param bbsCnVO |
|
238 |
- * @return |
|
239 |
- * @throws Exception |
|
139 |
+ * @param bbsCnVO - 게시판 내용 정보 |
|
140 |
+ * @return ResponseEntity - 게시판 내용 삭제 결과를 포함하는 응답 |
|
240 | 141 |
* |
241 | 142 |
* 게시판 내용 삭제 |
242 | 143 |
*/ |
243 | 144 |
@PostMapping("/deleteProc.json") |
244 |
- public ResponseEntity<?> deleteProc(@RequestBody BbsCnVO bbsCnVO) throws Exception { |
|
245 |
- |
|
145 |
+ public ResponseEntity<?> deleteProc(@RequestBody BbsCnVO bbsCnVO) { |
|
246 | 146 |
// 게시판 내용 수정 |
247 | 147 |
int result = bbsCnService.deleteBbsCn(bbsCnVO); |
248 |
- |
|
249 |
- // 응답 처리 |
|
250 |
- if(result > 0) { |
|
251 |
- return resUtil.successRes(result, MessageCode.COMMON_SUCCESS); |
|
252 |
- } else { |
|
253 |
- return resUtil.errorRes(MessageCode.COMMON_DELETE_FAIL); |
|
254 |
- } |
|
148 |
+ return resUtil.successRes(result, MessageCode.COMMON_SUCCESS); |
|
255 | 149 |
} |
150 |
+ |
|
256 | 151 |
/** |
257 |
- * @author 방선주 |
|
258 |
- * @since 2024.05.22 |
|
259 |
- * @param params |
|
260 |
- * @return |
|
261 |
- * @throws Exception |
|
152 |
+ * @param params - 게시판 내용 정보 |
|
153 |
+ * @return ResponseEntity - 조회수 증가 결과를 포함하는 응답 |
|
262 | 154 |
* |
263 | 155 |
* 조회수 증가 |
264 | 156 |
*/ |
265 | 157 |
@PostMapping("/updateVwCnt.json") |
266 |
- public ResponseEntity<?> updateVwCnt(@RequestBody HashMap<String, Object> params) throws Exception { |
|
267 |
- |
|
158 |
+ public ResponseEntity<?> updateVwCnt(@RequestBody HashMap<String, Object> params) { |
|
268 | 159 |
// 조회수 증가 |
269 | 160 |
int result = bbsCnService.updateVwCnt(params); |
270 |
- |
|
271 |
- // 응답 처리 |
|
272 |
- if(result > 0) { |
|
273 |
- return resUtil.successRes(result, MessageCode.COMMON_SUCCESS); |
|
274 |
- } else { |
|
275 |
- return resUtil.errorRes(MessageCode.COMMON_UPDATE_FAIL); |
|
276 |
- } |
|
161 |
+ return resUtil.successRes(result, MessageCode.COMMON_SUCCESS); |
|
277 | 162 |
} |
278 | 163 |
|
279 | 164 |
/** |
280 |
- * @author 방선주 |
|
281 |
- * @since 2024.05.21 |
|
282 |
- * @param fileId |
|
283 |
- * @return |
|
284 |
- * @throws Exception |
|
165 |
+ * @param fileId - 첨부파일 아이디 |
|
166 |
+ * @param response - HTTP 응답 객체 |
|
167 |
+ * @return ResponseEntity - 댓글 등록 결과를 포함하는 응답 |
|
285 | 168 |
* |
286 | 169 |
* 게시판 첨부 파일 다운로드 |
287 | 170 |
*/ |
... | ... | @@ -314,105 +197,51 @@ |
314 | 197 |
/********* 질의형 게시판 **********/ |
315 | 198 |
|
316 | 199 |
/** |
317 |
- * @author 방선주 |
|
318 |
- * @since 2024.05.31 |
|
319 |
- * @param bbsCnVO |
|
320 |
- * @return |
|
321 |
- * @throws Exception |
|
200 |
+ * @param bbsCnVO - 게시판 내용 정보 |
|
201 |
+ * @return ResponseEntity - 답변 등록 결과를 포함하는 응답 |
|
322 | 202 |
* |
323 | 203 |
* 질의형 게시판 답변 등록 |
324 | 204 |
*/ |
325 | 205 |
@PostMapping("/ansSaveProc.json") |
326 |
- public ResponseEntity<?> ansSaveProc(@RequestBody BbsCnVO bbsCnVO) throws Exception { |
|
327 |
- // 응답 처리 |
|
328 |
- HttpHeaders headers = new HttpHeaders(); |
|
329 |
- headers.setContentType(new MediaType("application", "json", Charset.forName("UTF-8"))); |
|
330 |
- ResponseData responseData = new ResponseData(); |
|
331 |
- |
|
332 |
-// int result = 1; |
|
206 |
+ public ResponseEntity<?> ansSaveProc(@RequestBody BbsCnVO bbsCnVO) { |
|
333 | 207 |
HashMap<String, Object> result = bbsCnService.saveAnswer(bbsCnVO); |
334 |
- int insertResult = (int) result.get("result"); |
|
335 |
- |
|
336 |
- |
|
337 |
- if(insertResult > 0) { |
|
338 |
- return resUtil.successRes(result, MessageCode.COMMON_SUCCESS); |
|
339 |
- } else if (insertResult == -1){ |
|
340 |
- responseData.setStatus(HttpStatus.INTERNAL_SERVER_ERROR.value()); |
|
341 |
- responseData.setStatusText(HttpStatus.INTERNAL_SERVER_ERROR); |
|
342 |
- responseData.setMessage("아래의 금지어가 포함되어 있습니다.\n* " + result.get("word")); |
|
343 |
- return new ResponseEntity<>(responseData, headers, HttpStatus.INTERNAL_SERVER_ERROR); |
|
344 |
- } else { |
|
345 |
- return resUtil.errorRes(MessageCode.COMMON_INSERT_FAIL); |
|
346 |
- } |
|
208 |
+ return resUtil.successRes(result, MessageCode.COMMON_SUCCESS); |
|
347 | 209 |
} |
210 |
+ |
|
348 | 211 |
/** |
349 |
- * @author 방선주 |
|
350 |
- * @since 2024.05.31 |
|
351 |
- * @param bbsCnVO |
|
352 |
- * @return |
|
353 |
- * @throws Exception |
|
212 |
+ * @param bbsCnVO - 게시판 내용 정보 |
|
213 |
+ * @return ResponseEntity - 답변 등록 결과를 포함하는 응답 |
|
354 | 214 |
* |
355 | 215 |
* 질의형 게시판 답변 수정 |
356 | 216 |
*/ |
357 | 217 |
@PostMapping("/ansUpdateProc.json") |
358 |
- public ResponseEntity<?> ansUpdateProc(@RequestBody BbsCnVO bbsCnVO) throws Exception { |
|
359 |
- // 응답 처리 |
|
360 |
- HttpHeaders headers = new HttpHeaders(); |
|
361 |
- headers.setContentType(new MediaType("application", "json", Charset.forName("UTF-8"))); |
|
362 |
- ResponseData responseData = new ResponseData(); |
|
363 |
- |
|
364 |
-// int result = 1; |
|
218 |
+ public ResponseEntity<?> ansUpdateProc(@RequestBody BbsCnVO bbsCnVO) { |
|
365 | 219 |
HashMap<String, Object> result = bbsCnService.updateAnswer(bbsCnVO); |
366 |
- int updateResult = (int) result.get("result"); |
|
367 |
- |
|
368 |
- if(updateResult > 0) { |
|
369 |
- return resUtil.successRes(result, MessageCode.COMMON_SUCCESS); |
|
370 |
- } else if (updateResult == -1){ |
|
371 |
- responseData.setStatus(HttpStatus.INTERNAL_SERVER_ERROR.value()); |
|
372 |
- responseData.setStatusText(HttpStatus.INTERNAL_SERVER_ERROR); |
|
373 |
- responseData.setMessage("아래의 금지어가 포함되어 있습니다.\n* " + result.get("word")); |
|
374 |
- return new ResponseEntity<>(responseData, headers, HttpStatus.INTERNAL_SERVER_ERROR); |
|
375 |
- } else { |
|
376 |
- return resUtil.errorRes(MessageCode.COMMON_UPDATE_FAIL); |
|
377 |
- } |
|
220 |
+ return resUtil.successRes(result, MessageCode.COMMON_SUCCESS); |
|
378 | 221 |
} |
222 |
+ |
|
379 | 223 |
/** |
380 |
- * @author 방선주 |
|
381 |
- * @since 2024.06.07 |
|
382 |
- * @param bbsCnVO |
|
383 |
- * @return |
|
384 |
- * @throws Exception |
|
224 |
+ * @param bbsCnVO - 게시판 내용 정보 |
|
225 |
+ * @return ResponseEntity - 답변 삭제 결과를 포함하는 응답 |
|
385 | 226 |
* |
386 | 227 |
* 질의형 게시판 답변 삭제 |
387 | 228 |
*/ |
388 | 229 |
@PostMapping("/ansDeleteProc.json") |
389 |
- public ResponseEntity<?> ansDeleteProc(@RequestBody BbsCnVO bbsCnVO) throws Exception { |
|
390 |
- // 응답 처리 |
|
391 |
- |
|
392 |
-// int result = 1; |
|
230 |
+ public ResponseEntity<?> ansDeleteProc(@RequestBody BbsCnVO bbsCnVO) { |
|
393 | 231 |
int result = bbsCnService.deleteAns(bbsCnVO); |
394 |
- |
|
395 |
- if(result > 0) { |
|
396 |
- return resUtil.successRes(result, MessageCode.COMMON_SUCCESS); |
|
397 |
- } else { |
|
398 |
- return resUtil.errorRes(MessageCode.COMMON_DELETE_FAIL); |
|
399 |
- } |
|
232 |
+ return resUtil.successRes(result, MessageCode.COMMON_SUCCESS); |
|
400 | 233 |
} |
234 |
+ |
|
401 | 235 |
/** |
402 |
- * @author 방선주 |
|
403 |
- * @since 2024.06.13 |
|
404 |
- * @param |
|
405 |
- * @return |
|
406 |
- * @throws Exception |
|
236 |
+ * @param bbsCn - 게시판 내용 정보 |
|
237 |
+ * @return ResponseEntity - 게시판 내용 목록 조회 결과를 포함하는 응답 |
|
407 | 238 |
* |
408 | 239 |
* 공지사항 최신 5개 조회 |
409 | 240 |
*/ |
410 | 241 |
@PostMapping("/findFiveNotice.json") |
411 |
- public ResponseEntity<?> findFiveNotice(@RequestBody BbsCnVO bbsCn) throws Exception { |
|
242 |
+ public ResponseEntity<?> findFiveNotice(@RequestBody BbsCnVO bbsCn) { |
|
412 | 243 |
// 공지사항 최신 5개 조회 |
413 | 244 |
List<BbsCnVO> result = bbsCnService.findFiveNotice(bbsCn); |
414 |
- |
|
415 |
- // 응답 처리 |
|
416 | 245 |
return resUtil.successRes(result, MessageCode.COMMON_SUCCESS); |
417 | 246 |
} |
418 | 247 |
}(No newline at end of file) |
--- 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 @@ |
47 | 47 |
* - fileMngResult : 파일매니저 등록 결과 |
48 | 48 |
* @throws CustomNotFoundException - 사용자 정보 조회 예외 발생 시 |
49 | 49 |
* @throws CustomInsertFailException - 파일매니저 등록 예외 발생 시 |
50 |
+ * @throws DataAccessException - db 관련 예외 발생 시 |
|
51 |
+ * @throws Exception - 그 외 예외 발생 시 |
|
50 | 52 |
* |
51 | 53 |
* 파일매니저 등록 |
52 | 54 |
*/ |
53 | 55 |
@Override |
54 | 56 |
public HashMap<String, Object> fileMngInsert(FileMngVO fileMngVO, List<MultipartFile> multipartFileList) { |
55 |
- HashMap<String, Object> result = new HashMap<>(); |
|
56 |
- result.put("fileInsertResult", 0); |
|
57 |
+ try { |
|
58 |
+ HashMap<String, Object> result = new HashMap<>(); |
|
59 |
+ result.put("fileInsertResult", 0); |
|
57 | 60 |
|
58 |
- // 파일관리 아이디 생성 |
|
59 |
- String fileMngId = fileMngIdgn.getNextStringId(); |
|
60 |
- fileMngVO.setFileMngId(fileMngId); |
|
61 |
+ // 파일관리 아이디 생성 |
|
62 |
+ String fileMngId = fileMngIdgn.getNextStringId(); |
|
63 |
+ fileMngVO.setFileMngId(fileMngId); |
|
61 | 64 |
|
62 |
- // 작성자 생성 |
|
63 |
- String writer = jwtUtil.getWriter(); |
|
64 |
- if (writer == null || writer.isEmpty()) { |
|
65 |
- throw new CustomNotFoundException("사용자 정보 조회에 실패했습니다."); |
|
65 |
+ // 작성자 생성 |
|
66 |
+ String writer = jwtUtil.getWriter(); |
|
67 |
+ if (writer == null || writer.isEmpty()) { |
|
68 |
+ throw new CustomNotFoundException("사용자 정보 조회에 실패했습니다."); |
|
69 |
+ } |
|
70 |
+ fileMngVO.setRgtr(writer); |
|
71 |
+ |
|
72 |
+ // 파일 등록 |
|
73 |
+ result.put("fileInsertResult", fileService.fileInsert(fileMngId, multipartFileList)); |
|
74 |
+ |
|
75 |
+ // 파일매니저 아이디 삽입 |
|
76 |
+ result.put("fileMngId", fileMngId); |
|
77 |
+ |
|
78 |
+ // DB 등록 |
|
79 |
+ int fileMngResult = fileMngDAO.fileMngInsert(fileMngVO); |
|
80 |
+ if (fileMngResult == 0) { |
|
81 |
+ throw new CustomInsertFailException("파일매니저 등록에 실패했습니다."); |
|
82 |
+ } |
|
83 |
+ result.put("fileMngResult", fileMngResult); |
|
84 |
+ |
|
85 |
+ return result; |
|
86 |
+ } catch (CustomNotFoundException | CustomFileUploadFailException | CustomInsertFailException | IllegalArgumentException le) { |
|
87 |
+ throw le; |
|
88 |
+ } catch (DataAccessException dae) { |
|
89 |
+ throw dae; |
|
90 |
+ } catch (Exception e) { |
|
91 |
+ throw e; |
|
66 | 92 |
} |
67 |
- fileMngVO.setRgtr(writer); |
|
68 |
- |
|
69 |
- // 파일 등록 |
|
70 |
- result.put("fileInsertResult", fileService.fileInsert(fileMngId, multipartFileList)); |
|
71 |
- |
|
72 |
- // 파일매니저 아이디 삽입 |
|
73 |
- result.put("fileMngId", fileMngId); |
|
74 |
- |
|
75 |
- // DB 등록 |
|
76 |
- int fileMngResult = fileMngDAO.fileMngInsert(fileMngVO); |
|
77 |
- if (fileMngResult == 0) { |
|
78 |
- throw new CustomInsertFailException("파일매니저 등록에 실패했습니다."); |
|
79 |
- } |
|
80 |
- result.put("fileMngResult", fileMngResult); |
|
81 |
- |
|
82 |
- return result; |
|
83 | 93 |
} |
84 | 94 |
|
85 | 95 |
/** |
... | ... | @@ -89,65 +99,86 @@ |
89 | 99 |
* @return int - 파일매니저 수정 결과 |
90 | 100 |
* @throws CustomNotFoundException - 사용자 정보 조회 예외 발생 시 |
91 | 101 |
* @throws CustomUpdateFailException - 파일매니저 수정 예외 발생 시 |
102 |
+ * @throws DataAccessException - db 관련 예외 발생 시 |
|
103 |
+ * @throws Exception - 그 외 예외 발생 시 |
|
92 | 104 |
* |
93 | 105 |
* 파일매니저 수정 |
94 | 106 |
*/ |
95 | 107 |
@Override |
96 | 108 |
public int fileMngUpadate(FileMngVO fileMngVO, List<HashMap<String, Object>> deleteFileList, List<MultipartFile> multipartFileList) { |
97 |
- int insertResult = 0; |
|
98 |
- int deleteResult = 0; |
|
99 |
- int result = 0; |
|
109 |
+ try { |
|
110 |
+ int insertResult = 0; |
|
111 |
+ int deleteResult = 0; |
|
112 |
+ int result = 0; |
|
100 | 113 |
|
101 |
- // 수정자 생성 |
|
102 |
- String writer = jwtUtil.getWriter(); |
|
103 |
- if(writer == null || writer.isEmpty()){ |
|
104 |
- throw new CustomNotFoundException("사용자 정보 조회에 실패했습니다."); |
|
105 |
- } |
|
106 |
- fileMngVO.setMdfr(writer); |
|
114 |
+ // 수정자 생성 |
|
115 |
+ String writer = jwtUtil.getWriter(); |
|
116 |
+ if (writer == null || writer.isEmpty()) { |
|
117 |
+ throw new CustomNotFoundException("사용자 정보 조회에 실패했습니다."); |
|
118 |
+ } |
|
119 |
+ fileMngVO.setMdfr(writer); |
|
107 | 120 |
|
108 |
- // 파일 추가 |
|
109 |
- if (multipartFileList != null && multipartFileList.size() > 0) { |
|
121 |
+ // 파일 추가 |
|
122 |
+ if (multipartFileList != null && multipartFileList.size() > 0) { |
|
123 |
+ // DB 등록 |
|
124 |
+ String fileMngId = fileMngVO.getFileMngId(); |
|
125 |
+ insertResult = fileService.fileInsert(fileMngId, multipartFileList); |
|
126 |
+ } |
|
127 |
+ |
|
128 |
+ // 파일 삭제 |
|
129 |
+ if (deleteFileList != null && deleteFileList.size() > 0) { |
|
130 |
+ deleteResult = fileService.fileDelete(deleteFileList); |
|
131 |
+ } |
|
132 |
+ |
|
110 | 133 |
// DB 등록 |
111 |
- String fileMngId = fileMngVO.getFileMngId(); |
|
112 |
- insertResult = fileService.fileInsert(fileMngId, multipartFileList); |
|
113 |
- } |
|
134 |
+ result = fileMngDAO.fileMngUpadate(fileMngVO); |
|
135 |
+ if (result == 0) { |
|
136 |
+ throw new CustomUpdateFailException("파일매니저 수정에 실패했습니다."); |
|
137 |
+ } |
|
114 | 138 |
|
115 |
- // 파일 삭제 |
|
116 |
- if (deleteFileList != null && deleteFileList.size() > 0) { |
|
117 |
- deleteResult = fileService.fileDelete(deleteFileList); |
|
139 |
+ return result; |
|
140 |
+ } catch (CustomNotFoundException | CustomFileUploadFailException | CustomInsertFailException | IllegalArgumentException |
|
141 |
+ | CustomDeleteFailException le) { |
|
142 |
+ throw le; |
|
143 |
+ } catch (DataAccessException dae) { |
|
144 |
+ throw dae; |
|
145 |
+ } catch (Exception e) { |
|
146 |
+ throw e; |
|
118 | 147 |
} |
119 |
- |
|
120 |
- // DB 등록 |
|
121 |
- result = fileMngDAO.fileMngUpadate(fileMngVO); |
|
122 |
- if(result == 0){ |
|
123 |
- throw new CustomUpdateFailException("파일매니저 수정에 실패했습니다."); |
|
124 |
- } |
|
125 |
- |
|
126 |
- return result; |
|
127 | 148 |
} |
128 | 149 |
|
129 | 150 |
/** |
130 | 151 |
* @param params - 파일매니저 아이디 |
131 | 152 |
* @return int - 파일매니저 삭제 결과 |
132 | 153 |
* @throws CustomDeleteFailException - 파일매니저 삭제 예외 발생 시 |
154 |
+ * @throws DataAccessException - db 관련 예외 발생 시 |
|
155 |
+ * @throws Exception - 그 외 예외 발생 시 |
|
133 | 156 |
* |
134 | 157 |
* 파일매니저 삭제 |
135 | 158 |
*/ |
136 | 159 |
@Override |
137 | 160 |
public int fileMngDelete(HashMap<String, Object> params) { |
138 |
- int deleteResult = 0; |
|
139 |
- int result = 0; |
|
161 |
+ try { |
|
162 |
+ int deleteResult = 0; |
|
163 |
+ int result = 0; |
|
140 | 164 |
|
141 |
- // 파일 삭제 |
|
142 |
- List<HashMap<String, Object>> fileList = fileService.fileSelectList(params.get("fileMngId").toString()); |
|
143 |
- deleteResult = fileService.fileDelete(fileList); |
|
165 |
+ // 파일 삭제 |
|
166 |
+ List<HashMap<String, Object>> fileList = fileService.fileSelectList(params.get("fileMngId").toString()); |
|
167 |
+ deleteResult = fileService.fileDelete(fileList); |
|
144 | 168 |
|
145 |
- // DB 등록 |
|
146 |
- result = fileMngDAO.fileMngDelete(params); |
|
147 |
- if(result == 0){ |
|
148 |
- throw new CustomDeleteFailException("파일매니저 삭제에 실패했습니다."); |
|
169 |
+ // DB 등록 |
|
170 |
+ result = fileMngDAO.fileMngDelete(params); |
|
171 |
+ if (result == 0) { |
|
172 |
+ throw new CustomDeleteFailException("파일매니저 삭제에 실패했습니다."); |
|
173 |
+ } |
|
174 |
+ |
|
175 |
+ return result; |
|
176 |
+ } catch (CustomDeleteFailException le) { |
|
177 |
+ throw le; |
|
178 |
+ } catch (DataAccessException dae) { |
|
179 |
+ throw dae; |
|
180 |
+ } catch (Exception e) { |
|
181 |
+ throw e; |
|
149 | 182 |
} |
150 |
- |
|
151 |
- return result; |
|
152 | 183 |
} |
153 | 184 |
}(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
... | ... | @@ -69,11 +69,11 @@ |
69 | 69 |
* @param fileMngId - 파일관리아이디 |
70 | 70 |
* @param multipartFileList - 파일 목록 |
71 | 71 |
* @return int - 파일 등록 결과 |
72 |
+ * @throws IllegalArgumentException - 잘못된 인자 예외 발생 시 |
|
72 | 73 |
* @throws RuntimeException - 파일 크기 초과 예외 발생 시 |
73 | 74 |
* @throws CustomInsertFailException - 파일 등록 예외 발생 시 |
74 | 75 |
* @throws CustomNotFoundException - 사용자 정보 조회 예외 발생 시 |
75 | 76 |
* @throws CustomFileUploadFailException - 파일 업로드 예외 발생 시 |
76 |
- * @throws IllegalArgumentException - 잘못된 인자 예외 발생 시 |
|
77 | 77 |
* @throws DataAccessException - db 관련 예외 발생 시 |
78 | 78 |
* @throws Exception - 그 외 예외 발생 시 |
79 | 79 |
* |
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?