package org.cmh.backend.NewsManagement.repository;

import org.cmh.backend.NewsManagement.model.News;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;

import java.util.List;

public interface NewsRepository extends JpaRepository<News, Long> {
    Page<News> findAllByOrderByIdDesc(Pageable pageable);

    Page<News> findByTenantOrderByIdDesc(String tenant, Pageable pageable);

    List<News> findByTitleContainingOrSummaryContainingOrAuthorContainingOrImagePathContainingAndTenantEquals(
            String title,
            String summary,
            String author,
            String imagePath,
            String tenant);

    List<News> findByTitleContainingOrSummaryContainingOrAuthorContainingOrImagePathContaining(String title, String summary, String author, String imagePath);
}