package dev.ksan.etfoglasiserver.repository;

import dev.ksan.etfoglasiserver.model.Entry;

import java.time.LocalDateTime;
import java.util.Optional;
import java.util.UUID;

import dev.ksan.etfoglasiserver.model.Subject;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;

@Repository
public interface EntryRepo extends JpaRepository<Entry, String> {

    Optional<Entry> findByTitleAndTimePublishedAndSubject(String title, LocalDateTime timePublished, Subject subject);

    Page<Entry> findAllByOrderByTimePublishedDesc(Pageable pageable);
    Page<Entry> findBySubjectOrderByTimePublishedDesc(Subject subject, Pageable pageable);
    Page<Entry> findByGroupNameOrderByTimePublishedDesc(String groupName, Pageable pageable);
    Page<Entry> findBySubjectAndGroupNameOrderByTimePublishedDesc(Subject subject, String groupName, Pageable pageable);
}

