<?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.kuaishou.modules.batch.mapper.KuaiShouGroupTemplateMapper">

    <select id="getMd5ByPhotoId" resultType="com.alibaba.fastjson.JSONObject">
    select
    signature  as 'md5',
    material_type as 'materialType'
    from ctop_kuaishou_video_get
    where  photo_id = #{photoId}
    and signature is not null
    limit 1
    </select>

    <select id="getImageListByMd5" resultType="com.alibaba.fastjson.JSONObject">
      select
      signature as 'md5',
      url as 'url'
      from ctop_material_cut_frame
      where video_signature = #{md5}
      ORDER BY RAND() LIMIT #{imageCount}
    </select>
    <select id="getImageJsonByMd5" resultType="com.alibaba.fastjson.JSONObject">
      select
      signature as 'md5',
      url as 'url'
      from ctop_material_cut_frame
      where video_signature = #{md5}
       ORDER BY RAND() LIMIT 1
    </select>


    <select id="getApiCreateCount" resultType="java.lang.Integer">
        select count(1)
        from
            ctop_kuaishou_group
        where  account_id = #{accountId}
          and unit_type = #{unitType}
          and DATE_FORMAT(group_create_time,'%Y-%m-%d') =  #{date}
    </select>

    <select id="getUrlByPhotoId" resultType="com.alibaba.fastjson.JSONObject">
     select
     cover_url as 'coverUrl',
     url as 'url'
     from
     ctop_kuaishou_video_get
     where  photo_id = #{photoId}
     and status = 0
     limit 1
    </select>

    <select id="getIdList" resultType="java.lang.Long">
    select id  from ctop_kuaishou_group_template
    where  task_status = 0
    order by create_time asc
    limit 70
    </select>

</mapper>