package com.mosquito.project.permission;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * 审批超时提醒记录Repository
 */
@Repository
public interface ApprovalTimeoutReminderRepository extends JpaRepository<ApprovalTimeoutReminderRecord, Long> {

    /**
     * 检查指定进度百分比的提醒是否已发送
     */
    @Query("SELECT COUNT(r) > 0 FROM ApprovalTimeoutReminderRecord r WHERE r.recordId = :recordId AND r.approverId = :approverId AND r.progressPercent = :progressPercent")
    boolean hasReminderBeenSent(@Param("recordId") Long recordId, @Param("approverId") Long approverId, @Param("progressPercent") Integer progressPercent);

    /**
     * 获取指定审批记录的所有提醒记录
     */
    List<ApprovalTimeoutReminderRecord> findByRecordId(Long recordId);
}
