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>
<!--
작성자 : 박세훈
작성일 : 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 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
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 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
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>
</mapper>