<?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.bonus.material.warehouse.mapper.WhTeamReceiveDetailMapper">
    <resultMap type="com.bonus.material.warehouse.domain.WhTeamReceiveDetail" id="WhTeamReceiveDetailResult">
        <result property="id"    column="id"    />
        <result property="typeId"    column="type_id"    />
        <result property="outNum"    column="out_num"    />
        <result property="pickName"    column="pick_name"    />
        <result property="outName"    column="out_name"    />
        <result property="outTime"    column="out_time"    />
        <result property="parentId"    column="parent_id"    />
        <result property="type"    column="type"    />
        <result property="createTime"    column="create_time"    />
        <result property="updateTime"    column="update_time"    />
    </resultMap>

    <sql id="selectWhTeamReceiveDetailVo">
        select id, type_id, out_num, pick_name, out_name, out_time, parent_id, type, create_time, update_time from wh_team_receive_detail
    </sql>

    <select id="selectWhTeamReceiveDetailList" parameterType="com.bonus.material.warehouse.domain.WhTeamReceiveDetail" resultMap="WhTeamReceiveDetailResult">
        <include refid="selectWhTeamReceiveDetailVo"/>
        <where>  
            <if test="typeId != null "> and type_id = #{typeId}</if>
            <if test="outNum != null "> and out_num = #{outNum}</if>
            <if test="pickName != null  and pickName != ''"> and pick_name like concat('%', #{pickName}, '%')</if>
            <if test="outName != null  and outName != ''"> and out_name like concat('%', #{outName}, '%')</if>
            <if test="outTime != null "> and out_time = #{outTime}</if>
            <if test="parentId != null "> and parent_id = #{parentId}</if>
            <if test="type != null  and type != ''"> and type = #{type}</if>
        </where>
    </select>
    
    <select id="selectWhTeamReceiveDetailById" parameterType="Long" resultMap="WhTeamReceiveDetailResult">
        <include refid="selectWhTeamReceiveDetailVo"/>
        where id = #{id}
    </select>
        
    <insert id="insertWhTeamReceiveDetail" parameterType="com.bonus.material.warehouse.domain.WhTeamReceiveDetail" useGeneratedKeys="true" keyProperty="id">
        insert into wh_team_receive_detail
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="typeId != null">type_id,</if>
            <if test="outNum != null">out_num,</if>
            <if test="pickName != null">pick_name,</if>
            <if test="outName != null">out_name,</if>
            <if test="outTime != null">out_time,</if>
            <if test="parentId != null">parent_id,</if>
            <if test="type != null">type,</if>
            <if test="createTime != null">create_time,</if>
            <if test="updateTime != null">update_time,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="typeId != null">#{typeId},</if>
            <if test="outNum != null">#{outNum},</if>
            <if test="pickName != null">#{pickName},</if>
            <if test="outName != null">#{outName},</if>
            <if test="outTime != null">#{outTime},</if>
            <if test="parentId != null">#{parentId},</if>
            <if test="type != null">#{type},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="updateTime != null">#{updateTime},</if>
         </trim>
    </insert>

    <update id="updateWhTeamReceiveDetail" parameterType="com.bonus.material.warehouse.domain.WhTeamReceiveDetail">
        update wh_team_receive_detail
        <trim prefix="SET" suffixOverrides=",">
            <if test="typeId != null">type_id = #{typeId},</if>
            <if test="outNum != null">out_num = #{outNum},</if>
            <if test="pickName != null">pick_name = #{pickName},</if>
            <if test="outName != null">out_name = #{outName},</if>
            <if test="outTime != null">out_time = #{outTime},</if>
            <if test="parentId != null">parent_id = #{parentId},</if>
            <if test="type != null">type = #{type},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteWhTeamReceiveDetailById" parameterType="Long">
        delete from wh_team_receive_detail where id = #{id}
    </delete>

    <delete id="deleteWhTeamReceiveDetailByIds" parameterType="String">
        delete from wh_team_receive_detail where id in 
        <foreach item="id" collection="array" open="(" separator="," close=")">
            #{id}
        </foreach>
    </delete>
</mapper>