
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">
<!--
작성자 : 하석형
작성일 : 2024.06.12
내 용 : 통합 검색 관리 관련
-->
<mapper namespace="com.takensoft.portal.search.dao.SearchDAO">
<!--
작 성 자 : 하석형
작 성 일 : 2024.06.12
내 용 : 검색 조건 SQL
-->
<sql id="searchSQL">
<!-- 검색 조건 및 검색어 -->
<choose>
<when test="searchType != null and searchType != ''">
<if test="searchType == 'title'">
AND bbs_nm LIKE '%' || #{searchText} || '%'
</if>
<if test="searchType == 'content'">
AND bbs_cn LIKE '%' || #{searchText} || '%'
</if>
</when>
<otherwise>
AND (
bbs_nm LIKE '%' || #{searchText} || '%'
OR
bbs_cn LIKE '%' || #{searchText} || '%'
)
</otherwise>
</choose>
<!-- 검색 기간 -->
<if test="startDt != null and startDt != ''">
<![CDATA[
AND reg_dt::DATE >= #{startDt}::DATE
]]>
</if>
<if test="endDt != null and endDt != ''">
<![CDATA[
AND reg_dt::DATE <= #{endDt}::DATE
]]>
</if>
</sql>
<!--
작 성 자 : 하석형
작 성 일 : 2024.06.12
내 용 : 검색 조건 Order By SQL
-->
<sql id="searchOrderBySQL">
<!-- 검색 정렬 -->
<choose>
<when test="sort != null and sort != ''">
<!-- (미구현)정확도 조건 -->
<if test="sort == 'A'">
</if>
</when>
<otherwise>
reg_dt DESC
</otherwise>
</choose>
</sql>
<!--
작 성 자 : 하석형
작 성 일 : 2024.06.12
내 용 : 게시판 검색 목록 조회 개수
-->
<select id="findAllCountByBbs" parameterType="SearchVO" resultType="int">
SELECT
COUNT(*)
FROM
bbs_cn bc
WHERE
bc.bbs_mng_id = #{bbsMngId}
AND
bc.use_yn = 'Y'
<include refid="searchSQL" />
<if test="roles != null and roles.size() > 0">
<choose>
<!-- ROLE_ADMIN일 때는 모든 데이터를 보여줍니다. -->
<when test="roles.contains('ROLE_ADMIN')">
</when>
<!-- ROLE_USER일 때는 작성자가 일치하는 데이터는 보여줍니다. -->
<when test="roles.contains('ROLE_USER')">
AND (bc.prvt_pst_yn = 'N' OR bc.rgtr = #{mbrId})
</when>
<!-- 그 외는 비밀글을 조회할 수 없습니다. -->
<otherwise>
AND bc.prvt_pst_yn = 'N'
</otherwise>
</choose>
</if>
</select>
<!--
작 성 자 : 하석형
작 성 일 : 2024.06.12
내 용 : 게시판 검색 목록 조회
-->
<select id="findAllByBbs" parameterType="SearchVO" resultType="SearchContentVO">
SELECT
bbs_mng_id AS menuTypeCtgry
, bbs_id AS pageId
, bbs_nm AS title
, bbs_cn AS content
, reg_dt::DATE
FROM
bbs_cn bc
WHERE
bc.bbs_mng_id = #{bbsMngId}
AND
bc.use_yn = 'Y'
<include refid="searchSQL" />
<if test="roles != null and roles.size() > 0">
<choose>
<!-- ROLE_ADMIN일 때는 모든 데이터를 보여줍니다. -->
<when test="roles.contains('ROLE_ADMIN')">
</when>
<!-- ROLE_USER일 때는 작성자가 일치하는 데이터는 보여줍니다. -->
<when test="roles.contains('ROLE_USER')">
AND (bc.prvt_pst_yn = 'N' OR bc.rgtr = #{mbrId})
</when>
<!-- 그 외는 비밀글을 조회할 수 없습니다. -->
<otherwise>
AND bc.prvt_pst_yn = 'N'
</otherwise>
</choose>
</if>
ORDER BY
<include refid="searchOrderBySQL" />
LIMIT #{typePreCnt}
<!--<if test="bbsMngIdList != null and bbsMngIdList.size() > 0">
AND bc.bbs_mng_id IN
<foreach item="bbsMngId" collection="bbsMngIdList" open="(" separator="," close=")">
#{bbsMngId}
</foreach>
</if>-->
</select>
</mapper>