<?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="cn.reghao.tnb.content.app.vod.db.mapper.PlayCompleteMapper">
    <insert id="save" useGeneratedKeys="true" keyProperty="id">
        insert into vod_play_complete
        (`user_id`,`video_id`,`create_at`)
        values 
        (#{userId},#{videoId},#{createAt})
    </insert>
    <insert id="saveAll" useGeneratedKeys="true" keyProperty="id">
        insert into vod_play_complete
        (`user_id`,`video_id`,`create_at`)
        values
        <foreach collection="list" item="item" index="index" separator=",">
            (#{item.userId},#{item.videoId},#{item.createAt})
        </foreach>
    </insert>

    <select id="findAll" resultType="cn.reghao.tnb.content.app.vod.model.po.PlayComplete">
        select *
        from vod_play_complete
        limit 1000
    </select>
    <select id="findByUserIdAndVideoId" resultType="cn.reghao.tnb.content.app.vod.model.po.PlayComplete">
        select *
        from vod_play_complete
        where user_id=#{userId} and video_id=#{videoId}
        order by id desc
        limit 1
    </select>
</mapper>
