PsHooN7979
08-01
240801 박세훈 게시판 상세 조회시 파일 정보 출력 및 게시판 sql 수정
@696e044b62693280b27169d6a67430b7f6220106
--- src/main/java/com/takensoft/ai_lms/lms/board/dao/BoardDAO.java
+++ src/main/java/com/takensoft/ai_lms/lms/board/dao/BoardDAO.java
... | ... | @@ -39,4 +39,5 @@ |
39 | 39 |
List<HashMap<String, Object>> searchBoard(HashMap<String, Object> params) throws Exception; |
40 | 40 |
|
41 | 41 |
|
42 |
+ |
|
42 | 43 |
} |
+++ src/main/java/com/takensoft/ai_lms/lms/board/vo/BoardFileVO.java
... | ... | @@ -0,0 +1,46 @@ |
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 | +/** | |
11 | + * @author : 박세훈 | |
12 | + * since : 2024.07.31 | |
13 | + * | |
14 | + * 게시판에 등록된 파일 관련 VO | |
15 | + */ | |
16 | + | |
17 | + | |
18 | +@Getter | |
19 | +@Setter | |
20 | +@AllArgsConstructor | |
21 | +@NoArgsConstructor | |
22 | +public class BoardFileVO { | |
23 | + | |
24 | + // 파일 아이디 | |
25 | + private String fileId; | |
26 | + // 파일 관리 아이디 | |
27 | + private String fileMngId; | |
28 | + // 파일명 | |
29 | + private String fileNm; | |
30 | + // 마스크명 | |
31 | + private String fileEncptNm; | |
32 | + // 절대 경로 | |
33 | + private String fileApath; | |
34 | + // 상대 경로 | |
35 | + private String fileRpath; | |
36 | + // 확장자 | |
37 | + private String fileExtn; | |
38 | + // 파일 크기 | |
39 | + private String fileSz; | |
40 | + // 파일 타입 | |
41 | + private String fileClsf; | |
42 | + // 등록자 | |
43 | + private String reg; | |
44 | + // 등록 일자 | |
45 | + private String regDt; | |
46 | +} |
--- src/main/java/com/takensoft/ai_lms/lms/board/vo/BoardVO.java
+++ src/main/java/com/takensoft/ai_lms/lms/board/vo/BoardVO.java
... | ... | @@ -11,7 +11,7 @@ |
11 | 11 |
|
12 | 12 |
import java.time.LocalDate; |
13 | 13 |
import java.time.LocalDateTime; |
14 |
- |
|
14 |
+import java.util.List; |
|
15 | 15 |
|
16 | 16 |
|
17 | 17 |
/** |
... | ... | @@ -39,10 +39,13 @@ |
39 | 39 |
private String bbsCnt; |
40 | 40 |
// 게시판 등록 날짜 |
41 | 41 |
private String bbsTm; |
42 |
- // 파일 관리 아이디 |
|
43 |
- private String fileMngId; |
|
44 | 42 |
// 반 아이디 |
45 | 43 |
private String sclsId; |
44 |
+ // 파일 관리 아이디 |
|
45 |
+ private String fileMngId; |
|
46 |
+ // 파일 테이블 연결 |
|
47 |
+ private List<BoardFileVO> files; |
|
48 |
+ |
|
46 | 49 |
|
47 | 50 |
|
48 | 51 |
} |
--- src/main/java/com/takensoft/ai_lms/lms/board/web/BoardController.java
+++ src/main/java/com/takensoft/ai_lms/lms/board/web/BoardController.java
... | ... | @@ -135,6 +135,7 @@ |
135 | 135 |
HashMap<String, Object> result = new HashMap<>(); |
136 | 136 |
|
137 | 137 |
List<HashMap<String, Object>> boardList = boardService.searchBoard(params); |
138 |
+ result.put("totalBoard", boardService.boardCount(params)); |
|
138 | 139 |
result.put("result", boardList); |
139 | 140 |
return new ResponseEntity<>(result, HttpStatus.OK); |
140 | 141 |
} |
--- src/main/resources/mybatis/mapper/lms/board-SQL.xml
+++ src/main/resources/mybatis/mapper/lms/board-SQL.xml
... | ... | @@ -2,6 +2,8 @@ |
2 | 2 |
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
3 | 3 |
<mapper namespace="com.takensoft.ai_lms.lms.board.dao.BoardDAO"> |
4 | 4 |
|
5 |
+ |
|
6 |
+ |
|
5 | 7 |
<resultMap id="boardMap" type="BoardVO"> |
6 | 8 |
<id property="bbsId" column="bbs_id"/> |
7 | 9 |
<result property="bbsTtl" column="bbs_ttl"/> |
... | ... | @@ -10,6 +12,37 @@ |
10 | 12 |
<result property="bbsTm" column="bbs_tm"/> |
11 | 13 |
<result property="fileMngId" column="file_mng_id"/> |
12 | 14 |
<result property="sclsId" column="scls_id"/> |
15 |
+ </resultMap> |
|
16 |
+ |
|
17 |
+ <resultMap id="boardFileResultMap" type="BoardUserVO"> |
|
18 |
+ <id property="userId" column="user_id" /> |
|
19 |
+ <result property="userNm" column="user_nm" /> |
|
20 |
+ <collection property="boardClass" ofType="BoardClassVO"> |
|
21 |
+ <id property="sclsId" column="scls_id" /> |
|
22 |
+ <result property="sclsNm" column="scls_nm" /> |
|
23 |
+ <collection property="board" ofType="BoardVO" > |
|
24 |
+ <id property="bbsId" column="bbs_id"/> |
|
25 |
+ <result property="bbsTtl" column="bbs_ttl"/> |
|
26 |
+ <result property="bbsCls" column="bbs_cls"/> |
|
27 |
+ <result property="bbsCnt" column="bbs_cnt"/> |
|
28 |
+ <result property="bbsTm" column="bbs_tm"/> |
|
29 |
+ <result property="sclsId" column="scls_id"/> |
|
30 |
+ <result property="fileMngId" column="file_mng_id"/> |
|
31 |
+ <collection property="files" ofType="BoardFileVO"> |
|
32 |
+ <id property="fileId" column="file_id"/> |
|
33 |
+ <result property="fileMngId" column="file_mng_id"/> |
|
34 |
+ <result property="fileNm" column="file_nm"/> |
|
35 |
+ <result property="fileEncptNm" column="file_encpt_nm"/> |
|
36 |
+ <result property="fileApath" column="file_apath"/> |
|
37 |
+ <result property="fileRpath" column="file_rpath"/> |
|
38 |
+ <result property="fileExtn" column="file_extn"/> |
|
39 |
+ <result property="fileSz" column="file_sz"/> |
|
40 |
+ <result property="fileClsf" column="file_clsf"/> |
|
41 |
+ <result property="reg" column="reg"/> |
|
42 |
+ <result property="regDt" column="reg_dt"/> |
|
43 |
+ </collection> |
|
44 |
+ </collection> |
|
45 |
+ </collection> |
|
13 | 46 |
</resultMap> |
14 | 47 |
|
15 | 48 |
<resultMap id="boardResultMap" type="BoardUserVO"> |
... | ... | @@ -24,8 +57,8 @@ |
24 | 57 |
<result property="bbsCls" column="bbs_cls"/> |
25 | 58 |
<result property="bbsCnt" column="bbs_cnt"/> |
26 | 59 |
<result property="bbsTm" column="bbs_tm"/> |
27 |
- <result property="fileMngId" column="file_mng_id"/> |
|
28 | 60 |
<result property="sclsId" column="scls_id"/> |
61 |
+ <result property="fileMngId" column="file_mng_id"/> |
|
29 | 62 |
</collection> |
30 | 63 |
</collection> |
31 | 64 |
</resultMap> |
... | ... | @@ -92,20 +125,12 @@ |
92 | 125 |
작성일 : 2024.07.25 |
93 | 126 |
내 용 : 게시글 상세 조회 |
94 | 127 |
--> |
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 |
|
128 |
+ <select id="findByBoardId" resultMap="boardFileResultMap"> |
|
129 |
+ SELECT * |
|
106 | 130 |
FROM board b |
107 | 131 |
LEFT JOIN class c ON b.scls_id = c.scls_id |
108 | 132 |
LEFT JOIN users u ON c.user_id = u.user_id |
133 |
+ LEFT JOIN cmmn_file f ON b.file_mng_id = f.file_mng_id |
|
109 | 134 |
WHERE b.bbs_id = #{bbsId} |
110 | 135 |
ORDER BY bbs_id DESC |
111 | 136 |
</select> |
... | ... | @@ -129,7 +154,7 @@ |
129 | 154 |
FROM board b |
130 | 155 |
LEFT JOIN class c ON b.scls_id = c.scls_id |
131 | 156 |
LEFT JOIN users u ON c.user_id = u.user_id |
132 |
- WHERE 1 = 1 |
|
157 |
+ WHERE b.scls_id = #{sclsId} |
|
133 | 158 |
<if test="option != null and keyword != null"> |
134 | 159 |
<choose> |
135 | 160 |
<when test="option == 'bbsTtl'"> |
... | ... | @@ -157,7 +182,6 @@ |
157 | 182 |
SET bbs_ttl = #{bbsTtl}, |
158 | 183 |
bbs_cls = #{bbsCls}, |
159 | 184 |
bbs_cnt = #{bbsCnt}, |
160 |
- bbs_tm = now(), |
|
161 | 185 |
file_mng_id = #{fileMngId} |
162 | 186 |
WHERE |
163 | 187 |
bbs_id = #{bbsId} |
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?