package com.codenetworkz.blog.repositories;

import com.codenetworkz.blog.models.Post;

import com.codenetworkz.blog.models.Status;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
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 PostRepository extends JpaRepository<Post, Long> {


    @Query(value ="select p from  Post p where p.isDelete =:status" )
    List<Post> findAllAndIsDelete(Status status);

    Optional<Post> findBySlug(String postSlug);

    Page<Post> findAllByIsDelete(Status status, Pageable pageable);
}
