<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "mybatis-3-mapper.dtd" >
<mapper namespace="com.pcloud.book.group.dao.impl.LearningReportBrowseRecordDaoImpl">
    <resultMap id="BaseResultMap" type="com.pcloud.book.group.entity.LearningReportBrowseRecord">
        <id column="id" property="id" jdbcType="BIGINT"/>
        <result column="qrcode_id" property="qrcodeId" jdbcType="BIGINT"/>
        <result column="classify_id" property="classifyId" jdbcType="BIGINT"/>
        <result column="book_group_id" property="bookGroupId" jdbcType="BIGINT"/>
        <result column="create_user" property="createUser" jdbcType="BIGINT"/>
        <result column="create_time" property="createTime" jdbcType="TIMESTAMP"/>
    </resultMap>


    <sql id="Base_Column_List">
        id, qrcode_id, classify_id, book_group_id, create_user, create_time
    </sql>

    <insert id="insert" parameterType="com.pcloud.book.group.entity.LearningReportBrowseRecord" useGeneratedKeys="true"
            keyProperty="id">
        insert into learning_report_browse_record
        <trim prefix="(" suffix=")" suffixOverrides=",">
            qrcode_id,
            classify_id,
            book_group_id,
            create_user,
            create_time
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            #{qrcodeId,jdbcType=BIGINT},
            #{classifyId,jdbcType=BIGINT},
            #{bookGroupId,jdbcType=BIGINT},
            #{createUser,jdbcType=BIGINT},
            NOW()
        </trim>
    </insert>

    <select id="getCountGroupByClassifyId" parameterType="list" resultType="com.pcloud.book.group.dto.ClassifyLearningCountDto">
        select
        classify_id classifyId,
        count(1) count
        from learning_report_browse_record
        where classify_id in
        <foreach collection="list" item="item" index="index" open="(" close=")" separator=",">
            #{item}
        </foreach>
        group by classify_id
    </select>

</mapper>