package com.infinite.focus.server.lessons;
import java.util.List;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

import com.infinite.focus.server.auth.Instructor;
import com.infinite.focus.server.auth.Student;
import com.infinite.focus.server.wall.WallPost;

//Handles CRUD operations for quotes table



@Repository
public interface LessonRepository extends JpaRepository<Lesson, Long> {
	
	@Query(value = "SELECT * FROM lesson WHERE lesson_id = ?1", nativeQuery = true)
	Lesson findByLessonId(Long lesson_id);
	
	@Query(value = "SELECT * FROM lesson WHERE grade_id = ?1 ORDER BY lesson_index ASC", nativeQuery = true)
	List<Lesson> findByGradeId(Long grade_id);
	
	@Query(value = "SELECT * FROM lesson WHERE grade_id = ?1  ORDER BY lesson_index DESC LIMIT 1", nativeQuery = true)
	Lesson findHighestLessonByGradeId(Long grade_id);
	
	@Query(value = "SELECT * FROM lesson WHERE video_url = ?1  ORDER BY lesson_index DESC LIMIT 1", nativeQuery = true)
	Lesson findByVideoUrl(String video_url);

}