package com.erp.systemtool.repository;

import com.erp.systemtool.entity.PullRecord;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;

import java.time.LocalDateTime;

/**
 * Repository for PullRecord entity
 */
@Repository
public interface PullRecordRepository extends JpaRepository<PullRecord, Long> {

    @Modifying
    @Query("DELETE FROM PullRecord p WHERE p.createdAt < :cutoffDate")
    int deleteOlderThan(@Param("cutoffDate") LocalDateTime cutoffDate);

    long countByCreatedAtBefore(LocalDateTime cutoffDate);
}
