<?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.CameraMapper">
    
    <resultMap type="com.tuoheng.admin.entity.domain.Camera" id="CameraResult">
        <result property="id"    column="id"    />
        <result property="tenantId"    column="tenant_id"    />
        <result property="cameraName"    column="camera_name"    />
        <result property="cameraType"    column="camera_type"    />
        <result property="longitude"    column="longitude"    />
        <result property="latitude"    column="latitude"    />
        <result property="location"    column="location"    />
        <result property="flvUrl"    column="flv_url"    />
        <result property="remark"    column="remark"    />
        <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="selectCameraVo">
        select id, tenant_id, camera_name, camera_type, longitude, latitude, location, flv_url, remark, create_user, create_time, update_user, update_time, mark from th_camera
    </sql>

    <select id="selectList" parameterType="com.tuoheng.admin.entity.request.camera.QueryCameraListRequest" resultMap="CameraResult">
        <include refid="selectCameraVo"/>
        <where>
            <if test="1 == 1"> and mark = 1 </if>
            <if test="tenantId != null "> and tenant_id = #{tenantId}</if>
        </where>
        order by create_time desc
    </select>
    
    <select id="selectOneById" parameterType="Integer" resultMap="CameraResult">
        <include refid="selectCameraVo"/>
        where mark = 1 and id = #{id}
    </select>

</mapper>