<?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.cont.mapper.ContItemMapper">

	<select id="select" parameterType="contItemSearch" resultType="contItem">
		select	
			CONT_ITEM_ID, CONT_ITEM_NM, CONT_ID, CONT, LANG_ID, REG_ID, REG_DT
		from		
			JCMS_CONT_ITEM
		where
			1=1
		<if test="!empty(contId)" > and CONT_ID = #{contId} </if>
		<if test="!empty(langId)" > and LANG_ID = #{langId} </if>
	</select>
	
	<select id="selectList" parameterType="contItemSearch" resultType="contItem">
		SELECT *
		FROM (
			SELECT ROWNUM RNUM , LIST.*
			FROM (
				SELECT CONT_ITEM_ID, CONT_ITEM_NM, CONT_ID, CONT, LANG_ID, REG_ID, REG_DT
				FROM JCMS_CONT_ITEM
				WHERE 1 = 1
					<if test="!empty(contId)" > AND CONT_ID = #{contId} </if>
					<if test="!empty(langId)" > AND LANG_ID = #{langId} </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>
	
	<select id="count" parameterType="contItemSearch" resultType="java.lang.Integer">
		select 
			COUNT(CONT_ITEM_ID)
		from
			JCMS_CONT_ITEM
		where
	   		1 = 1
		<if test="!empty(contId)" > and CONT_ID = #{contId} </if>
		<if test="!empty(langId)" > and LANG_ID = #{langId} </if>
	</select>
	
	<insert id="insert" parameterType="contItem">
		insert into JCMS_CONT_ITEM (
			CONT_ITEM_ID,
			CONT_ITEM_NM,
			CONT_ID,
			CONT,
			LANG_ID,
			REG_ID,
			REG_DT
		) values (
			CONT_ITEM_ID_SEQ.NEXTVAL
			, #{contItemNm}
			, #{contId}
			, #{cont ,jdbcType=CLOB}
			, #{langId}
			, #{regId}
			, SYSDATE
		)
	</insert>
	
	<update id="update" parameterType="contItem">
		update JCMS_CONT_ITEM set
			CONT_ITEM_NM = #{contItemNm}
			,CONT = #{cont ,jdbcType=CLOB}
			,UPD_ID = #{updId}
			,UPD_DT = SYSDATE
		where
			CONT_ITEM_ID = #{contItemId}
	</update>
	
</mapper>
