<?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="com.mx.dla.dda.contrato.deal.daos.DealDAO">

	<resultMap id="resultsTransaccionDeal" type="DealDTO">
		<result property="idContrato" column="ID_CONTRATO" />
		<result property="limitesLicencia" column="LIMITES_LICENCIA" />	
	</resultMap>

	<insert id="creaContratoDeal" parameterType="DealDTO">

		INSERT INTO DDA_T_CONTRATO_DEAL  
		  (ID_CONTRATO, LIMITES_LICENCIA) 
		     values(
		        #{idContrato, javaType=Long, jdbcType=NUMERIC},
		        #{limitesLicencia, javaType=String, jdbcType=VARCHAR}	        
		      )    
	</insert>

	<update id="actualizaContratoDeal" parameterType="DealDTO">
		UPDATE DDA_T_CONTRATO_DEAL
		SET
		    LIMITES_LICENCIA =   #{limitesLicencia, javaType=String, jdbcType=VARCHAR}  
		WHERE
		    ID_CONTRATO =     #{idContrato, javaType=Long, jdbcType=NUMERIC}
	</update>

	<select id="consultaContratoDeal" resultMap="resultsTransaccionDeal"
		parameterType="map"> 
		SELECT
		   t.ID_CONTRATO, 
		   t.LIMITES_LICENCIA
		FROM DDA_T_CONTRATO_DEAL t
		WHERE 
		   t.ID_CONTRATO = #{contratoDeal.idContrato}
		ORDER BY t.ID_CONTRATO ASC
	</select>
	
	<delete id="eliminaContratoDeal" parameterType="DealDTO">
		DELETE DDA_T_CONTRATO_DEAL
		WHERE
		    ID_CONTRATO = #{idContrato, javaType=Long, jdbcType=NUMERIC}
	</delete>

</mapper>