package com.ssj.dao.course.dao;

import com.ssj.bean.course.domain.CourseFeedbackFile;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

import java.util.Date;
import java.util.List;


@Repository
public interface IFeedbackFileDao extends JpaRepository<CourseFeedbackFile, String> {

	@Query(nativeQuery = true, value = " SELECT * FROM tb_course_feedback_file t where t.course_details_id=?2 and t.lib_id=?1 and t.imgurl is null order by t.create_time asc limit 1   ")
	CourseFeedbackFile findOneData(String libId, String courseDetailId);

	@Query(nativeQuery = true, value = " SELECT imgurl FROM tb_course_feedback_file t where t.course_details_id=?3 and t.lib_id=?1 and t.vip_id=?2 and t.imgurl is not null order by t.create_time asc limit 3   ")
	List<String> getRedFlowList3(String libId, String vipId, String courseDetailId);

	@Query(nativeQuery = true, value = " SELECT count(1) FROM tb_course_feedback_file t where t.course_details_id=?3 and t.lib_id=?1 and t.vip_id=?2 and to_days(t.create_time)=to_days(?4)")
	Integer getRedFlowCount(String libId, String vipId, String courseDetailsId, Date openTime);

	@Query(nativeQuery = true, value = " SELECT imgurl FROM tb_course_feedback_file t where t.course_details_id=?3 and t.lib_id=?1 and t.vip_id=?2 and  to_days(t.create_time)=to_days(?4)  ")
	List<String> getImgList(String libId, String backId, String courseDetailsId, Date openTime);

}
