<?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.WxRescueInfoMapper">
    
    <resultMap type="cn.iocoder.yudao.module.rescue.domain.WxRescueInfo" id="WxRescueInfoResult">
        <result property="id"    column="id"    />
        <result property="customerName"    column="customer_name"    />
        <result property="customerPhone"    column="customer_phone"    />
        <result property="carNum"    column="car_num"    />
        <result property="amount"    column="amount"    />
        <result property="payType"    column="pay_type"    />

        <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="selectWxRescueInfoVo">
        select id, customer_name, customer_phone, car_num, amount, pay_type, remark, create_time, creator, update_time, updater from wx_rescue_info
    </sql>

    <select id="selectWxRescueInfoList" parameterType="cn.iocoder.yudao.module.rescue.domain.WxRescueInfo" resultMap="WxRescueInfoResult">
        <include refid="selectWxRescueInfoVo"/>
        <where>  
            <if test="customerName != null  and customerName != ''"> and customer_name like concat('%', #{customerName}, '%')</if>
            <if test="customerPhone != null  and customerPhone != ''"> and customer_phone = #{customerPhone}</if>
            <if test="carNum != null  and carNum != ''"> and car_num = #{carNum}</if>
            <if test="amount != null "> and amount = #{amount}</if>
            <if test="payType != null  and payType != ''"> and pay_type = #{payType}</if>
        </where>
    </select>
    
    <select id="selectWxRescueInfoById" parameterType="java.lang.Long" resultMap="WxRescueInfoResult">
        <include refid="selectWxRescueInfoVo"/>
        where id = #{id}
    </select>
        
    <insert id="insertWxRescueInfo" parameterType="cn.iocoder.yudao.module.rescue.domain.WxRescueInfo" useGeneratedKeys="true" keyProperty="id">
        insert into wx_rescue_info
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="customerName != null">customer_name,</if>
            <if test="customerPhone != null">customer_phone,</if>
            <if test="carNum != null">car_num,</if>
            <if test="amount != null">amount,</if>
            <if test="payType != null">pay_type,</if>
            <if test="remark != null">remark,</if>
            <if test="createTime != null">create_time,</if>
            <if test="createBy != null">creator,</if>
            <if test="updateTime != null">update_time,</if>
            <if test="updateBy != null">updater,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="customerName != null">#{customerName},</if>
            <if test="customerPhone != null">#{customerPhone},</if>
            <if test="carNum != null">#{carNum},</if>
            <if test="amount != null">#{amount},</if>
            <if test="payType != null">#{payType},</if>
            <if test="remark != null">#{remark},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="createBy != null">#{createBy},</if>
            <if test="updateTime != null">#{updateTime},</if>
            <if test="updateBy != null">#{updateBy},</if>
         </trim>
    </insert>

    <update id="updateWxRescueInfo" parameterType="cn.iocoder.yudao.module.rescue.domain.WxRescueInfo">
        update wx_rescue_info
        <trim prefix="SET" suffixOverrides=",">
            <if test="customerName != null">customer_name = #{customerName},</if>
            <if test="customerPhone != null">customer_phone = #{customerPhone},</if>
            <if test="carNum != null">car_num = #{carNum},</if>
            <if test="amount != null">amount = #{amount},</if>
            <if test="payType != null">pay_type = #{payType},</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="updateTime != null">update_time = #{updateTime},</if>
            <if test="updateBy != null">updater = #{updateBy},</if>
        </trim>
        where id = #{id}
    </update>

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

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