package com.petshop.backend.repository;

import com.petshop.backend.entity.ActivityLog;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface ActivityLogRepository extends JpaRepository<ActivityLog, Long>, JpaSpecificationExecutor<ActivityLog> {
    boolean existsByUser_Id(Long userId);

    @Query("select a from ActivityLog a order by a.logTimestamp desc, a.logId desc")
    List<ActivityLog> findRecent(Pageable pageable);
}
