<?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.WhDirectApplyDetailsMapper">
    <resultMap type="com.bonus.material.warehouse.domain.WhDirectApplyDetails" id="WhDirectApplyDetailsResult">
        <result property="id"    column="id"    />
        <result property="directId"    column="direct_id"    />
        <result property="typeId"    column="type_id"    />
        <result property="maId"    column="ma_id"    />
        <result property="createTime"    column="create_time"    />
        <result property="updateTime"    column="update_time"    />
        <result property="directNum"    column="direct_num"    />
    </resultMap>

    <sql id="selectWhDirectApplyDetailsVo">
        select id, direct_id, type_id, ma_id, create_time, update_time, direct_num from wh_direct_apply_details
    </sql>

    <select id="selectWhDirectApplyDetailsList" parameterType="com.bonus.material.warehouse.domain.WhDirectApplyDetails" resultMap="WhDirectApplyDetailsResult">
        <include refid="selectWhDirectApplyDetailsVo"/>
        <where>  
            <if test="directId != null "> and direct_id = #{directId}</if>
            <if test="typeId != null "> and type_id = #{typeId}</if>
            <if test="maId != null "> and ma_id = #{maId}</if>
            <if test="directNum != null "> and direct_num = #{directNum}</if>
        </where>
    </select>
    
    <select id="selectWhDirectApplyDetailsById" parameterType="Long" resultMap="WhDirectApplyDetailsResult">
        <include refid="selectWhDirectApplyDetailsVo"/>
        where id = #{id}
    </select>
        
    <insert id="insertWhDirectApplyDetails" parameterType="com.bonus.material.warehouse.domain.WhDirectApplyDetails" useGeneratedKeys="true" keyProperty="id">
        insert into wh_direct_apply_details
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="directId != null">direct_id,</if>
            <if test="typeId != null">type_id,</if>
            <if test="maId != null">ma_id,</if>
            <if test="createTime != null">create_time,</if>
            <if test="updateTime != null">update_time,</if>
            <if test="directNum != null">direct_num,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="directId != null">#{directId},</if>
            <if test="typeId != null">#{typeId},</if>
            <if test="maId != null">#{maId},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="updateTime != null">#{updateTime},</if>
            <if test="directNum != null">#{directNum},</if>
         </trim>
    </insert>

    <update id="updateWhDirectApplyDetails" parameterType="com.bonus.material.warehouse.domain.WhDirectApplyDetails">
        update wh_direct_apply_details
        <trim prefix="SET" suffixOverrides=",">
            <if test="directId != null">direct_id = #{directId},</if>
            <if test="typeId != null">type_id = #{typeId},</if>
            <if test="maId != null">ma_id = #{maId},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
            <if test="directNum != null">direct_num = #{directNum},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteWhDirectApplyDetailsById" parameterType="Long">
        delete from wh_direct_apply_details where id = #{id}
    </delete>

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