<?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.jeeplus.test.materialManagement.collect.mapper.CollectBasicsReturnHiMapper">

    <sql id="HI_Column_List">
        hi.id,
        hi.create_by,
        hi.create_date,
        hi.update_by,
        hi.update_date,
        hi.del_flag,
        hi.remarks,
        hi.collect_id,
        hi.json_data,
        hi.return_user,
        hi.return_goods
    </sql>

    <select id="findHiById" resultType="com.jeeplus.test.materialManagement.collect.domain.CollectBasicsReturnHi">
        select
        <include refid="HI_Column_List"></include>,
        su.name as returnUserName
        from material_management_collect_basics_return_hi hi
        left join sys_user su on su.id = hi.return_user
        where hi.del_flag = '0' and hi.collect_id = #{collectId}
        order by hi.create_date desc
    </select>

    <select id="findHiByHiId" resultType="com.jeeplus.test.materialManagement.collect.domain.CollectBasicsReturnHi">
        select
        <include refid="HI_Column_List"></include>
        from material_management_collect_basics_return_hi hi
        where hi.del_flag = '0' and hi.id = #{id}
    </select>

    <select id="findLastHiByid" resultType="com.jeeplus.test.materialManagement.collect.domain.CollectBasicsReturnHi">
        select
        <include refid="HI_Column_List"></include>
        from material_management_collect_basics_return_hi hi
        where hi.del_flag = '0' and hi.collect_id = #{collectId}
        order by hi.create_date desc
        limit 1
    </select>
</mapper>
