<?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.yonge.cooleshow.biz.dal.dao.ExposureRecordDao">

	<update id="saveExposureRecord">
		insert into exposure_record (exposure_time_, exposure_num_, object_id_, object_type_, platform_)
		values
		<foreach collection="beans" item="bean" separator="," >
			(#{bean.exposureTime}, 1, #{bean.objectId}, #{bean.objectType}, #{bean.platform})
		</foreach>
		ON DUPLICATE KEY UPDATE
		exposure_num_ = exposure_num_ + 1
	</update>
    <select id="courseExposureTotal"
            resultType="com.yonge.cooleshow.biz.dal.wrapper.TeacherIndexWrapper$CourseExposureTotal">
		select DATE_FORMAT(er.exposure_time_, #{groupBy}) 'date',er.object_type_ as type,
		       SUM(er.exposure_num_) exposureNum from exposure_record er
		where er.exposure_time_ BETWEEN #{param.startTime} AND #{param.endTime}
		group by er.object_type_,DATE_FORMAT(er.exposure_time_, #{groupBy})
		ORDER BY type,'date'
	</select>
</mapper>
