<?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.com.ctop.common.module.mapper.MaterialCutFrameMapper">

    <select id="getListByVideoSignature" resultType="cn.com.ctop.common.module.entity.MaterialCutFrame">
        select a.signature,
       (select frame.url
        from ctop_material_cut_frame frame
        where frame.signature = a.signature
        order by id desc
        limit 1) as 'url',
       (select frame.image_index
        from ctop_material_cut_frame frame
        where frame.signature = a.signature
        order by id desc
        limit 1) as 'image_index',
       (select frame.id
        from ctop_material_cut_frame frame
        where frame.signature = a.signature
        order by id desc
        limit 1) as 'id'
       from (select distinct signature
      from ctop_material_cut_frame
      where video_signature = #{videoSignature}) a;
    </select>


    <select id="getProgramCreativeCover" resultType="com.alibaba.fastjson.JSONObject">
      SELECT
      signature as 'signature',
      url as 'url'
      FROM ctop_material_cut_frame
      WHERE video_signature = #{signature}
      ORDER BY RAND() LIMIT 5;
    </select>

</mapper>
