<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "classpath:resources/mybatis-3-config.dtd">

<mapper
	namespace="com.mx.dla.dda.contrato.condicionesTransaccion.daos.CondicionesTransaccionDAO">
	<!-- DEFINICION DE MAPPERS -->

	<!-- MAPPER DE AGREGAR CONTRATO PTRANS -->
	<resultMap id="contratoPtrans" type="ContratoPtransDTO">
		<id property="idContratoPtrans" column="ID_CONTRATO_PTRANS" />
		<result property="idContrato" column="ID_CONTRATO" />
		<result property="tipoTrans" column="TIPO_TRANS" />
		<result property="tipoTitulo" column="TIPO_TITULO" />
		<result property="tipoAnnio" column="TIPO_ANNIO" />
		<result property="tipoMinimo" column="TIPO_MINIMO" />
	</resultMap>

	<!-- MAPPER DE AGREGAR CONTRATO PT ANNIO -->
	<resultMap id="contratoPtAnnio" type="ContratoPtAnnioDTO">
		<id property="idContratoPtrans" column="ID_CONTRATO_PTRANS" />
		<result property="annio" column="ANNIO" />
		<result property="titulos" column="TITULOS" />
		<result property="precio" column="PRECIO" />
		<result property="minimo" column="MINIMO" />
	</resultMap>


	<!-- MAPPER DE AGREGAR CONTRATO PT CMG -->
	<resultMap id="contratoPtCmg" type="ContratoPtCmgDTO">
		<id property="idPtcmg" column="ID_PTCMG" />
		<result property="idContratoPtrans" column="ID_CONTRATO_PTRANS" />
		<result property="idCategoria" column="ID_CATEGORIA" />
		<result property="annio" column="ANNIO" />
		<result property="minimo" column="MINIMO" />
	</resultMap>


	
	<resultMap id="contratoCategorias" type="ContratoCategoriasDTO">
		<id property="idContratoPtrans" column="ID_CONTRATO_PTRANS" />
		<result property="idCategoria" column="ID_CATEGORIA" />
		<result property="rsDLA" column="RS_DLA" />
		<result property="rsEstudio" column="RS_ESTUDIO" />
		<result property="tipoTitlo" column="TIPO_TITULO" />
	</resultMap>  

	<!-- MAPPER DE AGREGAR CONTRATO PTRS RD -->
	<resultMap id="contratoPtrsCat" type="ContratoPtrsRdDTO">
		<id property="idContratoPtrans" column="ID_CONTRATO_PTRANS" />
		<result property="idRelease" column="ID_RELEASE" />
		<result property="rsDLA" column="RS_DLA" />
		<result property="rsEstudio" column="RS_ESTUDIO" />
	</resultMap>
	
	<!-- MAPPER DE AGREGAR CONTRATO PTRS PRECIO -->
	<resultMap id="contratoPtrsPrecio" type="ContratoPtrsPrecioDTO">
		<id property="idContratoPtrans" column="ID_CONTRATO_PTRANS" />
		<result property="idCategoria" column="ID_CATEGORIA" />
		<result property="precio" column="PRECIO" />
	</resultMap>
	
	<!-- DEFINICION DE QUERYS -->


	<!-- selects para id de tablas -->


	<select id="getIdContratoPtrans" resultType="int">
		select DDA_SQT_CONTRATO_PTRANS.nextVal from DUAL
	</select>

	<select id="getIdAnnio" resultType="int">
		select DDA_SQT_CONTRATO_PT_ANNIO.nextVal from DUAL
	</select>

	<select id="getIdContratoCMG" resultType="int">
		select DDA_SQT_CONTRATO_PT_CMG.nextVal from DUAL
	</select>
	

	
	<insert id="agregarContratoPtrans" parameterType="ContratoPtransDTO">
		INSERT INTO DDA_T_CONTRATO_PTRANS
		(ID_CONTRATO_PTRANS,ID_CONTRATO,TIPO_TRANS,TIPO_TITULO,TIPO_ANNIO,TIPO_MINIMO)

		values
		(#{idContratoPtrans,javaType=int, jdbcType=NUMERIC},
		#{idContrato,javaType=int, jdbcType=NUMERIC},
		#{tipoTrans,javaType=String, jdbcType=VARCHAR},
		#{tipoTitulo,javaType=String, jdbcType=VARCHAR},
		#{tipoAnnio ,javaType=String,jdbcType=VARCHAR},
		#{tipoMinimo ,javaType=String,jdbcType=VARCHAR})	
		
				
	</insert>
	
	<insert id="agregarContratoPtAnnio" parameterType="ContratoPtAnnioDTO">
		INSERT INTO DDA_T_CONTRATO_PT_ANNIO
		(ID_CONTRATO_PTRANS,ANNIO,TITULOS,PRECIO,MINIMO)

		values
		(#{idContratoPtrans,javaType=int, jdbcType=NUMERIC},
		#{annio,javaType=String, jdbcType=VARCHAR},
		#{titulos,javaType=String, jdbcType=VARCHAR},
		#{precio ,javaType=String,jdbcType=VARCHAR},
		#{minimo ,javaType=String,jdbcType=VARCHAR})	
			
	</insert>
	
	
	<insert id="agregarContratoPtCmg" parameterType="ContratoPtCmgDTO">
		INSERT INTO DDA_T_CONTRATO_PT_CMG
		(ID_PTCMG,ID_CONTRATO_PTRANS,ID_CATEGORIA,ANNIO,MINIMO)

		values
		(#{idPtcmg,javaType=int, jdbcType=NUMERIC},
		#{idContratoPtrans,javaType=int, jdbcType=NUMERIC},
		#{idCategoria,javaType=int, jdbcType=NUMERIC},
		#{annio,javaType=String, jdbcType=VARCHAR},
		#{minimo ,javaType=String,jdbcType=VARCHAR})	
			
	</insert>

	<insert id="agregarContratoCategorias" parameterType="ContratoCategoriasDTO">
		INSERT INTO
		DDA_T_CONTRATO_PTRS_CAT
		(ID_CONTRATO_PTRANS,ID_CATEGORIA,RS_DLA,RS_ESTUDIO,TIPO_TITULO)

		values
		(#{idContratoPtrans,javaType=int, jdbcType=NUMERIC},
		#{idCategoria,javaType=int, jdbcType=NUMERIC},
		#{rsDLA,javaType=String, jdbcType=VARCHAR},
		#{rsEstudio
		,javaType=String,jdbcType=VARCHAR},
		#{tipoTitlo
		,javaType=String,jdbcType=VARCHAR})

	</insert>
	 
		<insert id="agregarContratoPtrsRd" parameterType="ContratoPtrsRdDTO">
			INSERT INTO DDA_T_CONTRATO_PTRS_RD
			(ID_CONTRATO_PTRANS,ID_RELEASE,RS_DLA,RS_ESTUDIO)
	
			values
			(#{idContratoPtrans,javaType=int, jdbcType=NUMERIC},
			#{idRelease,javaType=int, jdbcType=NUMERIC},
			#{rsDLA,javaType=String, jdbcType=VARCHAR},
			#{rsEstudio ,javaType=String,jdbcType=VARCHAR})	
				
	</insert>
	
	<insert id="agregarContratoPtrsPrecio" parameterType="ContratoPtrsPrecioDTO">
			INSERT INTO DDA_T_CONTRATO_PTRS_PRECIO
			(ID_CONTRATO_PTRANS,ID_CATEGORIA,PRECIO)	
			values
			(#{idContratoPtrans},
			#{idCategoria},
			#{precio})	
				
	</insert>
	
	
</mapper>