package com.ssj.dao.sys.homework.dao;

import com.ssj.bean.sys.homework.domain.NoHomeworkRecord;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface NoHomeworkRecordDao extends JpaRepository<NoHomeworkRecord, String> {

    @Query(nativeQuery = true, value = "select * from scon_no_homework_record where vip_id=?1 and course_name=?2 and to_days(create_time) = to_days(now())")
    public List<NoHomeworkRecord> findByVipIdAndCourseName(String vipId, String courseName);

    @Query(nativeQuery = true, value = "select * from scon_no_homework_record where vip_id=?1 and to_days(create_time) = to_days(now())")
    public List<NoHomeworkRecord> findByVipId(String vipId);

    @Query(nativeQuery = true, value = "select * from scon_no_homework_record where vip_id=?1 and create_time between ?2 and ?3")
    public List<NoHomeworkRecord> findDateRecordByVipId(String vipId, String beginTime, String endTime);

    @Query(nativeQuery = true, value = "select * from scon_no_homework_record where vip_id=?1 and course_name=?2 and create_time between ?3 and ?4 limit 1")
    public NoHomeworkRecord findDateRecordByVipIdAndCourseName(String vipId, String subject, String beginTime, String endTime);

    @Query(nativeQuery = true, value = "select * from scon_no_homework_record where vip_id=?1 and course_name=?2 and create_time between ?3 and ?4")
    public List<NoHomeworkRecord> findByVipIdAndCourseNameAndTime(String vipId, String courseName, String beginTime, String endTime);
}
