<?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.playlet.system.mapper.PlayletWithdrawApprovalMapper">

    <resultMap type="PlayletWithdrawApproval" id="PlayletWithdrawApprovalResult">
        <result property="id"    column="id"    />
        <result property="withdrawOrder"    column="withdraw_order"    />
        <result property="approvalUserId"    column="approval_user_id"    />
        <result property="approvalStatus"    column="approval_status"    />
        <result property="approvalOpinion"    column="approval_opinion"    />
        <result property="approvalMoney"    column="approval_money"    />
        <result property="createBy"    column="create_by"    />
        <result property="updateBy"    column="update_by"    />
        <result property="createTime"    column="create_time"    />
        <result property="updateTime"    column="update_time"    />
        <result property="remark"    column="remark"    />
    </resultMap>

    <sql id="selectPlayletWithdrawApprovalVo">
        select id, withdraw_order, approval_user_id, approval_status, approval_opinion, approval_money, create_by, update_by, create_time, update_time, remark from playlet_withdraw_approval
    </sql>

    <select id="selectPlayletWithdrawApprovalList" parameterType="PlayletWithdrawApproval" resultMap="PlayletWithdrawApprovalResult">
        <include refid="selectPlayletWithdrawApprovalVo"/>
        <where>
            <if test="withdrawOrder != null  and withdrawOrder != ''"> and withdraw_order = #{withdrawOrder}</if>
            <if test="approvalUserId != null  and approvalUserId != ''"> and approval_user_id = #{approvalUserId}</if>
            <if test="approvalStatus != null "> and approval_status = #{approvalStatus}</if>
            <if test="approvalOpinion != null  and approvalOpinion != ''"> and approval_opinion = #{approvalOpinion}</if>
            <if test="approvalMoney != null "> and approval_money = #{approvalMoney}</if>
        </where>
    </select>

    <select id="selectPlayletWithdrawApprovalById" parameterType="Long" resultMap="PlayletWithdrawApprovalResult">
        <include refid="selectPlayletWithdrawApprovalVo"/>
        where id = #{id}
    </select>

    <insert id="insertPlayletWithdrawApproval" parameterType="PlayletWithdrawApproval" useGeneratedKeys="true" keyProperty="id">
        insert into playlet_withdraw_approval
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="withdrawOrder != null and withdrawOrder != ''">withdraw_order,</if>
            <if test="approvalUserId != null and approvalUserId != ''">approval_user_id,</if>
            <if test="approvalStatus != null">approval_status,</if>
            <if test="approvalOpinion != null and approvalOpinion != ''">approval_opinion,</if>
            <if test="approvalMoney != null">approval_money,</if>
            <if test="createBy != null and createBy != ''">create_by,</if>
            <if test="updateBy != null and updateBy != ''">update_by,</if>
            <if test="createTime != null">create_time,</if>
            <if test="updateTime != null">update_time,</if>
            <if test="remark != null and remark != ''">remark,</if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="withdrawOrder != null and withdrawOrder != ''">#{withdrawOrder},</if>
            <if test="approvalUserId != null and approvalUserId != ''">#{approvalUserId},</if>
            <if test="approvalStatus != null">#{approvalStatus},</if>
            <if test="approvalOpinion != null and approvalOpinion != ''">#{approvalOpinion},</if>
            <if test="approvalMoney != null">#{approvalMoney},</if>
            <if test="createBy != null and createBy != ''">#{createBy},</if>
            <if test="updateBy != null and updateBy != ''">#{updateBy},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="updateTime != null">#{updateTime},</if>
            <if test="remark != null and remark != ''">#{remark},</if>
        </trim>
    </insert>

    <update id="updatePlayletWithdrawApproval" parameterType="PlayletWithdrawApproval">
        update playlet_withdraw_approval
        <trim prefix="SET" suffixOverrides=",">
            <if test="withdrawOrder != null and withdrawOrder != ''">withdraw_order = #{withdrawOrder},</if>
            <if test="approvalUserId != null and approvalUserId != ''">approval_user_id = #{approvalUserId},</if>
            <if test="approvalStatus != null">approval_status = #{approvalStatus},</if>
            <if test="approvalOpinion != null and approvalOpinion != ''">approval_opinion = #{approvalOpinion},</if>
            <if test="approvalMoney != null">approval_money = #{approvalMoney},</if>
            <if test="createBy != null and createBy != ''">create_by = #{createBy},</if>
            <if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
            <if test="remark != null and remark != ''">remark = #{remark},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deletePlayletWithdrawApprovalById" parameterType="Long">
        delete from playlet_withdraw_approval where id = #{id}
    </delete>

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

</mapper>