PsHooN7979
07-30
240730 박세훈 게시판 sql 수정
@8fa49ba86840a4c1df82d2815688335cfa639232
+++ src/main/java/com/takensoft/ai_lms/lms/board/vo/BoardClassVO.java
... | ... | @@ -0,0 +1,34 @@ |
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 | +import java.util.List; | |
10 | + | |
11 | +/** | |
12 | + * @author : 박세훈 | |
13 | + * since : 2024.07.25 | |
14 | + * | |
15 | + * 게시판 class 관련 VO | |
16 | + */ | |
17 | + | |
18 | + | |
19 | + | |
20 | +@Getter | |
21 | +@Setter | |
22 | +@AllArgsConstructor | |
23 | +@NoArgsConstructor | |
24 | +public class BoardClassVO { | |
25 | + | |
26 | + // 반 아이디 | |
27 | + private String sclsId; | |
28 | + | |
29 | + //반 이름 | |
30 | + private String sclsNm; | |
31 | + | |
32 | + // 게시판 테이블과 연결 | |
33 | + private List<BoardVO> board; | |
34 | +} |
+++ src/main/java/com/takensoft/ai_lms/lms/board/vo/BoardUserVO.java
... | ... | @@ -0,0 +1,34 @@ |
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 | +import java.util.List; | |
10 | + | |
11 | +/** | |
12 | + * @author : 박세훈 | |
13 | + * since : 2024.07.25 | |
14 | + * | |
15 | + * 게시판 user 관련 VO | |
16 | + */ | |
17 | + | |
18 | + | |
19 | + | |
20 | +@Getter | |
21 | +@Setter | |
22 | +@AllArgsConstructor | |
23 | +@NoArgsConstructor | |
24 | +public class BoardUserVO { | |
25 | + | |
26 | + // 사용자 아이디 | |
27 | + private String userId; | |
28 | + | |
29 | + // 사용자 이름 | |
30 | + private String userNm; | |
31 | + | |
32 | + // 반 테이블과 연결 | |
33 | + private List<BoardClassVO> boardClass; | |
34 | +} |
--- src/main/java/com/takensoft/ai_lms/lms/board/vo/BoardVO.java
+++ src/main/java/com/takensoft/ai_lms/lms/board/vo/BoardVO.java
... | ... | @@ -32,15 +32,15 @@ |
32 | 32 |
// 게시판 아이디 |
33 | 33 |
private String bbsId; |
34 | 34 |
// 게시판 제목 |
35 |
- private String bbsTitle; |
|
35 |
+ private String bbsTtl; |
|
36 | 36 |
// 게시판 카테고리 |
37 |
- private String bbsCategory; |
|
37 |
+ private String bbsCls; |
|
38 | 38 |
// 게시판 내용 |
39 |
- private String bbsContents; |
|
39 |
+ private String bbsCnt; |
|
40 | 40 |
// 게시판 등록 날짜 |
41 |
- private String bbsTime; |
|
41 |
+ private String bbsTm; |
|
42 | 42 |
// 파일 관리 아이디 |
43 |
- private String fileManageId; |
|
43 |
+ private String fileMngId; |
|
44 | 44 |
// 반 아이디 |
45 | 45 |
private String sclsId; |
46 | 46 |
|
--- src/main/resources/mybatis/mapper/lms/board-SQL.xml
+++ src/main/resources/mybatis/mapper/lms/board-SQL.xml
... | ... | @@ -12,6 +12,23 @@ |
12 | 12 |
<result property="sclsId" column="scls_id"/> |
13 | 13 |
</resultMap> |
14 | 14 |
|
15 |
+ <resultMap id="boardResultMap" type="BoardUserVO"> |
|
16 |
+ <result property="userId" column="user_id" /> |
|
17 |
+ <result property="userNm" column="user_nm" /> |
|
18 |
+ <collection property="boardClass" ofType="BoardClassVO"> |
|
19 |
+ <id property="sclsId" column="scls_id" /> |
|
20 |
+ <result property="sclsNm" column="scls_nm" /> |
|
21 |
+ <collection property="board" ofType="BoardVO" > |
|
22 |
+ <id property="bbsId" column="bbs_id"/> |
|
23 |
+ <result property="bbsTtl" column="bbs_ttl"/> |
|
24 |
+ <result property="bbsCls" column="bbs_cls"/> |
|
25 |
+ <result property="bbsCnt" column="bbs_cnt"/> |
|
26 |
+ <result property="bbsTm" column="bbs_tm"/> |
|
27 |
+ <result property="fileMngId" column="file_mng_id"/> |
|
28 |
+ <result property="sclsId" column="scls_id"/> |
|
29 |
+ </collection> |
|
30 |
+ </collection> |
|
31 |
+ </resultMap> |
|
15 | 32 |
|
16 | 33 |
<!-- |
17 | 34 |
작성자 : 박세훈 |
... | ... | @@ -51,11 +68,22 @@ |
51 | 68 |
작성일 : 2024.07.25 |
52 | 69 |
내 용 : 게시글 전체 조회 |
53 | 70 |
--> |
54 |
- <select id="findAllBoard" resultMap="boardMap"> |
|
55 |
- SELECT * |
|
56 |
- FROM board |
|
57 |
- WHERE scls_id = #{sclsId} |
|
58 |
- ORDER BY bbs_id DESC |
|
71 |
+ <select id="findAllBoard" resultMap="boardResultMap"> |
|
72 |
+ SELECT b.bbs_id, |
|
73 |
+ b.bbs_ttl, |
|
74 |
+ b.bbs_cls, |
|
75 |
+ b.bbs_cnt, |
|
76 |
+ b.bbs_tm, |
|
77 |
+ b.file_mng_id, |
|
78 |
+ c.scls_id, |
|
79 |
+ c.scls_nm, |
|
80 |
+ u.user_id, |
|
81 |
+ u.user_nm |
|
82 |
+ FROM board b |
|
83 |
+ LEFT JOIN class c ON b.scls_id = c.scls_id |
|
84 |
+ LEFT JOIN users u ON c.user_id = u.user_id |
|
85 |
+ WHERE b.scls_id = #{sclsId} |
|
86 |
+ ORDER BY b.bbs_id DESC |
|
59 | 87 |
LIMIT #{pageSize} OFFSET #{startIndex} |
60 | 88 |
</select> |
61 | 89 |
|
... | ... | @@ -64,10 +92,21 @@ |
64 | 92 |
작성일 : 2024.07.25 |
65 | 93 |
내 용 : 게시글 상세 조회 |
66 | 94 |
--> |
67 |
- <select id="findByBoardId" parameterType="BoardVO" resultMap="boardMap"> |
|
68 |
- SELECT * |
|
69 |
- FROM board |
|
70 |
- WHERE bbs_id = #{bbsId} |
|
95 |
+ <select id="findByBoardId" resultMap="boardResultMap"> |
|
96 |
+ SELECT b.bbs_id, |
|
97 |
+ b.bbs_ttl, |
|
98 |
+ b.bbs_cls, |
|
99 |
+ b.bbs_cnt, |
|
100 |
+ b.bbs_tm, |
|
101 |
+ b.file_mng_id, |
|
102 |
+ c.scls_id, |
|
103 |
+ c.scls_nm, |
|
104 |
+ u.user_id, |
|
105 |
+ u.user_nm |
|
106 |
+ FROM board b |
|
107 |
+ LEFT JOIN class c ON b.scls_id = c.scls_id |
|
108 |
+ LEFT JOIN users u ON c.user_id = u.user_id |
|
109 |
+ WHERE b.bbs_id = #{bbsId} |
|
71 | 110 |
ORDER BY bbs_id DESC |
72 | 111 |
</select> |
73 | 112 |
|
... | ... | @@ -76,9 +115,20 @@ |
76 | 115 |
작성일 : 2024.07.26 |
77 | 116 |
내 용 : 게시글 검색 |
78 | 117 |
--> |
79 |
- <select id="searchBoard" parameterType="BoardVO" resultMap="boardMap"> |
|
80 |
- SELECT * |
|
81 |
- FROM board |
|
118 |
+ <select id="searchBoard" resultMap="boardResultMap"> |
|
119 |
+ SELECT b.bbs_id, |
|
120 |
+ b.bbs_ttl, |
|
121 |
+ b.bbs_cls, |
|
122 |
+ b.bbs_cnt, |
|
123 |
+ b.bbs_tm, |
|
124 |
+ b.file_mng_id, |
|
125 |
+ c.scls_id, |
|
126 |
+ c.scls_nm, |
|
127 |
+ u.user_id, |
|
128 |
+ u.user_nm |
|
129 |
+ FROM board b |
|
130 |
+ LEFT JOIN class c ON b.scls_id = c.scls_id |
|
131 |
+ LEFT JOIN users u ON c.user_id = u.user_id |
|
82 | 132 |
WHERE 1 = 1 |
83 | 133 |
<if test="option != null and keyword != null"> |
84 | 134 |
<choose> |
... | ... | @@ -122,4 +172,5 @@ |
122 | 172 |
DELETE FROM board WHERE bbs_id = #{bbsId} |
123 | 173 |
</delete> |
124 | 174 |
|
125 |
-</mapper>(파일 끝에 줄바꿈 문자 없음) |
|
175 |
+</mapper> |
|
176 |
+ |
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?