<?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.xxfc.platform.vehicle.mapper.VehicleCataMapper">

	<!-- 可根据自己的需求，是否要使用 -->
    <resultMap type="com.xxfc.platform.vehicle.entity.VehicleCata" id="vehicleCataMap">
        <result property="id" column="id"/>
        <result property="vehicleModelId" column="vehicle_model_id"/>
        <result property="cataId" column="cata_id"/>
        <result property="isdel" column="isdel"/>
        <result property="crtTime" column="crt_time"/>
        <result property="updTime" column="upd_time"/>
    </resultMap>

    <insert id="addCataList" parameterType="java.util.List">
        insert into vehicle_cata (
        vehicle_model_id,cata_id,crt_time,upd_time
        ) VALUES
        <foreach collection ="list" item="item" index="index" separator =",">
            (#{item.vehicleModelId},#{item.cataId},#{item.crtTime},#{item.updTime})
        </foreach>
    </insert>

    <select id="getOne" resultMap="vehicleCataMap">
        SELECT  * FROM  vehicle_cata WHERE  vehicle_model_id=#{vehicleModelId} AND  cata_id=#{cataId}  and  isdel=0 limit 1

    </select>

    <update id="delList">
       update  vehicle_cata set isdel=1 where  cata_id not in (
        <trim suffixOverrides=",">
        <foreach collection ="list" item="cataId">
                #{cataId},
        </foreach>
        </trim>
        ) and vehicle_model_id=#{vehicleModelId}
    </update>

</mapper>