package com.cirle.scientific.dao;

import com.cirle.scientific.po.QkjLive;
import com.cirle.scientific.po.QkjVedioPlayRecord;
import com.cirle.scientific.po.QkjVideoPlayLog;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;

import java.math.BigDecimal;
import java.util.List;

public interface QkjVideoPlayLogDao extends PagingAndSortingRepository<QkjVideoPlayLog, Long>, JpaSpecificationExecutor<QkjVideoPlayLog> {

    @Query(value = "SELECT t1.id , courseid , liveid , logtime , t1.mem_card , SUM(learntime) learntime FROM (\n" +
            "\tSELECT * FROM qkj_video_play_log WHERE learntime > 0 and  mem_card = ?1 \n" +
            ") t1 INNER JOIN(\n" +
            "\tSELECT * FROM qkj_tqcourse_course WHERE tqcourse_id = ?2 \n" +
            ") t2 ON t1.courseid = t2.id",nativeQuery = true)
    QkjVideoPlayLog findCourseLogList(String memCard , Long tqcourseId);

    @Query(value = "SELECT id,courseid,liveid,logtime,mem_card,SUM(learntime) learntime " +
                   "FROM qkj_video_play_log WHERE mem_card = ?1 AND liveid = ?2 AND learntime > 0",nativeQuery = true)
    QkjVideoPlayLog findLiveLogList(String memCard , Long liveId);

}
