<?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.ICameraDetailMapper">

    <select id="getListByUserAndType" resultType="com.fdkankan.ucenter.vo.response.CameraAppVo">
     SELECT *,c.id as cameraId FROM t_camera_detail d
        LEFT JOIN t_camera c on d.camera_id = c.id
        WHERE d.rec_status = 'A'
        and d.user_id = #{userId}
        and d.type = #{cameraType}
    </select>

    <select id="getListByUserIdsAndType" resultType="com.fdkankan.ucenter.vo.response.CameraAppVo">
        SELECT *,c.id as cameraId FROM t_camera_detail d
            LEFT JOIN t_camera c on d.camera_id = c.id
        WHERE d.rec_status = 'A'
          and d.user_id in
        <foreach item="userId" collection="userIds" open="(" separator="," close=")">
            #{userId}
        </foreach>
          and d.type = #{cameraType}
    </select>

    <select id="getListByUserAndTypeEx" resultType="com.fdkankan.ucenter.vo.response.CameraExcelVo">
        SELECT d.camera_id,c.sn_code,d.used_space,d.total_space,u.user_name as cooperationUser ,ui.increment_end_time as spaceEndStr,ui.is_expired
            FROM t_camera_detail d
                LEFT JOIN t_camera c on d.camera_id = c.id
                left join t_user_increment ui on d.camera_id = ui.camera_id
                left join t_user u on d.cooperation_user = u.id
        WHERE d.rec_status = 'A'  and d.user_id = #{userId}

    </select>
</mapper>
