<?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.PurchContractRetentionInfoMapper">
	<resultMap type="PurchContractRetentionInfo" id="baseResultMap">
		<result property="id" column="id" />
		<result property="retention" column="is_retention" />
		<result property="retentionPercent" column="retention_percent" />
		<result property="hasLimit" column="is_limit" />
		<result property="retentionLimit" column="retention_limit" />
		<result property="releaseDate" column="release_date" />
		<result property="releaseDays" column="release_days" />
		<result property="purchContractBasicInfoId" column="purch_contract_basic_info_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" />
		<association property="releaseMethodDict" column="release_method" resultMap="dictionaryResult" />
	</resultMap>

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

	<select id="findByPurchContId" parameterType="java.lang.Long" resultMap="baseResultMap">
		SELECT
			t1.id,
			t1.is_retention,
			t1.retention_percent,
			t1.is_limit,
			t1.retention_limit,
			t1.release_method,
			t1.release_date,
			t1.release_days,
			t1.purch_contract_basic_info_id,
			t1.user_create,
			t1.user_modified,
			t1.gmt_create,
			t1.gmt_modified,
			t2.id did,
			t2.code dcode,
			t2.name dname
		FROM
			purch_contract_retention_info t1
				LEFT JOIN t_dictionary t2 ON t1.release_method = t2.id
		WHERE t1.purch_contract_basic_info_id = #{purchContId}
	</select>

</mapper>
