<?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.framework.security.mapper.ScurRscMapper">

	<select id="selectList" parameterType="scurRsc" resultType="scurRsc">
		SELECT *
		FROM (
			SELECT ROWNUM RNUM , LIST.*
			FROM (
				SELECT RSC_ID, RSC_NM, RSC_TP, RSC_PATN, RSC_DESC, REG_ID, REG_DT, UPD_ID, UPD_DT
				FROM JCMS_SCUR_RSC
				WHERE 1=1
					<if test="!empty(rscId)" > AND RSC_ID = #{rscId} </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="scurRsc" resultType="java.lang.Integer">
		select
			COUNT(RSC_ID)
		from
			JCMS_SCUR_RSC
		where
			1=1
		<if test="!empty(rscId)" >
			and RSC_ID = #{rscId}
		</if>
	</select>
	
	<insert id="insert" parameterType="scurRsc">
		insert into JCMS_SCUR_RSC (
			RSC_ID,
			RSC_NM,  
			RSC_TP,
			RSC_PATN,  
			RSC_DESC,  
			REG_ID,  
			REG_DT
		) values (
			#{rscId},
			#{rscNm},
			#{rscTp},
			#{rscPatn},
			#{rscDesc},
			#{regId},	
			SYSDATE
		)
	</insert>
	
	<update id="update" parameterType="scurRsc">
		update JCMS_SCUR_RSC set
			RSC_ID = #{rscId},
			RSC_NM = #{rscNm}, 
			RSC_TP = #{rscTp},
			RSC_PATN = #{rscPatn},  
			RSC_DESC = #{rscDesc},  
			UPD_ID = #{updId},
			UPD_DT = SYSDATE
		where
			RSC_ID = #{rscId}
	</update>
	
	<delete id="delete" parameterType="scurRsc">
		delete from JCMS_SCUR_RSC
		where 
			RSC_ID = #{rscId}
	</delete>
</mapper>