<?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="cn.iocoder.yudao.module.rescue.mapper.RescueOrderReturnMapper">
    
    <resultMap type="cn.iocoder.yudao.module.rescue.domain.RescueOrderReturn" id="RescueOrderReturnResult">
        <result property="id"    column="id"    />
        <result property="rescueOrderId"    column="rescue_order_id"    />
        <result property="returnTime"    column="return_time"    />
        <result property="returnMoney"    column="return_money"    />
        <result property="userId"    column="user_id"    />
        <result property="remark"    column="remark"    />

        <result property="deptId"    column="dept_id"    />
        <result property="creator"    column="creator"    />
        <result property="createTime"    column="create_time"    />
        <result property="updater"    column="updater"    />
        <result property="updateTime"    column="update_time"    />
    </resultMap>

    <sql id="selectRescueOrderReturnVo">
        select id, rescue_order_id, return_time, return_money, user_id, remark, create_time, creator, dept_id, update_time, updater from rescue_order_return
    </sql>

    <select id="selectRescueOrderReturnList" parameterType="cn.iocoder.yudao.module.rescue.domain.RescueOrderReturn" resultMap="RescueOrderReturnResult">
        <include refid="selectRescueOrderReturnVo"/>
        <where>  
            <if test="returnTime != null "> and return_time = #{returnTime}</if>
            <if test="userId != null "> and user_id = #{userId}</if>
        </where>
    </select>
    
    <select id="selectRescueOrderReturnById" parameterType="java.lang.Long" resultMap="RescueOrderReturnResult">
        <include refid="selectRescueOrderReturnVo"/>
        where id = #{id}
    </select>
        
    <insert id="insertRescueOrderReturn" parameterType="cn.iocoder.yudao.module.rescue.domain.RescueOrderReturn">
        insert into rescue_order_return
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">id,</if>
            <if test="rescueOrderId != null">rescue_order_id,</if>
            <if test="returnTime != null">return_time,</if>
            <if test="returnMoney != null">return_money,</if>
            <if test="userId != null">user_id,</if>
            <if test="remark != null">remark,</if>
            <if test="createTime != null">create_time,</if>
            <if test="createBy != null">creator,</if>
            <if test="deptId != null">dept_id,</if>
            <if test="updateTime != null">update_time,</if>
            <if test="updateBy != null">updater,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="id != null">#{id},</if>
            <if test="rescueOrderId != null">#{rescueOrderId},</if>
            <if test="returnTime != null">#{returnTime},</if>
            <if test="returnMoney != null">#{returnMoney},</if>
            <if test="userId != null">#{userId},</if>
            <if test="remark != null">#{remark},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="createBy != null">#{createBy},</if>
            <if test="deptId != null">#{deptId},</if>
            <if test="updateTime != null">#{updateTime},</if>
            <if test="updateBy != null">#{updateBy},</if>
         </trim>
    </insert>

    <update id="updateRescueOrderReturn" parameterType="cn.iocoder.yudao.module.rescue.domain.RescueOrderReturn">
        update rescue_order_return
        <trim prefix="SET" suffixOverrides=",">
            <if test="rescueOrderId != null">rescue_order_id = #{rescueOrderId},</if>
            <if test="returnTime != null">return_time = #{returnTime},</if>
            <if test="returnMoney != null">return_money = #{returnMoney},</if>
            <if test="userId != null">user_id = #{userId},</if>
            <if test="remark != null">remark = #{remark},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="createBy != null">creator = #{createBy},</if>
            <if test="deptId != null">dept_id = #{deptId},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
            <if test="updateBy != null">updater = #{updateBy},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteRescueOrderReturnById" parameterType="java.lang.Long">
        delete from rescue_order_return where id = #{id}
    </delete>

    <delete id="deleteRescueOrderReturnByIds" parameterType="java.lang.String">
        delete from rescue_order_return where id in 
        <foreach item="id" collection="array" open="(" separator="," close=")">
            #{id}
        </foreach>
    </delete>
</mapper>