<?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.zbf.system.mapper.TransferOrderMapper">

    <resultMap type="TransferOrder" id="TransferOrderResult">
        <result property="creator"    column="creator"    />
        <result property="id"    column="id"    />
        <result property="creationTime"    column="creation_time"    />
        <result property="transferContent"    column="transfer_content"    />
        <result property="transferStatus"    column="transfer_status"    />
    </resultMap>

    <sql id="selectTransferOrderVo">
        select creator, id, creation_time, transfer_content, transfer_status from transfer_order
    </sql>

    <select id="selectTransferOrderList" parameterType="TransferOrder" resultMap="TransferOrderResult">
        <include refid="selectTransferOrderVo"/>
        <where>
            <if test="creator != null  and creator != ''"> and creator = #{creator}</if>
            <if test="creationTime != null "> and creation_time = #{creationTime}</if>
            <if test="transferContent != null  and transferContent != ''"> and transfer_content = #{transferContent}</if>
            <if test="transferStatus != null  and transferStatus != ''"> and transfer_status = #{transferStatus}</if>
        </where>
    </select>

    <select id="selectTransferOrderById" parameterType="Long" resultMap="TransferOrderResult">
        <include refid="selectTransferOrderVo"/>
        where id = #{id}
    </select>

    <insert id="insertTransferOrder" parameterType="TransferOrder" useGeneratedKeys="true" keyProperty="id">
        insert into transfer_order
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="creator != null and creator != ''">creator,</if>
            <if test="creationTime != null">creation_time,</if>
            <if test="transferContent != null and transferContent != ''">transfer_content,</if>
            <if test="transferStatus != null and transferStatus != ''">transfer_status,</if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="creator != null and creator != ''">#{creator},</if>
            <if test="creationTime != null">#{creationTime},</if>
            <if test="transferContent != null and transferContent != ''">#{transferContent},</if>
            <if test="transferStatus != null and transferStatus != ''">#{transferStatus},</if>
        </trim>
    </insert>

    <update id="updateTransferOrder" parameterType="TransferOrder">
        update transfer_order
        <trim prefix="SET" suffixOverrides=",">
            <if test="creator != null and creator != ''">creator = #{creator},</if>
            <if test="creationTime != null">creation_time = #{creationTime},</if>
            <if test="transferContent != null and transferContent != ''">transfer_content = #{transferContent},</if>
            <if test="transferStatus != null and transferStatus != ''">transfer_status = #{transferStatus},</if>
        </trim>
        where id = #{id}
    </update>

    <update id="enableTransferOrderByIds" parameterType="String">
        update transfer_order set status=0 where id in
        <foreach item="id" collection="array" open="(" separator="," close=")">
            #{id}
        </foreach>
    </update>
    <update id="disabledTransferOrderByIds" parameterType="String">
        update transfer_order set status=1 where id in
        <foreach item="id" collection="array" open="(" separator="," close=")">
            #{id}
        </foreach>
    </update>

    <delete id="deleteTransferOrderById" parameterType="Long">
        delete from transfer_order  where id = #{id}
    </delete>

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