PsHooN7979
08-06
240806 박세훈 학생 게시판 관련 crud 추가
@8b7466849591a5f53d6ec39b724a590531021f6b
--- src/main/java/com/takensoft/ai_lms/lms/board/dao/BoardDAO.java
+++ src/main/java/com/takensoft/ai_lms/lms/board/dao/BoardDAO.java
... | ... | @@ -1,6 +1,7 @@ |
1 | 1 |
package com.takensoft.ai_lms.lms.board.dao; |
2 | 2 |
|
3 | 3 |
|
4 |
+import com.takensoft.ai_lms.lms.board.vo.BoardStudentVO; |
|
4 | 5 |
import com.takensoft.ai_lms.lms.board.vo.BoardVO; |
5 | 6 |
import org.egovframe.rte.psl.dataaccess.mapper.Mapper; |
6 | 7 |
|
... | ... | @@ -38,6 +39,29 @@ |
38 | 39 |
// 게시글 검색 |
39 | 40 |
List<HashMap<String, Object>> searchBoard(HashMap<String, Object> params) throws Exception; |
40 | 41 |
|
42 |
+ // 학생 게시판 등록 |
|
43 |
+ int insertBoardStudent(BoardStudentVO boardStudentVO) throws Exception; |
|
44 |
+ |
|
45 |
+ // 학생 게시판 삭세 |
|
46 |
+ int deleteBoardStudent(String bbsId) throws Exception; |
|
47 |
+ |
|
48 |
+ // 학생 게시판 조회 |
|
49 |
+ List<BoardStudentVO> boardStudentList(HashMap<String, Object> params) throws Exception; |
|
50 |
+ |
|
51 |
+ // 학생 게시판 수 조회 |
|
52 |
+ int boardStudentCount(HashMap<String, Object> params) throws Exception; |
|
53 |
+ |
|
54 |
+ // 학생 게시판 조회 여부 체크 |
|
55 |
+ int updateBoardCheck(HashMap<String, Object> params) throws Exception; |
|
56 |
+ |
|
57 |
+ // 학생 게시판 조회 여부 일괄 갱신 |
|
58 |
+ int updateAllBoardCheck(HashMap<String, Object> params) throws Exception; |
|
59 |
+ |
|
60 |
+ // 학생 게시판 조회 안한 게시물 수 조회 |
|
61 |
+ int checkCount(HashMap<String, Object> params) throws Exception; |
|
62 |
+ |
|
63 |
+ |
|
64 |
+ |
|
41 | 65 |
|
42 | 66 |
|
43 | 67 |
} |
--- src/main/java/com/takensoft/ai_lms/lms/board/service/BoardService.java
+++ src/main/java/com/takensoft/ai_lms/lms/board/service/BoardService.java
... | ... | @@ -1,5 +1,6 @@ |
1 | 1 |
package com.takensoft.ai_lms.lms.board.service; |
2 | 2 |
|
3 |
+import com.takensoft.ai_lms.lms.board.vo.BoardStudentVO; |
|
3 | 4 |
import com.takensoft.ai_lms.lms.board.vo.BoardVO; |
4 | 5 |
|
5 | 6 |
import java.util.HashMap; |
... | ... | @@ -34,4 +35,25 @@ |
34 | 35 |
|
35 | 36 |
// 게시글 검색 |
36 | 37 |
List<HashMap<String, Object>> searchBoard(HashMap<String, Object> params) throws Exception; |
38 |
+ |
|
39 |
+ // 학생 게시판 등록 |
|
40 |
+ int insertBoardStudent(BoardStudentVO boardStudentVO) throws Exception; |
|
41 |
+ |
|
42 |
+ // 학생 게시판 삭세 |
|
43 |
+ int deleteBoardStudent(String bbsId) throws Exception; |
|
44 |
+ |
|
45 |
+ // 학생 게시판 전체 조회 |
|
46 |
+ List<BoardStudentVO> boardStudentList(HashMap<String, Object> params) throws Exception; |
|
47 |
+ |
|
48 |
+ // 학생 게시판 수 조회 |
|
49 |
+ int boardStudentCount(HashMap<String, Object> params) throws Exception; |
|
50 |
+ |
|
51 |
+ // 학생 게시판 조회 여부 체크 |
|
52 |
+ int updateBoardCheck(HashMap<String, Object> params) throws Exception; |
|
53 |
+ |
|
54 |
+ // 학생 게시판 조회 여부 일괄 갱신 |
|
55 |
+ int updateAllBoardCheck(HashMap<String, Object> params) throws Exception; |
|
56 |
+ |
|
57 |
+ // 학생 게시판 조회 안한 게시물 수 조회 |
|
58 |
+ int checkCount(HashMap<String, Object> params) throws Exception; |
|
37 | 59 |
} |
--- src/main/java/com/takensoft/ai_lms/lms/board/service/impl/BoardServiceImpl.java
+++ src/main/java/com/takensoft/ai_lms/lms/board/service/impl/BoardServiceImpl.java
... | ... | @@ -3,6 +3,7 @@ |
3 | 3 |
import com.takensoft.ai_lms.common.idgen.service.IdgenService; |
4 | 4 |
import com.takensoft.ai_lms.lms.board.dao.BoardDAO; |
5 | 5 |
import com.takensoft.ai_lms.lms.board.service.BoardService; |
6 |
+import com.takensoft.ai_lms.lms.board.vo.BoardStudentVO; |
|
6 | 7 |
import com.takensoft.ai_lms.lms.board.vo.BoardVO; |
7 | 8 |
import lombok.RequiredArgsConstructor; |
8 | 9 |
import org.egovframe.rte.fdl.cmmn.EgovAbstractServiceImpl; |
... | ... | @@ -24,7 +25,15 @@ |
24 | 25 |
public int insertBoard(BoardVO boardVO) throws Exception { |
25 | 26 |
String boardId = boardIdgn.getNextStringId(); |
26 | 27 |
boardVO.setBbsId(boardId); |
27 |
- return boardDAO.insertBoard(boardVO); |
|
28 |
+ int result = boardDAO.insertBoard(boardVO); |
|
29 |
+ |
|
30 |
+ if(result > 0) { |
|
31 |
+ BoardStudentVO boardStudentVO = new BoardStudentVO(); |
|
32 |
+ boardStudentVO.setBbsId(boardId); |
|
33 |
+ boardDAO.insertBoardStudent(boardStudentVO); |
|
34 |
+ } |
|
35 |
+ |
|
36 |
+ return result; |
|
28 | 37 |
} |
29 | 38 |
// 게시글 전체 조회 |
30 | 39 |
@Override |
... | ... | @@ -62,7 +71,13 @@ |
62 | 71 |
// 게시글 삭제 |
63 | 72 |
@Override |
64 | 73 |
public int deleteBoard(String bbsId) throws Exception{ |
65 |
- return boardDAO.deleteBoard(bbsId); |
|
74 |
+ int result = boardDAO.deleteBoard(bbsId); |
|
75 |
+ |
|
76 |
+ if(result > 0) { |
|
77 |
+ boardDAO.deleteBoardStudent(bbsId); |
|
78 |
+ } |
|
79 |
+ |
|
80 |
+ return result; |
|
66 | 81 |
} |
67 | 82 |
|
68 | 83 |
// 게시글 검색 |
... | ... | @@ -72,6 +87,57 @@ |
72 | 87 |
} |
73 | 88 |
|
74 | 89 |
|
90 |
+ // 학생 게시판 등록 |
|
91 |
+ @Override |
|
92 |
+ public int insertBoardStudent(BoardStudentVO boardStudentVO) throws Exception { |
|
93 |
+ return boardDAO.insertBoardStudent(boardStudentVO); |
|
94 |
+ } |
|
95 |
+ |
|
96 |
+ // 학생 게시판 삭세 |
|
97 |
+ @Override |
|
98 |
+ public int deleteBoardStudent(String bbsId) throws Exception { |
|
99 |
+ return boardDAO.deleteBoardStudent(bbsId); |
|
100 |
+ } |
|
101 |
+ |
|
102 |
+ |
|
103 |
+ // 학생 게시판 조회 |
|
104 |
+ @Override |
|
105 |
+ public List<BoardStudentVO> boardStudentList(HashMap<String, Object> params) throws Exception{ |
|
106 |
+ int page = Integer.parseInt(params.get("page").toString()); |
|
107 |
+ int pageSize = Integer.parseInt(params.get("pageSize").toString()); |
|
108 |
+ |
|
109 |
+ // 조회를 위한 startIndex 계산 |
|
110 |
+ int startIndex = (page - 1) * pageSize; |
|
111 |
+ params.put("startIndex", startIndex); |
|
112 |
+ params.put("pageSize", pageSize); |
|
113 |
+ System.out.println(startIndex); |
|
114 |
+ return boardDAO.boardStudentList(params); |
|
115 |
+ } |
|
116 |
+ |
|
117 |
+ // 학생 게시판 수 조회 |
|
118 |
+ @Override |
|
119 |
+ public int boardStudentCount(HashMap<String, Object> params) throws Exception { |
|
120 |
+ return boardDAO.boardStudentCount(params); |
|
121 |
+ } |
|
122 |
+ |
|
123 |
+ // 학생 게시판 조회 여부 체크 |
|
124 |
+ @Override |
|
125 |
+ public int updateBoardCheck(HashMap<String, Object> params) throws Exception{ |
|
126 |
+ return boardDAO.updateBoardCheck(params); |
|
127 |
+ } |
|
128 |
+ |
|
129 |
+ // 학생 게시판 조회 여부 일괄 갱신 |
|
130 |
+ @Override |
|
131 |
+ public int updateAllBoardCheck(HashMap<String, Object> params) throws Exception{ |
|
132 |
+ return boardDAO.updateAllBoardCheck(params); |
|
133 |
+ } |
|
134 |
+ |
|
135 |
+ // 학생 게시판 조회 안한 게시물 수 조회 |
|
136 |
+ @Override |
|
137 |
+ public int checkCount(HashMap<String, Object> params) throws Exception{ |
|
138 |
+ return boardDAO.checkCount(params); |
|
139 |
+ } |
|
140 |
+ |
|
75 | 141 |
|
76 | 142 |
|
77 | 143 |
} |
+++ src/main/java/com/takensoft/ai_lms/lms/board/vo/BoardStudentVO.java
... | ... | @@ -0,0 +1,30 @@ |
1 | +package com.takensoft.ai_lms.lms.board.vo; | |
2 | + | |
3 | + | |
4 | +import lombok.AllArgsConstructor; | |
5 | +import lombok.Getter; | |
6 | +import lombok.NoArgsConstructor; | |
7 | +import lombok.Setter; | |
8 | + | |
9 | +/** | |
10 | + * @author : 박세훈 | |
11 | + * since : 2024.08.06 | |
12 | + * | |
13 | + * 학생 게시판 정보 관련 VO | |
14 | + */ | |
15 | + | |
16 | +@Getter | |
17 | +@Setter | |
18 | +@NoArgsConstructor | |
19 | +@AllArgsConstructor | |
20 | +public class BoardStudentVO { | |
21 | + | |
22 | + // 학생 아이디 | |
23 | + private String stdId; | |
24 | + | |
25 | + // 게시판 아이디 | |
26 | + private String bbsId; | |
27 | + | |
28 | + // 공지 조회 여부 | |
29 | + private String checkYn; | |
30 | +} |
--- src/main/java/com/takensoft/ai_lms/lms/board/web/BoardController.java
+++ src/main/java/com/takensoft/ai_lms/lms/board/web/BoardController.java
... | ... | @@ -2,6 +2,7 @@ |
2 | 2 |
|
3 | 3 |
|
4 | 4 |
import com.takensoft.ai_lms.lms.board.service.BoardService; |
5 |
+import com.takensoft.ai_lms.lms.board.vo.BoardStudentVO; |
|
5 | 6 |
import com.takensoft.ai_lms.lms.board.vo.BoardVO; |
6 | 7 |
import com.takensoft.ai_lms.lms.file.service.FileService; |
7 | 8 |
import lombok.RequiredArgsConstructor; |
... | ... | @@ -141,5 +142,52 @@ |
141 | 142 |
} |
142 | 143 |
|
143 | 144 |
|
145 |
+ /** |
|
146 |
+ * @author 박세훈 |
|
147 |
+ * @since 2024.08.06 |
|
148 |
+ * |
|
149 |
+ * 학생 게시판 조회 |
|
150 |
+ */ |
|
151 |
+ @PostMapping("/boardStudentList.json") |
|
152 |
+ public ResponseEntity<?> boardStudentList(@RequestBody HashMap<String, Object> params) throws Exception{ |
|
153 |
+ HashMap<String, Object> result = new HashMap<>(); |
|
154 |
+ |
|
155 |
+ // 전체 게시물 수 조회 및 추가 |
|
156 |
+ result.put("totalBoard", boardService.boardStudentCount(params)); |
|
157 |
+ result.put("result", boardService.boardStudentList(params)); |
|
158 |
+ result.put("unCheck", boardService.checkCount(params)); |
|
159 |
+ |
|
160 |
+ return new ResponseEntity<>(result, HttpStatus.OK); |
|
161 |
+ } |
|
162 |
+ |
|
163 |
+ |
|
164 |
+ /** |
|
165 |
+ * @author 박세훈 |
|
166 |
+ * @since 2024.08.06 |
|
167 |
+ * |
|
168 |
+ * 학생 게시판 조회 여부 체크 |
|
169 |
+ */ |
|
170 |
+ @PostMapping("/boardStudentCheck.json") |
|
171 |
+ public int updateBoardCheck(@RequestBody HashMap<String, Object> params) throws Exception { |
|
172 |
+ return boardService.updateBoardCheck(params); |
|
173 |
+ } |
|
174 |
+ |
|
175 |
+ |
|
176 |
+ /** |
|
177 |
+ * @author 박세훈 |
|
178 |
+ * @since 2024.08.06 |
|
179 |
+ * |
|
180 |
+ * 학생 게시판 조회 여부 일괄 갱신 |
|
181 |
+ */ |
|
182 |
+ @PostMapping("/allBoardStudentCheck.json") |
|
183 |
+ public int updateAllBoardCheck(@RequestBody HashMap<String, Object> params) throws Exception { |
|
184 |
+ return boardService.updateAllBoardCheck(params); |
|
185 |
+ } |
|
186 |
+ |
|
187 |
+ |
|
188 |
+ |
|
189 |
+ |
|
190 |
+ |
|
191 |
+ |
|
144 | 192 |
|
145 | 193 |
} |
--- src/main/resources/mybatis/mapper/lms/board-SQL.xml
+++ src/main/resources/mybatis/mapper/lms/board-SQL.xml
... | ... | @@ -63,6 +63,12 @@ |
63 | 63 |
</collection> |
64 | 64 |
</resultMap> |
65 | 65 |
|
66 |
+ <resultMap id="boardStudentResultMap" type="BoardStudentVO"> |
|
67 |
+ <result property="stdId" column="std_id" /> |
|
68 |
+ <result property="bbsId" column="bbs_id" /> |
|
69 |
+ <result property="checkYn" column="check_yn" /> |
|
70 |
+ </resultMap> |
|
71 |
+ |
|
66 | 72 |
<!-- |
67 | 73 |
작성자 : 박세훈 |
68 | 74 |
작성일 : 2024.07.25 |
... | ... | @@ -102,16 +108,7 @@ |
102 | 108 |
내 용 : 게시글 전체 조회 |
103 | 109 |
--> |
104 | 110 |
<select id="findAllBoard" resultMap="boardResultMap"> |
105 |
- SELECT b.bbs_id, |
|
106 |
- b.bbs_ttl, |
|
107 |
- b.bbs_cls, |
|
108 |
- b.bbs_cnt, |
|
109 |
- b.bbs_tm, |
|
110 |
- b.file_mng_id, |
|
111 |
- c.scls_id, |
|
112 |
- c.scls_nm, |
|
113 |
- u.user_id, |
|
114 |
- u.user_nm |
|
111 |
+ SELECT * |
|
115 | 112 |
FROM board b |
116 | 113 |
LEFT JOIN class c ON b.scls_id = c.scls_id |
117 | 114 |
LEFT JOIN users u ON c.user_id = u.user_id |
... | ... | @@ -141,16 +138,7 @@ |
141 | 138 |
내 용 : 게시글 검색 |
142 | 139 |
--> |
143 | 140 |
<select id="searchBoard" resultMap="boardResultMap"> |
144 |
- SELECT b.bbs_id, |
|
145 |
- b.bbs_ttl, |
|
146 |
- b.bbs_cls, |
|
147 |
- b.bbs_cnt, |
|
148 |
- b.bbs_tm, |
|
149 |
- b.file_mng_id, |
|
150 |
- c.scls_id, |
|
151 |
- c.scls_nm, |
|
152 |
- u.user_id, |
|
153 |
- u.user_nm |
|
141 |
+ SELECT * |
|
154 | 142 |
FROM board b |
155 | 143 |
LEFT JOIN class c ON b.scls_id = c.scls_id |
156 | 144 |
LEFT JOIN users u ON c.user_id = u.user_id |
... | ... | @@ -196,5 +184,97 @@ |
196 | 184 |
DELETE FROM board WHERE bbs_id = #{bbsId} |
197 | 185 |
</delete> |
198 | 186 |
|
187 |
+ |
|
188 |
+ <!-- |
|
189 |
+ 작성자 : 박세훈 |
|
190 |
+ 작성일 : 2024.08.06 |
|
191 |
+ 내 용 : 학생 게시판 등록 |
|
192 |
+ --> |
|
193 |
+ <insert id="insertBoardStudent" parameterType="BoardStudentVO"> |
|
194 |
+ INSERT INTO user_board (std_id, |
|
195 |
+ bbs_id, |
|
196 |
+ check_yn) |
|
197 |
+ SELECT u.std_id, b.bbs_id, 'F' |
|
198 |
+ FROM user_class u |
|
199 |
+ JOIN board b ON u.scls_id = b.scls_id |
|
200 |
+ ON CONFLICT (std_id, bbs_id) |
|
201 |
+ DO NOTHING; |
|
202 |
+ </insert> |
|
203 |
+ |
|
204 |
+ <!-- |
|
205 |
+ 작성자 : 박세훈 |
|
206 |
+ 작성일 : 2024.08.06 |
|
207 |
+ 내 용 : 학생 게시판 삭제 |
|
208 |
+ --> |
|
209 |
+ <delete id="deleteBoardStudent" parameterType="String"> |
|
210 |
+ DELETE FROM user_board |
|
211 |
+ WHERE bbs_id = #{bbsId} |
|
212 |
+ </delete> |
|
213 |
+ |
|
214 |
+ <!-- |
|
215 |
+ 작성자 : 박세훈 |
|
216 |
+ 작성일 : 2024.08.06 |
|
217 |
+ 내 용 : 학생 게시판 조회 |
|
218 |
+ --> |
|
219 |
+ <select id="boardStudentList" resultMap="boardResultMap" > |
|
220 |
+ SELECT * |
|
221 |
+ FROM user_class uc |
|
222 |
+ JOIN board b ON uc.scls_id = b.scls_id |
|
223 |
+ LEFT JOIN class c ON b.scls_id = c.scls_id |
|
224 |
+ LEFT JOIN users u ON c.user_id = u.user_id |
|
225 |
+ WHERE uc.std_id = #{stdId} |
|
226 |
+ ORDER BY b.bbs_id DESC |
|
227 |
+ LIMIT #{pageSize} OFFSET #{startIndex} |
|
228 |
+ </select> |
|
229 |
+ |
|
230 |
+ <!-- |
|
231 |
+ 작성자 : 박세훈 |
|
232 |
+ 작성일 : 2024.08.06 |
|
233 |
+ 내 용 : 학생 게시판 조회 여부 갱신 |
|
234 |
+ --> |
|
235 |
+ <update id="updateBoardCheck" parameterType="BoardStudentVO"> |
|
236 |
+ UPDATE user_board |
|
237 |
+ set check_yn = 'T' |
|
238 |
+ WHERE bbs_id = #{bbsId} |
|
239 |
+ AND std_id = #{stdId} |
|
240 |
+ AND check_yn = 'F' |
|
241 |
+ </update> |
|
242 |
+ |
|
243 |
+ <!-- |
|
244 |
+ 작성자 : 박세훈 |
|
245 |
+ 작성일 : 2024.08.06 |
|
246 |
+ 내 용 : 학생 게시판 조회 여부 일괄 갱신 |
|
247 |
+ --> |
|
248 |
+ <update id="updateAllBoardCheck" parameterType="BoardStudentVO"> |
|
249 |
+ UPDATE user_board |
|
250 |
+ set check_yn = 'T' |
|
251 |
+ WHERE std_id = #{stdId} |
|
252 |
+ AND check_yn = 'F' |
|
253 |
+ </update> |
|
254 |
+ |
|
255 |
+ <!-- |
|
256 |
+ 작성자 : 박세훈 |
|
257 |
+ 작성일 : 2024.08.06 |
|
258 |
+ 내 용 : 학생 게시판 게시물 수 확인 |
|
259 |
+ --> |
|
260 |
+ <select id="boardStudentCount" resultType="Integer"> |
|
261 |
+ SELECT COUNT(*) |
|
262 |
+ FROM user_board |
|
263 |
+ WHERE std_id = #{stdId} |
|
264 |
+ </select> |
|
265 |
+ |
|
266 |
+ |
|
267 |
+ <!-- |
|
268 |
+ 작성자 : 박세훈 |
|
269 |
+ 작성일 : 2024.08.06 |
|
270 |
+ 내 용 : 학생 게시판 미조회 게시물 수 확인 |
|
271 |
+ --> |
|
272 |
+ <select id="checkCount" resultType="Integer"> |
|
273 |
+ SELECT COUNT(*) |
|
274 |
+ FROM user_board |
|
275 |
+ WHERE check_yn = 'F' AND std_id = #{stdId} |
|
276 |
+ </select> |
|
277 |
+ |
|
278 |
+ |
|
199 | 279 |
</mapper> |
200 | 280 |
|
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?