<?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.brilliance.isc.mda.dao.CpdretMapper">
    <resultMap id="BaseResultMap" type="com.brilliance.isc.bo.Cpdret">
        <result column="INR" property="inr" jdbcType="CHAR"/>
        <result column="CHOWNREF" property="chownref" jdbcType="VARCHAR"/>
        <result column="OBJTYP" property="objtyp" jdbcType="VARCHAR"/>
        <result column="OBJINR" property="objinr" jdbcType="VARCHAR"/>
        <result column="BFTH" property="bfth" jdbcType="VARCHAR"/>
        <result column="REJCOD" property="rejcod" jdbcType="VARCHAR"/>
        <result column="REMARK" property="remark" jdbcType="VARCHAR"/>
        <result column="SMHINR" property="smhinr" jdbcType="VARCHAR"/>
        <result column="OBJREF" property="objref" jdbcType="VARCHAR"/>
        <result column="INIREF" property="iniref" jdbcType="VARCHAR"/>
        <result column="CREDAT" property="credat" jdbcType="DATE"/>
        <result column="RIGHTUNIT" property="rightunit" jdbcType="VARCHAR"/>
        <result column="INIUSR" property="iniusr" jdbcType="VARCHAR"/>
        <result column="INIFRM" property="inifrm" jdbcType="VARCHAR"/>
    </resultMap>

    <sql id="Base_Column_List">
        chownref,
        objtyp,
        objinr,
        bfth,
        rejcod,
        remark,
        smhinr,
        objref,
        iniref,
        credat,
        rightunit,
        iniusr,
        inifrm
    </sql>

    <select id="selectCpdretByChownref" resultMap="BaseResultMap">
        select
        <include refid="Base_Column_List"/>
        from cpdret
        where chownref = #{chownref,jdbcType=VARCHAR}
    </select>

    <select id="selectByObjtypAndObjinr" resultMap="BaseResultMap">
        select
        <include refid="Base_Column_List"/>
        from cpdret
        where objtyp = #{objtyp,jdbcType=VARCHAR} and objinr = #{objinr,jdbcType=VARCHAR}
        order by inr desc and rownum = 1
    </select>

    <select id="selectByObjinr" resultMap="BaseResultMap">
        select
        <include refid="Base_Column_List"/>
        from cpdret
        where objinr = #{objinr,jdbcType=VARCHAR}
    </select>

</mapper>