
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
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.05.13
내 용 : 팝업 관련
-->
<mapper namespace="com.takensoft.cms.popup.dao.PopupDAO">
<!-- 팝업 resultMap -->
<resultMap id="popupMap" type="PopupVO">
<result property="popupId" column="popup_id" />
<result property="popupTtl" column="popup_ttl" />
<result property="bgngDt" column="bgng_dt" />
<result property="endDt" column="end_dt" />
<result property="wdthLen" column="wdth_len" />
<result property="vrtcLen" column="vrtc_len" />
<result property="popupType" column="popup_type" />
<result property="popupUseYn" column="popup_use_yn" />
<result property="vdoUrl" column="vdo_url" />
<result property="linkUrl" column="link_url" />
<result property="fileMngId" column="file_mng_id" />
<result property="sn" column="sn" />
<result property="pageType" column="page_type" />
<result property="useYn" column="use_yn" />
<result property="rgtr" column="rgtr" />
<result property="regDt" column="reg_dt" />
<result property="mdfr" column="mdfr" />
<result property="mdfcnDt" column="mdfcn_dt" />
<result property="mbrNm" column="mbr_nm" />
</resultMap>
<!--
작 성 자 : 박정하
작 성 일 : 2024.05.13
내 용 : 팝업 등록
-->
<insert id="insertPopup" parameterType="PopupVO" useGeneratedKeys="true" keyProperty="popupId">
INSERT INTO popup_mng (
popup_id
, popup_ttl
, bgng_dt
, end_dt
, wdth_len
, vrtc_len
, popup_type
, popup_use_yn
, vdo_url
, link_url
, file_mng_id
, sn
, page_type
, use_yn
, rgtr
, reg_dt
) VALUES (
#{popupId}
, #{popupTtl}
, #{bgngDt}::timestamp
, #{endDt}::timestamp
, #{wdthLen}
, #{vrtcLen}
, #{popupType}
, #{popupUseYn}
, #{vdoUrl}
, #{linkUrl}
, #{fileMngId}
, #{sn}
, #{pageType}
, 'Y'
, #{rgtr}
, NOW()
)
</insert>
<!-- SELECT SQL -->
<sql id="selectItem">
SELECT pm.popup_id
, pm.popup_ttl
, TO_CHAR(pm.bgng_dt, 'YYYY-MM-DD HH24:MI') AS bgng_dt
, TO_CHAR(pm.end_dt, 'YYYY-MM-DD HH24:MI') AS end_dt
, pm.wdth_len
, pm.vrtc_len
, pm.popup_type
, pm.popup_use_yn
, pm.vdo_url
, pm.link_url
, pm.file_mng_id
, pm.sn
, pm.page_type
, pm.use_yn
, pm.rgtr
, TO_CHAR(pm.reg_dt, 'YYYY-MM-DD HH24:MI') AS reg_dt
, pm.mdfr
, TO_CHAR(pm.mdfcn_dt, 'YYYY-MM-DD HH24:MI') AS mdfcn_dt
, mi.mbr_nm
FROM popup_mng AS pm
LEFT JOIN mbr_info AS mi
ON pm.rgtr = mi.mbr_id
</sql>
<sql id="selectRequirement">
<if test="searchText != null and searchText != ''">
<choose>
<when test="searchType != null and searchType != ''">
<if test="searchType == 'popup_ttl'">
AND pm.popup_ttl LIKE '%' || #{searchText} || '%'
</if>
<if test="searchType == 'mbr_nm'">
AND mi.mbr_nm LIKE '%' || #{searchText} || '%'
</if>
</when>
<otherwise>
AND (
pm.popup_ttl LIKE '%' || #{searchText} || '%'
OR
mi.mbr_nm LIKE '%' || #{searchText} || '%'
)
</otherwise>
</choose>
</if>
</sql>
<!-- // SELECT SQL -->
<!--
작 성 자 : 박정하
작 성 일 : 2024.05.13
내 용 : 팝업 목록 개수
-->
<select id="selectPopupListCnt" parameterType="Pagination" resultType="Integer">
SELECT COUNT(popup_id)
FROM popup_mng AS pm
LEFT JOIN mbr_info AS mi
ON pm.rgtr = mi.mbr_id
WHERE pm.use_yn = 'Y'
<include refid="selectRequirement" />
</select>
<!--
작 성 자 : 박정하
작 성 일 : 2024.05.13
내 용 : 팝업 목록 조회
-->
<select id="selectPopupList" parameterType="Pagination" resultMap="popupMap">
<include refid="selectItem" />
WHERE pm.use_yn = 'Y'
<include refid="selectRequirement" />
ORDER BY reg_dt DESC
LIMIT #{recordSize} OFFSET #{limitStart}
</select>
<!--
작 성 자 : 박정하
작 성 일 : 2024.05.13
내 용 : 팝업 상세 조회
-->
<select id="selectPopupDetail" parameterType="PopupVO" resultMap="popupMap">
<include refid="selectItem" />
WHERE pm.popup_id = #{popupId}
AND pm.use_yn = 'Y'
</select>
<!--
작 성 자 : 박정하
작 성 일 : 2024.05.13
내 용 : 팝업 수정
-->
<update id="updatePopup" parameterType="PopupVO">
UPDATE popup_mng
SET popup_ttl = #{popupTtl}
, bgng_dt = #{bgngDt}::timestamp
, end_dt = #{endDt}::timestamp
, wdth_len = #{wdthLen}
, vrtc_len = #{vrtcLen}
, popup_type = #{popupType}
, popup_use_yn = #{popupUseYn}
, vdo_url = #{vdoUrl}
, link_url = #{linkUrl}
, file_mng_id = #{fileMngId}
, sn = #{sn}
, page_type = #{pageType}
, use_yn = #{useYn}
, mdfr = #{mdfr}
, mdfcn_dt = NOW()
WHERE popup_id = #{popupId}
</update>
<!--
작 성 자 : 박정하
작 성 일 : 2024.05.22
내 용 : 팝업 목록 조회 (팝업창 띄우는 용도)
-->
<select id="selectPopupListByPage" parameterType="String" resultMap="popupMap">
<include refid="selectItem" />
WHERE pm.use_yn = 'Y'
AND pm.popup_use_yn = 'Y'
AND pm.page_type = #{pageType}
AND now() >= pm.bgng_dt::timestamp
AND pm.end_dt::timestamp >= now()
ORDER BY reg_dt DESC
</select>
<!--
작 성 자 : 박정하
작 성 일 : 2024.05.23
내 용 : 매일 자정에 종료일이 지난 팝업 사용여부 변경
-->
<update id="cleanExpiredPopups">
UPDATE popup_mng
SET popup_use_yn = 'N'
, mdfr = null
, mdfcn_dt = NOW()
WHERE end_dt <= NOW()
</update>
<!--
작 성 자 : 박정하
작 성 일 : 2024.05.28
내 용 : 팝업 최신 목록 조회 (최신글 5건 출력)
-->
<select id="selectPopupListByNew" resultMap="popupMap">
<include refid="selectItem" />
WHERE pm.use_yn = 'Y'
ORDER BY pm.reg_dt DESC
LIMIT 5
</select>
</mapper>