File name
Commit message
Commit date
File name
Commit message
Commit date
File name
Commit message
Commit date
File name
Commit message
Commit date
File name
Commit message
Commit date
File name
Commit message
Commit date
<?xml version="1.0" encoding="UTF-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"/>
<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"/>
</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">
<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>
</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>
<!--
작성자 : 박세훈
작성일 : 2024.07.25
내 용 : 게시글 등록 관련
-->
<insert id="insertBoard" parameterType="BoardVO">
INSERT INTO board(bbs_id,
bbs_ttl,
bbs_cls,
bbs_cnt,
bbs_tm,
file_mng_id,
scls_id)
VALUES (#{bbsId},
#{bbsTtl},
#{bbsCls},
#{bbsCnt},
now(),
#{fileMngId},
#{sclsId});
</insert>
<!--
작성자 : 박세훈
작성일 : 2024.07.25
내 용 : 전체 게시물 수 조회
-->
<select id="boardCount" resultType="Integer">
SELECT COUNT(*)
FROM board
WHERE scls_id = #{sclsId}
</select>
<!--
작성자 : 박세훈
작성일 : 2024.07.25
내 용 : 게시글 전체 조회
-->
<select id="findAllBoard" resultMap="boardResultMap">
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
WHERE b.scls_id = #{sclsId}
ORDER BY b.bbs_id DESC
LIMIT #{pageSize} OFFSET #{startIndex}
</select>
<!--
작성자 : 박세훈
작성일 : 2024.07.25
내 용 : 게시글 상세 조회
-->
<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>
<!--
작성자 : 박세훈
작성일 : 2024.07.26
내 용 : 게시글 검색
-->
<select id="searchBoard" resultMap="boardResultMap">
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
WHERE b.scls_id = #{sclsId}
<if test="option != null and keyword != null">
<choose>
<when test="option == 'bbsTtl'">
AND bbs_ttl LIKE CONCAT('%', #{keyword}, '%')
</when>
<when test="option == 'bbsCls'">
AND bbs_cls LIKE CONCAT('%', #{keyword}, '%')
</when>
<otherwise>
AND bbs_cnt LIKE CONCAT('%', #{keyword}, '%')
</otherwise>
</choose>
</if>
ORDER BY bbs_id DESC
LIMIT #{pageSize} OFFSET #{startIndex}
</select>
<!--
작성자 : 박세훈
작성일 : 2024.07.25
내 용 : 게시글 수정
-->
<update id="updateBoard" parameterType="BoardVO">
UPDATE board
SET bbs_ttl = #{bbsTtl},
bbs_cls = #{bbsCls},
bbs_cnt = #{bbsCnt},
file_mng_id = #{fileMngId}
WHERE
bbs_id = #{bbsId}
</update>
<!--
작성자 : 박세훈
작성일 : 2024.07.25
내 용 : 게시글 삭제
-->
<delete id="deleteBoard" parameterType="String">
DELETE FROM board WHERE bbs_id = #{bbsId}
</delete>
<!--
작성자 : 박세훈
작성일 : 2024.08.06
내 용 : 학생 게시판 등록
-->
<insert id="insertBoardStudent" parameterType="BoardStudentVO">
INSERT INTO user_board (std_id,
bbs_id,
check_yn)
SELECT u.std_id, b.bbs_id, 'F'
FROM user_class u
JOIN board b ON u.scls_id = b.scls_id
ON CONFLICT (std_id, bbs_id)
DO NOTHING;
</insert>
<!--
작성자 : 박세훈
작성일 : 2024.08.06
내 용 : 학생 게시판 삭제
-->
<delete id="deleteBoardStudent" parameterType="String">
DELETE FROM user_board
WHERE bbs_id = #{bbsId}
</delete>
<!--
작성자 : 박세훈
작성일 : 2024.08.06
내 용 : 학생 게시판 조회
-->
<select id="boardStudentList" resultMap="boardResultMap" >
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}
ORDER BY b.bbs_id DESC
LIMIT #{pageSize} OFFSET #{startIndex}
</select>
<!--
작성자 : 박세훈
작성일 : 2024.08.06
내 용 : 학생 게시판 조회 여부 갱신
-->
<update id="updateBoardCheck" parameterType="BoardStudentVO">
UPDATE user_board
set check_yn = 'T'
WHERE bbs_id = #{bbsId}
AND std_id = #{stdId}
AND check_yn = 'F'
</update>
<!--
작성자 : 박세훈
작성일 : 2024.08.06
내 용 : 학생 게시판 조회 여부 일괄 갱신
-->
<update id="updateAllBoardCheck" parameterType="BoardStudentVO">
UPDATE user_board
set check_yn = 'T'
WHERE std_id = #{stdId}
AND check_yn = 'F'
</update>
<!--
작성자 : 박세훈
작성일 : 2024.08.06
내 용 : 학생 게시판 게시물 수 확인
-->
<select id="boardStudentCount" resultType="Integer">
SELECT COUNT(*)
FROM user_board
WHERE std_id = #{stdId}
</select>
<!--
작성자 : 박세훈
작성일 : 2024.08.06
내 용 : 학생 게시판 미조회 게시물 수 확인
-->
<select id="checkCount" resultType="Integer">
SELECT COUNT(*)
FROM user_board
WHERE check_yn = 'F' AND std_id = #{stdId}
</select>
</mapper>