package com.mosquito.project.persistence.repository;

import com.mosquito.project.persistence.entity.ActivityEntity;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

import java.time.OffsetDateTime;
import java.util.List;

public interface ActivityRepository extends JpaRepository<ActivityEntity, Long>, JpaSpecificationExecutor<ActivityEntity> {

    /**
     * 查询已过期但未结束的活动（状态为RUNNING或PAUSED）
     */
    @Query("SELECT a FROM ActivityEntity a WHERE a.endTimeUtc < :now AND a.status IN ('RUNNING', 'PAUSED')")
    List<ActivityEntity> findExpiredActivities(@Param("now") OffsetDateTime now);
}

