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

	<resultMap id="ferryResult" type="ferryVO">
		<result property="serNo" column="SER_NO" />
		<result property="ferryOffice" column="FERRYOFFICE" />
		<result property="ferryName" column="FERRYNAME" />
		<result property="ferryTon" column="FERRYTON" />
		<result property="ferryRoute" column="FERRYROUTE" />
		<result property="ferryTime" column="FERRYTIME" />
		<result property="ferrySpeedMax" column="FERRYSPEEDMAX" />
		<result property="ferrySpeedNor" column="FERRYSPEEDNOR" />
		<result property="ferryGuestCnt" column="FERRYGUESTCNT" />
		<result property="ferryClueCnt" column="FERRYCLUECNT" />
		<result property="runTerm" column="RUNTERM" />
		<result property="runCnt" column="RUNCNT" />
		<result property="repreName" column="REPRENAME" />
		<result property="tel" column="TEL" />
		<result property="ferrySosok" column="FERRYSOSOK" />
		<result property="sailingDistance" column="SAILINGDISTANCE" />
		<result property="sailingDate" column="SAILINGDATE" />
		<result property="cooperateNation" column="COOPERATENATION" />
		<result property="writer" column="WRITER" />
		<result property="creDate" column="CREDATE" />
		<result property="logDate" column="LOGDATE" />
		<result property="imgFile" column="IMGFILE" />
		<result property="comments" column="COMMENTS" />
	</resultMap>
	
	<select id="select" parameterType="ferryVO" resultMap="ferryResult">
	<![CDATA[	
        SELECT
        	*
        FROM
        	TFERRY
        WHERE
        	SER_NO = #{serNo}
	]]>
	</select>

	<select id="selectList" parameterType="divMngSearchVO" resultMap="ferryResult">
	<![CDATA[
        SELECT
        	*
        FROM
        	TFERRY
        WHERE
        	FERRYROUTE = #{ferryRoute}
        ORDER BY
        	SER_NO ASC
  	]]>
	</select>

	<insert id="insert" parameterType="ferryVO">
	<![CDATA[
		INSERT INTO TFERRY
		(
	        SER_NO, FERRYOFFICE, FERRYNAME, FERRYTON, FERRYROUTE,
	        FERRYTIME, FERRYSPEEDMAX, FERRYSPEEDNOR, FERRYGUESTCNT, FERRYCLUECNT, 
	        RUNTERM, RUNCNT, REPRENAME, TEL, FERRYSOSOK, 
	        SAILINGDISTANCE, SAILINGDATE, COOPERATENATION, WRITER, CREDATE,
	        LOGDATE, IMGFILE, COMMENTS
      	)
      	VALUES
      	(
      		#{serNo}, #{ferryOffice}, #{ferryName}, #{ferryTon}, #{ferryRoute}, 
      		#{ferryTime}, #{ferrySpeedMax}, #{ferrySpeedNor}, #{ferryGuestCnt}, #{ferryClueCnt},
      		#{runTerm}, #{runCnt}, #{repreName}, #{tel}, #{ferrySosok}, 
      		#{sailingDistance}, #{sailingDate}, #{cooperateNation}, #{writer}, TO_CHAR(NOW(), 'YYYYMMDDHH24MISS'),
      		TO_CHAR(NOW(), 'YYYYMMDDHH24MISS'), #{imgFile}, #{comments}
		)
	]]>
	</insert>

	<update id="update" parameterType="ferryVO">
	<![CDATA[
		UPDATE 
			TFERRY
		SET 
			FERRYOFFICE = #{ferryOffice}, 
			FERRYNAME = #{ferryName}, 
			FERRYTON = #{ferryTon}, 
			FERRYROUTE = #{ferryRoute},
	        FERRYTIME = #{ferryTime}, 
	        FERRYSPEEDMAX = #{ferrySpeedMax}, 
	        FERRYSPEEDNOR = #{ferrySpeedNor}, 
	        FERRYGUESTCNT = #{ferryGuestCnt}, 
	        FERRYCLUECNT = #{ferryClueCnt}, 
	        RUNTERM = #{runTerm}, 
	        RUNCNT = #{runCnt}, 
	        REPRENAME = #{repreName}, 
	        TEL = #{tel}, 
	        FERRYSOSOK = #{ferrySosok}, 
	        SAILINGDISTANCE = #{sailingDistance}, 
	        SAILINGDATE = #{sailingDate}, 
	        COOPERATENATION = #{cooperateNation}, 
	        LOGDATE = TO_CHAR(NOW(), 'YYYYMMDDHH24MISS'),
	        IMGFILE = #{imgFile}, 
	        COMMENTS = #{comments}
		WHERE 
			SER_NO = #{serNo}
	]]>
	</update>

	<delete id="delete" parameterType="ferryVO">
	<![CDATA[
		DELETE 
		FROM
			TFERRY
		WHERE 
			SER_NO = #{serNo}
	]]>
	</delete>

	<select id="selectMaxSerNo" parameterType="ferryVO" resultType="int">
	<![CDATA[	
		SELECT
			MAX(SER_NO)
		FROM
			TFERRY
	]]>
	</select>
</mapper>
