<?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.muyu.enterpise.mapper.CarFenceServiceMybaitsMapper">

    <insert id="fenceAdd" keyProperty="id" useGeneratedKeys="true">
        insert into car_fence values (0,#{name},#{clazzId},#{typeId},#{fenceText},#{fenceStart},#{fenceEnd},#{fenceCreate},0)
    </insert>
    <insert id="addGroup">
        insert into car_middle values (0,#{fenceGroupId},#{integer})
    </insert>
    <insert id="addFenceGroup">
        insert into car_middle values (0,#{id},#{fenceGroupId})
    </insert>
    <!--根据围栏组和车辆的id添加中间表-->
    <insert id="addFenceGroupAddCarMiddle">
        insert into car_group_middle values (0,#{id},#{groupId})
    </insert>

    <!--根据围栏组的id查询绑定的围栏的中间表-->
    <select id="BoundFenceGroup" resultType="com.muyu.domain.CarMiddle">
        select * from  car_middle where car_group_id = #{groupId}
    </select>
    <!--查询围栏组绑定的围栏列表-->
    <select id="selectBoundCarFenceList" resultType="com.muyu.domain.CarFence">
        select * from car_fence where id = #{carFenceId}
    </select>
    <!--获取绑定的围栏组-->
    <select id="selectBoundGFenceGroup" resultType="com.muyu.domain.FenceAndGroupMiddle">
        select * from car_group_middle where car_id = #{carId}
    </select>
    <!--获取围栏组的数据-->
    <select id="selectGroup" resultType="com.muyu.domain.FenceGroup">
        select * from  fence_group where group_id = #{carGroupId}
    </select>


</mapper>
