<?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.sunxung.factoring.mapper.purchcontractmanagement.PurchContractElectronicInfoMapper">
	<resultMap type="PurchContractElectronicInfo" id="baseResultMap">
		<result property="id" column="id" />
		<result property="certifyLink" column="certify_link" />
		<result property="certifyStatus" column="certify_status" />
		<result property="signStatus" column="sign_status" />
		<result property="contractLink" column="contract_link" />
		<result property="purchContractBasicInfoId" column="purch_contract_basic_info_id" />
		<result property="transactionId" column="transaction_id"/>
		<result property="fddCustomerId" column="fdd_customer_id"/>
		<result property="userCreate" column="user_create" />
		<result property="userModified" column="user_modified" />
		<result property="gmtCreate" column="gmt_create" />
		<result property="gmtModified" column="gmt_modified" />
		<result property="shortContractLink" column="short_contract_link"/>
		<result property="contractName" column="contract_name"/>
		<association property="certifyStatusDict" column="certify_status" resultMap="dictionaryResult" />
		<association property="signStatusDict" column="sign_status" resultMap="signDictionaryResult" />
	</resultMap>

	<resultMap id="dictionaryResult" type="Dictionary">
		<result property="id" column="did" />
		<result property="name" column="dname" />
		<result property="code" column="dcode" />
	</resultMap>

	<resultMap id="signDictionaryResult" type="Dictionary">
		<result property="id" column="signdid" />
		<result property="name" column="signdname" />
		<result property="code" column="signdcode" />
	</resultMap>

	<select id="findByPurchContBasicId" parameterType="java.lang.Long" resultMap="baseResultMap">
		SELECT
			t1.id,
			t1.certify_link,
		    t1.certify_status,
		    t1.sign_status,
			t1.contract_link,
			t1.purch_contract_basic_info_id,
			t1.transaction_id,
			t1.fdd_customer_id,
			t1.user_create,
			t1.user_modified,
			t1.gmt_create,
			t1.gmt_modified,
		    t1.short_contract_link,
			t2.id did,
			t2.code dcode,
			t2.name dname,
			t3.id signdid,
			t3.code signdcode,
			t3.name signdname,
		    t1.contract_name
		FROM
			purch_contract_electronic_info t1
				LEFT JOIN t_dictionary t2 ON t1.certify_status = t2.id
				LEFT JOIN t_dictionary t3 ON t1.sign_status = t3.id
		WHERE t1.purch_contract_basic_info_id = #{id}
	</select>

</mapper>
