<?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.jnv.bnr.site.service.SiteManageDAO">
<select id="selectSiteManageList" parameterType="map" resultType="SiteVO">
SELECT S.SITE_ID
, S.SITE_NM
, S.SITE_URL
, S.SITE_DESC
, S.SITE_CLS_CD
, S.USE_YN
, S.RGSTR_ID
, S.RGST_DT
, S.UPDTR_ID
, S.UPDT_DT
FROM PTS_SITE_LIST S
<where>
<if test='searchKeyword != null and searchKeyword != ""'>
<choose>
<when test='searchType == "SITENAME"'>
AND S.SITE_NM LIKE '%'|| #{searchKeyword} || '%'
</when>
<when test='searchType == "SITEURL"'>
AND S.SITE_URL LIKE '%'|| #{searchKeyword} || '%'
</when>
<when test='searchType == "WRITERNAME"'>
AND S.RGSTR_ID = #{searchKeyword}
</when>
<otherwise>
AND (S.SITE_NM LIKE '%'|| #{searchKeyword} || '%'
OR S.SITE_URL LIKE '%'|| #{searchKeyword} || '%'
OR S.RGSTR_ID = #{searchKeyword})
</otherwise>
</choose>
</if>
</where>
ORDER BY S.RGST_DT DESC
</select>
<insert id="insertSiteManageItem" parameterType= "SiteVO">
INSERT INTO PTS_SITE_LIST
( SITE_ID
, SITE_NM
, SITE_URL
, SITE_DESC
, SITE_CLS_CD
, USE_YN
, RGSTR_ID
, RGST_DT
, UPDTR_ID
, UPDT_DT)
VALUES(
#{siteId}
,#{siteNm}
,#{siteUrl}
,#{siteDesc}
,#{siteClsCd}
,#{useYn}
,#{sessionUserId}
,NOW()
,#{sessionUserId}
,NOW()
)
</insert>
<update id="updateSiteManageItem" parameterType= "SiteVO">
UPDATE PTS_SITE_LIST
SET SITE_NM = #{siteNm}
, SITE_URL = #{siteUrl}
, SITE_DESC = #{siteDesc}
, SITE_CLS_CD = #{siteClsCd}
, USE_YN = #{useYn}
, RGSTR_ID = #{sessionUserId}
, RGST_DT = NOW()
, UPDTR_ID = #{sessionUserId}
, UPDT_DT = NOW()
WHERE SITE_ID = #{siteId}
</update>
<delete id="deleteSiteManageItem" parameterType="SiteVO">
DELETE FROM PTS_SITE_LIST
WHERE SITE_ID = #{siteId}
</delete>
</mapper>