package com.izouma.jmrh.repo;

import com.izouma.jmrh.domain.ApprovalProcess;
import com.izouma.jmrh.enums.ApprovalProcessStatus;
import com.izouma.jmrh.enums.ApprovalStatus;
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.JpaSpecificationExecutor;

import java.util.List;

public interface ApprovalProcessRepo extends JpaRepository<ApprovalProcess, Long>, JpaSpecificationExecutor<ApprovalProcess> {
    Page<ApprovalProcess> findByUserIdOrderByCreatedAtDesc(Long userId, Pageable pageable);

    Page<ApprovalProcess> findByUserIdAndStatusInOrderByCreatedAtDesc(Long userId, Iterable<ApprovalProcessStatus> statuses, Pageable pageable);

    Page<ApprovalProcess> findByUserIdAndApprovalStatusOrderByCreatedAtDesc(Long userId, ApprovalStatus status, Pageable pageable);

    long countByApprovalIdAndLevelAndStatus(Long approvalId, int level, ApprovalProcessStatus status);
}