PsHooN7979 08-07
240807 박세훈 게시판 수정
@f3a8e67abccc6061cc3855c76233dc303b7098dd
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
@@ -46,6 +46,8 @@
     // 파일 테이블 연결
     private List<BoardFileVO> files;
 
+    private List<BoardStudentVO> boardStudent;
+
 
 
 }
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
@@ -63,11 +63,28 @@
         </collection>
     </resultMap>
 
-    <resultMap id="boardStudentResultMap" type="BoardStudentVO">
-        <result property="stdId" column="std_id" />
-        <result property="bbsId" column="bbs_id" />
-        <result property="checkYn" column="check_yn" />
+    <resultMap id="boardStudentResultMap" 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="boardStudent" ofType="BoardStudentVO">
+                    <id property="stdId" column="std_id" />
+                    <result property="checkYn" column="check_yn" />
+                </collection>
+            </collection>
+        </collection>
     </resultMap>
+
 
     <!--
         작성자 : 박세훈
@@ -216,13 +233,13 @@
         작성일 : 2024.08.06
         내 용 : 학생 게시판 조회
     -->
-    <select id="boardStudentList" resultMap="boardResultMap" >
+    <select id="boardStudentList" resultMap="boardStudentResultMap" >
         SELECT  *
         FROM user_class uc
         JOIN board b ON uc.scls_id = b.scls_id
         LEFT JOIN class c ON b.scls_id = c.scls_id
         LEFT JOIN users u ON c.user_id = u.user_id
-        WHERE uc.std_id = #{stdId}
+        WHERE uc.user_id = #{userId}
         ORDER BY b.bbs_id DESC
         LIMIT #{pageSize} OFFSET #{startIndex}
     </select>
@@ -233,7 +250,7 @@
         내 용 : 학생 게시판 조회 여부 갱신
     -->
     <update id="updateBoardCheck" parameterType="BoardStudentVO">
-        UPDATE user_board
+        UPDATE user_board ub
         set check_yn = 'T'
         WHERE bbs_id = #{bbsId}
          AND std_id = #{stdId}
@@ -247,9 +264,9 @@
     -->
     <update id="updateAllBoardCheck" parameterType="BoardStudentVO">
         UPDATE user_board
-        set check_yn = 'T'
+        set check_yn = 'F'
         WHERE std_id = #{stdId}
-         AND check_yn = 'F'
+         AND check_yn = 'T'
     </update>
 
     <!--
@@ -259,8 +276,9 @@
     -->
     <select id="boardStudentCount" resultType="Integer">
         SELECT COUNT(*)
-        FROM user_board
-        WHERE std_id = #{stdId}
+        FROM user_board ub
+        JOIN user_class uc ON uc.std_id = ub.std_id
+        WHERE user_id = #{userId}
     </select>
 
 
@@ -271,8 +289,9 @@
     -->
     <select id="checkCount" resultType="Integer">
         SELECT COUNT(*)
-        FROM user_board
-        WHERE check_yn = 'F' AND std_id = #{stdId}
+        FROM user_board ub
+        JOIN user_class uc ON uc.std_id = ub.std_id
+        WHERE ub.check_yn = 'F' AND uc.user_id = #{userId}
     </select>
 
 
Add a comment
List