<?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="cn.reghao.tnb.file.app.zdisk.db.mapper.CamDeviceMapper">
    <insert id="save" useGeneratedKeys="true" keyProperty="id">
        insert into disk_cam_device
        (`cam_id`,`cam_name`,`state`,`add_at`,`add_by`,`pull_url`,`push_url`)
        values
        (#{camId},#{camName},#{state},#{addAt},#{addBy},#{pullUrl},#{pushUrl})
    </insert>

    <select id="countByCamDeviceQuery" resultType="java.lang.Integer">
        select count(*)
        from disk_cam_device
        <where>
            deleted=0
            <if test="camId != null">
                and cam_id=#{camId}
            </if>
            <if test="addBy != null">
                and `add_by`=#{addBy}
            </if>
            <if test="camName != null">
                and cam_name=#{camName}
            </if>
        </where>
    </select>
    <select id="findCamDeviceQueryByPage" resultType="cn.reghao.tnb.file.app.zdisk.model.po.CamDevice">
        select *
        from disk_cam_device
        <where>
            deleted=0
            <if test="camDeviceQuery.camId != null">
                and cam_id=#{camDeviceQuery.camId}
            </if>
            <if test="camDeviceQuery.addBy != null">
                and `add_by`=#{camDeviceQuery.addBy}
            </if>
            <if test="camDeviceQuery.camName != null">
                and cam_name=#{camDeviceQuery.camName}
            </if>
        </where>
    </select>
    <select id="findByCamIds" resultType="cn.reghao.tnb.file.app.zdisk.model.po.CamDevice">
        select *
        from disk_cam_device
        where deleted=0 and cam_id in
        <foreach collection="list" item="id" index="index" open="(" close=")" separator=",">
            #{id}
        </foreach>
    </select>
</mapper>
