package com.codenetworkz.blog.repositories;

import com.codenetworkz.blog.models.Category;

import com.codenetworkz.blog.models.Comment;
import com.codenetworkz.blog.models.Status;
import com.codenetworkz.blog.models.Tag;
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 CategoryRepository extends JpaRepository<Category, Long> {

    Optional<Category> findBySlug(String categorySlug);

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

    List<Category> findAllByIdInAndIsDelete(List<Long> categoryIds, Status status);

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