<?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.dcsoft.system.vehicle.mapper.CarChargeItemMapper">

    <resultMap type="CarChargeItem" id="CarChargeItemResult">
        <result property="id"    column="id"    />
        <result property="chargeId"    column="charge_id"    />
        <result property="startLong"    column="start_long"    />
        <result property="endLong"    column="end_long"    />
        <result property="chargeMoney"    column="charge_money"    />
    </resultMap>

    <sql id="selectCarChargeItemVo">
        select id, charge_id, start_long, end_long, charge_money from car_charge_item
    </sql>

    <select id="selectCarChargeItemList" parameterType="CarChargeItem" resultMap="CarChargeItemResult">
        <include refid="selectCarChargeItemVo"/>
        <where>
            <if test="chargeId != null "> and charge_id = #{chargeId}</if>
            <if test="startLong != null "> and start_long = #{startLong}</if>
            <if test="endLong != null "> and end_long = #{endLong}</if>
            <if test="chargeMoney != null "> and charge_money = #{chargeMoney}</if>
        </where>
    </select>

    <select id="selectCarChargeItemById" parameterType="Long" resultMap="CarChargeItemResult">
        <include refid="selectCarChargeItemVo"/>
        where id = #{id}
    </select>

    <insert id="insertCarChargeItem" parameterType="CarChargeItem" useGeneratedKeys="true" keyProperty="id">
        insert into car_charge_item
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="chargeId != null">charge_id,</if>
            <if test="startLong != null">start_long,</if>
            <if test="endLong != null">end_long,</if>
            <if test="chargeMoney != null">charge_money,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="chargeId != null">#{chargeId},</if>
            <if test="startLong != null">#{startLong},</if>
            <if test="endLong != null">#{endLong},</if>
            <if test="chargeMoney != null">#{chargeMoney},</if>
         </trim>
    </insert>

    <update id="updateCarChargeItem" parameterType="CarChargeItem">
        update car_charge_item
        <trim prefix="SET" suffixOverrides=",">
            <if test="chargeId != null">charge_id = #{chargeId},</if>
            <if test="startLong != null">start_long = #{startLong},</if>
            <if test="endLong != null">end_long = #{endLong},</if>
            <if test="chargeMoney != null">charge_money = #{chargeMoney},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteCarChargeItemById" parameterType="Long">
        delete from car_charge_item where id = #{id}
    </delete>

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

    <delete id="deleteChargeItemByChargeId" parameterType="Long">
        delete from car_charge_item where charge_id = #{id}
    </delete>
</mapper>
