package com.red.circle.other.infra.database.mongo.repository;

import com.red.circle.other.infra.database.mongo.document.RocketHistoryDocument;
import org.springframework.data.mongodb.repository.MongoRepository;
import org.springframework.data.mongodb.repository.Query;
import org.springframework.stereotype.Repository;

import java.time.LocalDateTime;
import java.util.List;

/**
 * 火箭历史Repository
 *
 * @author system
 * @date 2025-01-15
 */
@Repository
public interface RocketHistoryRepository extends MongoRepository<RocketHistoryDocument, String> {

    /**
     * 根据房间ID查询历史
     */
    List<RocketHistoryDocument> findByRoomIdOrderByLaunchTimeDesc(Long roomId);

    /**
     * 查询今天最新的火箭发射记录（按发射时间倒序）
     */
    RocketHistoryDocument findFirstByRoomIdAndDateOrderByLaunchTimeDesc(Long roomId, String date);

    /**
     * 根据房间ID和日期查询
     */
    List<RocketHistoryDocument> findByRoomIdAndDateOrderByLaunchTimeDesc(Long roomId, String date);

    /**
     * 根据房间ID和时间范围查询
     */
    List<RocketHistoryDocument> findByRoomIdAndLaunchTimeBetweenOrderByLaunchTimeDesc(
            Long roomId,
            LocalDateTime startTime,
            LocalDateTime endTime
    );

    /**
     * 根据等级查询
     */
    List<RocketHistoryDocument> findByLevelOrderByLaunchTimeDesc(Integer level);
}
