<?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.FavlistContentMapper">
    <insert id="save" useGeneratedKeys="true" keyProperty="id">
        insert into favlist_content
        (`id`,`favlist_id`,`content_id`,`collect_at`)
        values 
        (#{id},#{favlistId},#{contentId},#{collectAt})
    </insert>

    <delete id="deleteByContentId">
        delete from favlist_content
        where content_id=#{contentId} and favlist_id=#{favlistId}
    </delete>

    <select id="findByContentId" resultType="cn.reghao.tnb.content.app.vod.model.po.FavlistContent">
        select *
        from favlist_content
        where favlist_id in (
            select favlist_id
            from favlist
            where content_type=#{contentType} and create_by=#{userId})
          and content_id=#{contentId}
    </select>

    <select id="countByFavlistId" resultType="java.lang.Integer">
        select count(*)
        from favlist_content
        where favlist_id=#{favlistId}
    </select>
    <select id="findByFavlistIdByPage" resultType="cn.reghao.tnb.content.app.vod.model.po.FavlistContent">
        select *
        from favlist_content
        where favlist_id=#{favlistId}
    </select>
</mapper>
