<?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.LearningReportTouchRecordDaoImpl">
    <resultMap id="BaseResultMap" type="com.pcloud.book.group.entity.LearningReportTouchRecord">
        <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="wx_user_id" property="wxUserId" jdbcType="VARCHAR"/>
        <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.LearningReportTouchRecord" useGeneratedKeys="true"
            keyProperty="id">
        insert into learning_report_touch_record
        <trim prefix="(" suffix=")" suffixOverrides=",">
            qrcode_id,
            classify_id,
            book_group_id,
            wx_user_id,
            create_time
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            #{qrcodeId,jdbcType=BIGINT},
            #{classifyId,jdbcType=BIGINT},
            #{bookGroupId,jdbcType=BIGINT},
            #{wxUserId,jdbcType=VARCHAR},
            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_touch_record
        where classify_id in
        <foreach collection="list" item="item" index="index" open="(" close=")" separator=",">
            #{item}
        </foreach>
        group by classify_id
    </select>

</mapper>