<?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.tuoheng.admin.mapper.IotEquipmentMapper">

    <resultMap type="com.tuoheng.admin.entity.IotEquipment" id="IotEquipmentResult">
        <result property="id"    column="id"    />
        <result property="tenantId"    column="tenant_id"    />
        <result property="deptId"    column="dept_id"    />
        <result property="code"    column="code"    />
        <result property="name"    column="name"    />
        <result property="roadId"    column="road_id"    />
        <result property="sectionId"    column="section_id"    />
        <result property="location"    column="location"    />
        <result property="longitude"    column="longitude"    />
        <result property="latitude"    column="latitude"    />
        <result property="playUrl"    column="play_url"    />
        <result property="status"    column="status"    />
        <result property="createUser"    column="create_user"    />
        <result property="createTime"    column="create_time"    />
        <result property="updateUser"    column="update_user"    />
        <result property="updateTime"    column="update_time"    />
        <result property="mark"    column="mark"    />
    </resultMap>


    <sql id="Base_Column_List">
        id, tenant_id, dept_id, code, name, road_id, section_id, location, longitude, latitude, play_url, status,
        create_user, create_time, update_user, update_time, mark
    </sql>

    <sql id="selectThAccidentVo">
        select id, tenant_id, dept_id, code, name, road_id, section_id, location, longitude, latitude, play_url, status,
        create_user, create_time, update_user, update_time, mark
        from th_iot_equipment
    </sql>

    <select id="selectPageList" parameterType="com.tuoheng.admin.request.iotequipment.QueryIotEquipmentPageListRequest" resultMap="IotEquipmentResult">
        select <include refid="Base_Column_List"/>
        from th_iot_equipment
        <where>
            <if test="1 == 1"> and mark = 1 </if>
            <if test="request.tenantId != null and request.tenantId != ''"> and tenant_id = #{request.tenantId} </if>
            <if test="request.deptIdList != null and request.deptIdList.size() > 0">
                and dept_id in
                <foreach item="deptId" collection="request.deptIdList" open="(" separator="," close=")">
                    #{deptId}
                </foreach>
            </if>
        </where>
        order by create_time desc
    </select>

    <select id="selectList" parameterType="com.tuoheng.admin.request.iotequipment.QueryIotEquipmentListRequest" resultMap="IotEquipmentResult">
        select <include refid="Base_Column_List"/>
        from th_iot_equipment
        <where>
            <if test="1 == 1"> and mark = 1 </if>
            <if test="request.tenantId != null and request.tenantId != ''"> and tenant_id = #{request.tenantId} </if>
            <if test="request.deptIdList != null and request.deptIdList.size() > 0">
                and dept_id in
                <foreach item="deptId" collection="request.deptIdList" open="(" separator="," close=")">
                    #{deptId}
                </foreach>
            </if>
        </where>
        order by create_time desc
    </select>


</mapper>