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
+++ src/main/java/com/takensoft/ai_lms/lms/board/dao/BoardDAO.java
@@ -39,4 +39,5 @@
     List<HashMap<String, Object>> searchBoard(HashMap<String, Object> params) throws Exception;
 
 
+
 }
 
src/main/java/com/takensoft/ai_lms/lms/board/vo/BoardFileVO.java (added)
+++ src/main/java/com/takensoft/ai_lms/lms/board/vo/BoardFileVO.java
@@ -0,0 +1,46 @@
+package com.takensoft.ai_lms.lms.board.vo;
+
+
+import lombok.AllArgsConstructor;
+import lombok.Getter;
+import lombok.NoArgsConstructor;
+import lombok.Setter;
+
+
+/**
+ * @author  : 박세훈
+ * since   : 2024.07.31
+ *
+ * 게시판에 등록된 파일 관련 VO
+ */
+
+
+@Getter
+@Setter
+@AllArgsConstructor
+@NoArgsConstructor
+public class BoardFileVO {
+
+    // 파일 아이디
+    private String fileId;
+    // 파일 관리 아이디
+    private String fileMngId;
+    // 파일명
+    private String fileNm;
+    // 마스크명
+    private String fileEncptNm;
+    // 절대 경로
+    private String fileApath;
+    // 상대 경로
+    private String fileRpath;
+    // 확장자
+    private String fileExtn;
+    // 파일 크기
+    private String fileSz;
+    // 파일 타입
+    private String fileClsf;
+    // 등록자
+    private String reg;
+    // 등록 일자
+    private String regDt;
+}
src/main/java/com/takensoft/ai_lms/lms/board/vo/BoardVO.java
--- 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 @@
 
 import java.time.LocalDate;
 import java.time.LocalDateTime;
-
+import java.util.List;
 
 
 /**
@@ -39,10 +39,13 @@
     private String bbsCnt;
     // 게시판 등록 날짜
     private String bbsTm;
-    // 파일 관리 아이디
-    private String fileMngId;
     // 반 아이디
     private String sclsId;
+    // 파일 관리 아이디
+    private String fileMngId;
+    // 파일 테이블 연결
+    private List<BoardFileVO> files;
+
 
 
 }
src/main/java/com/takensoft/ai_lms/lms/board/web/BoardController.java
--- 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 @@
         HashMap<String, Object> result = new HashMap<>();
 
         List<HashMap<String, Object>> boardList = boardService.searchBoard(params);
+        result.put("totalBoard", boardService.boardCount(params));
         result.put("result", boardList);
         return new ResponseEntity<>(result, HttpStatus.OK);
     }
src/main/resources/mybatis/mapper/lms/board-SQL.xml
--- src/main/resources/mybatis/mapper/lms/board-SQL.xml
+++ src/main/resources/mybatis/mapper/lms/board-SQL.xml
@@ -2,6 +2,8 @@
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="com.takensoft.ai_lms.lms.board.dao.BoardDAO">
 
+
+    
     <resultMap id="boardMap" type="BoardVO">
         <id property="bbsId" column="bbs_id"/>
         <result property="bbsTtl" column="bbs_ttl"/>
@@ -10,6 +12,37 @@
         <result property="bbsTm" column="bbs_tm"/>
         <result property="fileMngId" column="file_mng_id"/>
         <result property="sclsId" column="scls_id"/>
+    </resultMap>
+
+    <resultMap id="boardFileResultMap" type="BoardUserVO">
+        <id property="userId" column="user_id" />
+        <result property="userNm" column="user_nm" />
+        <collection property="boardClass" ofType="BoardClassVO">
+            <id property="sclsId" column="scls_id" />
+            <result property="sclsNm" column="scls_nm" />
+            <collection property="board" ofType="BoardVO" >
+                <id property="bbsId" column="bbs_id"/>
+                <result property="bbsTtl" column="bbs_ttl"/>
+                <result property="bbsCls" column="bbs_cls"/>
+                <result property="bbsCnt" column="bbs_cnt"/>
+                <result property="bbsTm" column="bbs_tm"/>
+                <result property="sclsId" column="scls_id"/>
+                <result property="fileMngId" column="file_mng_id"/>
+                <collection property="files" ofType="BoardFileVO">
+                    <id property="fileId" column="file_id"/>
+                    <result property="fileMngId" column="file_mng_id"/>
+                    <result property="fileNm" column="file_nm"/>
+                    <result property="fileEncptNm" column="file_encpt_nm"/>
+                    <result property="fileApath" column="file_apath"/>
+                    <result property="fileRpath" column="file_rpath"/>
+                    <result property="fileExtn" column="file_extn"/>
+                    <result property="fileSz" column="file_sz"/>
+                    <result property="fileClsf" column="file_clsf"/>
+                    <result property="reg" column="reg"/>
+                    <result property="regDt" column="reg_dt"/>
+                </collection>
+            </collection>
+        </collection>
     </resultMap>
 
     <resultMap id="boardResultMap" type="BoardUserVO">
@@ -24,8 +57,8 @@
                 <result property="bbsCls" column="bbs_cls"/>
                 <result property="bbsCnt" column="bbs_cnt"/>
                 <result property="bbsTm" column="bbs_tm"/>
-                <result property="fileMngId" column="file_mng_id"/>
                 <result property="sclsId" column="scls_id"/>
+                <result property="fileMngId" column="file_mng_id"/>
             </collection>
         </collection>
     </resultMap>
@@ -92,20 +125,12 @@
         작성일 : 2024.07.25
         내 용 : 게시글 상세 조회
     -->
-    <select id="findByBoardId" resultMap="boardResultMap">
-        SELECT  b.bbs_id,
-                b.bbs_ttl,
-                b.bbs_cls,
-                b.bbs_cnt,
-                b.bbs_tm,
-                b.file_mng_id,
-                c.scls_id,
-                c.scls_nm,
-                u.user_id,
-                u.user_nm
+    <select id="findByBoardId" resultMap="boardFileResultMap">
+        SELECT  *
         FROM board b
         LEFT JOIN class c ON b.scls_id = c.scls_id
         LEFT JOIN users u ON c.user_id = u.user_id
+        LEFT JOIN cmmn_file f ON b.file_mng_id = f.file_mng_id
         WHERE b.bbs_id = #{bbsId}
         ORDER BY bbs_id DESC
     </select>
@@ -129,7 +154,7 @@
         FROM board b
         LEFT JOIN class c ON b.scls_id = c.scls_id
         LEFT JOIN users u ON c.user_id = u.user_id
-        WHERE 1 = 1
+        WHERE b.scls_id = #{sclsId}
         <if test="option != null and keyword != null">
             <choose>
                 <when test="option == 'bbsTtl'">
@@ -157,7 +182,6 @@
         SET bbs_ttl = #{bbsTtl},
             bbs_cls = #{bbsCls},
             bbs_cnt = #{bbsCnt},
-            bbs_tm = now(),
             file_mng_id = #{fileMngId}
         WHERE
             bbs_id = #{bbsId}
Add a comment
List