<?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.crm.custom.dao.mapper.GoldenGoodsVideoMapper">

    <select id="customCountList" resultType="integer"
            parameterType="com.crm.rely.backend.model.entity.golden.goods.GoldenGoodsVideoSearchEntity">
        select count(*) from golden_goods_video video
        left join golden_order_details der on video.goods_id = der.goods_id and der.custom_id = #{customId}
        where video.goods_id = #{goodsId}
        <if test="videoName!=null and videoName!=''">
            and video.video_name like concat('%',#{videoName},'%')
        </if>
    </select>

    <select id="customPageList" resultType="com.crm.rely.backend.model.pojo.view.GoldenGoodsVideoListView"
            parameterType="com.crm.rely.backend.model.entity.golden.goods.GoldenGoodsVideoSearchEntity">
        select video.id,video.goods_id,video_name,title,
               file_type,front_url,pay_type,sort,
               der.custom_id
        from golden_goods_video video
        left join golden_order_details der on video.goods_id = der.goods_id and der.custom_id = #{customId}
        where video.goods_id = #{goodsId}
        <if test="videoName!=null and videoName!=''">
            and video.video_name like concat('%',#{videoName},'%')
        </if>
        order by video.sort asc
        <if test="page != null">
            limit #{page.offset},#{page.row}
        </if>
    </select>

    <select id="countList" resultType="integer"
            parameterType="com.crm.rely.backend.model.entity.golden.goods.GoldenGoodsVideoSearchEntity">
        select count(*) from golden_goods_video
        where goods_id = #{goodsId}
        <if test="videoName!=null and videoName!=''">
            and video_name like concat('%',#{videoName},'%')
        </if>
    </select>

    <select id="pageList" resultType="com.crm.rely.backend.model.pojo.table.GoldenGoodsVideoTable"
            parameterType="com.crm.rely.backend.model.entity.golden.goods.GoldenGoodsVideoSearchEntity">
        select * from golden_goods_video
        where goods_id = #{goodsId}
        <if test="videoName!=null and videoName!=''">
            and video_name like concat('%',#{videoName},'%')
        </if>
        order by sort asc
        <if test="page != null">
            limit #{page.offset},#{page.row}
        </if>
    </select>

</mapper>