<?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.yida.data.device.camera.mapper.EduCameraStrategyThemeMapper">

	<!-- 家长查询符合条件的主题列表数据 -->
	<select id="selectThemeList" resultType="com.yida.data.common.core.entity.camera.EduCameraStrategyTheme">
		SELECT DISTINCT
			a.*
		FROM
			(
				SELECT DISTINCT
					t.*
				FROM
					edu_camera_strategy_theme t
				LEFT JOIN edu_camera_strategy_open_class c ON t.id = c.open_id
				WHERE
					t.del_flag = 0
				AND c.del_flag = 0
				AND t.open_status = 1
				AND c.dept_id IN
			    <foreach collection="classIds" open="(" separator="," close=")" item="classId">
					#{classId}
				</foreach>
			) a
		LEFT JOIN edu_camera_strategy_open_time ot ON a.id = ot.open_id
		WHERE
			ot.`week` = #{weekDay}
		AND DATE_FORMAT( NOW( ), '%H:%i' ) BETWEEN DATE_FORMAT( ot.`start`, '%H:%i' )
		AND DATE_FORMAT( ot.`end`, '%H:%i' )
		AND ot.del_flag = 0
	</select>
	
</mapper>
