package com.itsol.quantrivanphong.access.homepage.repository;

import com.itsol.quantrivanphong.model.News;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.Optional;

@Repository
public interface NewsRepository extends JpaRepository<News, Integer> {
    @Query("SELECT u from News u")
    List<News> findAllNews();
    @Query("SELECT u FROM News u where u.id=:id")
    News findNewsById(int id);
    List<News> findByEmployeeId(int employeeId);
    List<News> findByCatalogiId(int catalogiId);
    Optional<News> findByIdAndEmployeeId(int id,int employeeId);
    Optional<News> findByIdAndAndCatalogiId(int id,int catalogiId);
}
