<?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="kr.co.jinwoosi.clfd.conts.menu.mapper.MenuPopupMapper">
	
	<select id="count" parameterType="cmsMenuPopupSearch" resultType="java.lang.Integer">
		select 
			COUNT(POPUP_ID)
		from
			JCMS_MENU_POPUP
		where
	   		1 = 1
		<if test="!empty(menuId)" > and MENU_ID = #{menuId} </if>
	</select>
	
	<select id="selectList" parameterType="cmsMenuPopupSearch" resultType="cmsMenuPopup">
		SELECT *
		FROM (
			SELECT ROWNUM RNUM , LIST.*
			FROM (
				SELECT MENU_ID, POPUP_ID
				FROM JCMS_MENU_POPUP
				WHERE 1 = 1
					<if test="!empty(menuId)" > AND MENU_ID = #{menuId} </if>
				<if test="!empty(sort) and !empty(sortOrd)">
	    		ORDER BY ${sort} ${sortOrd}
			    </if>
		    ) LIST
		)
	    <if test="pagingYn == true" >
			<![CDATA[
				WHERE RNUM  > #{start} AND RNUM <= #{start} + #{length}
			]]>
		</if>
	</select>
	
	<insert id="insert" parameterType="cmsMenuPopup">
		insert into JCMS_MENU_POPUP (
			POPUP_ID,
			MENU_ID
		) values (
			#{popupId}
			, #{menuId}
		)
	</insert>
	
	<delete id="delete" parameterType="cmsMenuPopup">
		delete from JCMS_MENU_POPUP 
		where 
			MENU_ID = #{menuId}
	</delete>
</mapper>
