<?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="SusaFile">

	<resultMap id="susaFileResult" type="susaFileVO">
		<result property="seq" column="SF_SEQ" />
		<result property="orders" column="SF_ORDER" />
		<result property="orgName" column="SF_ORG_NAME" />
		<result property="saveName" column="SF_SAVE_NAME" />
		<result property="parentSeq" column="SF_SS_SEQ" />
	</resultMap>
	
	<select id="SusaFile.select" parameterType="susaVO" resultMap="susaFileResult">
	<![CDATA[
		SELECT
			*
		FROM 
			H3_SUSA_FILE
		WHERE
			SF_SEQ = #{seq}
	]]>
	</select>
	
	<select id="SusaFile.selectList" parameterType="susaVO" resultMap="susaFileResult">
	<![CDATA[
		SELECT
			*
		FROM 
			H3_SUSA_FILE
	]]>	
	<if test="parentSeq != null and parentSeq > 0">
		WHERE
			SF_SS_SEQ = #{parentSeq}
	</if>
	<![CDATA[
		ORDER BY
			SF_ORDER
	]]>
	</select>
	
	<insert id="SusaFile.insert" parameterType="susaVO" useGeneratedKeys="true" keyColumn="SF_SEQ">
	<![CDATA[
		INSERT INTO 
			H3_SUSA_FILE (
				SF_ORDER,
				SF_ORG_NAME,
	  			SF_SAVE_NAME,
	  			SF_SS_SEQ
		) VALUES (
		  	#{orders},
		  	#{orgName},
		  	#{saveName},
		  	#{parentSeq}
		) 
	]]>
	</insert>
	
	<delete id="SusaFile.delete" parameterType="susaVO">
	<![CDATA[
		DELETE
		FROM 
			H3_SUSA_FILE
		WHERE
			SF_SEQ = #{seq}
	]]>
	</delete>
</mapper>
