<?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.input.mapper.InputApplyDetailsMapper">
    <resultMap type="com.bonus.material.input.domain.InputApplyDetails" id="InputApplyDetailsResult">
        <result property="id"    column="id"    />
        <result property="taskId"    column="task_id"    />
        <result property="maId"    column="ma_id"    />
        <result property="typeId"    column="type_id"    />
        <result property="parentId"    column="parent_id"    />
        <result property="inputNum"    column="input_num"    />
        <result property="inputType"    column="input_type"    />
        <result property="createBy"    column="create_by"    />
        <result property="createTime"    column="create_time"    />
        <result property="updateBy"    column="update_by"    />
        <result property="updateTime"    column="update_time"    />
        <result property="remark"    column="remark"    />
        <result property="companyId"    column="company_id"    />
    </resultMap>

    <sql id="selectInputApplyDetailsVo">
        select id, task_id, ma_id, type_id, parent_id, input_num, input_type, create_by, create_time, update_by, update_time, remark, company_id from input_apply_details
    </sql>

    <select id="selectInputApplyDetailsList" parameterType="com.bonus.material.input.domain.InputApplyDetails" resultMap="InputApplyDetailsResult">
        <include refid="selectInputApplyDetailsVo"/>
        <where>
            <if test="taskId != null "> and task_id = #{taskId}</if>
            <if test="maId != null "> and ma_id = #{maId}</if>
            <if test="typeId != null "> and type_id = #{typeId}</if>
            <if test="parentId != null "> and parent_id = #{parentId}</if>
            <if test="inputNum != null "> and input_num = #{inputNum}</if>
            <if test="inputType != null  and inputType != ''"> and input_type = #{inputType}</if>
            <if test="companyId != null "> and company_id = #{companyId}</if>
        </where>
    </select>

    <select id="selectInputApplyDetailsById" parameterType="Long" resultMap="InputApplyDetailsResult">
        <include refid="selectInputApplyDetailsVo"/>
        where id = #{id}
    </select>

    <insert id="insertInputApplyDetails" parameterType="com.bonus.material.input.domain.InputApplyDetails" useGeneratedKeys="true" keyProperty="id">
        insert into input_apply_details
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="taskId != null">task_id,</if>
            <if test="maId != null">ma_id,</if>
            <if test="typeId != null">type_id,</if>
            <if test="parentId != null">parent_id,</if>
            <if test="inputNum != null">input_num,</if>
            <if test="inputType != null">input_type,</if>
            <if test="createBy != null">create_by,</if>
            <if test="createTime != null">create_time,</if>
            <if test="updateBy != null">update_by,</if>
            <if test="updateTime != null">update_time,</if>
            <if test="remark != null">remark,</if>
            <if test="companyId != null">company_id,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="taskId != null">#{taskId},</if>
            <if test="maId != null">#{maId},</if>
            <if test="typeId != null">#{typeId},</if>
            <if test="parentId != null">#{parentId},</if>
            <if test="inputNum != null">#{inputNum},</if>
            <if test="inputType != null">#{inputType},</if>
            <if test="createBy != null">#{createBy},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="updateBy != null">#{updateBy},</if>
            <if test="updateTime != null">#{updateTime},</if>
            <if test="remark != null">#{remark},</if>
            <if test="companyId != null">#{companyId},</if>
         </trim>
    </insert>

    <update id="updateInputApplyDetails" parameterType="com.bonus.material.input.domain.InputApplyDetails">
        update input_apply_details
        <trim prefix="SET" suffixOverrides=",">
            <if test="taskId != null">task_id = #{taskId},</if>
            <if test="maId != null">ma_id = #{maId},</if>
            <if test="typeId != null">type_id = #{typeId},</if>
            <if test="parentId != null">parent_id = #{parentId},</if>
            <if test="inputNum != null">input_num = #{inputNum},</if>
            <if test="inputType != null">input_type = #{inputType},</if>
            <if test="createBy != null">create_by = #{createBy},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="updateBy != null">update_by = #{updateBy},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
            <if test="remark != null">remark = #{remark},</if>
            <if test="companyId != null">company_id = #{companyId},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteInputApplyDetailsById" parameterType="Long">
        delete from input_apply_details where id = #{id}
    </delete>

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


</mapper>
