<?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.fdkankan.ucenter.mapper.ICameraMapper">

    <select id="pageList" resultType="com.fdkankan.ucenter.vo.response.CameraVo">
        select c.id,c.sn_code,c.child_name ,d.balance,d.type , d.total_space,d.used_space,
        u.id as cooperationUser,u.user_name as cooperationUserName,d.unit
        from t_camera c
        left join t_camera_detail d on c.id = d.camera_id
        left join t_user u on d.cooperation_user = u.id
        WHERE c.rec_status = 'A'
        <if test="param.selecttype !=null and param.selecttype == 2 and param.childName !=null and param.childName!='' ">
            and c.child_name like CONCAT('%',#{param.childName},'%')
        </if>
        <if test="param.selecttype !=null and param.selecttype == 1 and param.childName !=null and param.childName!=''">
            and u.user_name like CONCAT('%',#{param.childName},'%')
        </if>
        <if test="param.userId !=null ">
            and d.user_id = #{param.userId}
        </if>
        <if test="param.cameraType!=null and param.cameraType == 4">
            and d.type in (0,1,2)
        </if>
        <if test="param.cameraType!=null and param.cameraType >= 9">
            and d.type = #{param.cameraType}
        </if>
        order by c.activated_time desc
    </select>
    <select id="getCameraInfo" resultType="com.fdkankan.ucenter.vo.response.CameraAppVo">
         select * from  t_camera c
        left join t_camera_detail d on c.id = d.camera_id
        left join t_goods g on d.goods_id = g.id
        left join t_user u on d.user_id = u.id
        where c.rec_status = 'A'
        and c.child_name = #{childName}
        and c.child_password = #{childPassword}
    </select>

    <select id="getAllListByUser" resultType="com.fdkankan.ucenter.entity.Camera">
        select  * from t_camera c left join t_camera_detail d on c.id = d.camera_id
        where c.rec_status = 'A' and c.sn_code like concat('%',#{snCode},'%') and d.user_id = #{userId}
    </select>
</mapper>
