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

import lombok.Data;
import org.springframework.data.annotation.Id;
import org.springframework.data.mongodb.core.index.CompoundIndex;
import org.springframework.data.mongodb.core.index.Indexed;
import org.springframework.data.mongodb.core.mapping.Document;

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

/**
 * 火箭状态MongoDB文档
 *
 * @author system
 * @date 2025-01-15
 */
@Data
@Document(collection = "room_rocket_status")
@CompoundIndex(name = "uk_room_date", def = "{'roomId': 1, 'date': 1}", unique = true)
public class RocketStatusDocument {

    /**
     * 主键ID
     */
    @Id
    private String id;

    /**
     * 房间ID
     */
    @Indexed
    private Long roomId;

    /**
     * 日期 (格式: 2025-01-15)
     */
    @Indexed
    private String date;

    /**
     * 等级
     */
    private Integer level;

    /**
     * 当前能量值
     */
    private Long currentEnergy;

    /**
     * 最大能量值
     */
    private Long maxEnergy;

    /**
     * 状态 (1:CHARGING 2:LAUNCHED 3:CLAIMING)
     */
    @Indexed
    private Integer status;

    /**
     * 贡献者列表
     */
    private List<ContributorDoc> contributors;

    /**
     * 发射时间
     */
    private LocalDateTime launchTime;

    /**
     * 领取过期时间
     */
    @Indexed
    private LocalDateTime claimExpireTime;

    /**
     * 已领取人数
     */
    private Integer claimCount;

    /**
     * 创建时间
     */
    @Indexed
    private LocalDateTime createdAt;

    /**
     * 更新时间
     */
    @Indexed
    private LocalDateTime updatedAt;

    /**
     * 贡献者内嵌文档
     */
    @Data
    public static class ContributorDoc {
        private Long userId;
        private String userName;
        private String userAvatar;
        private Long energy;
        private Double contributionRate;
        private Integer giftCount;
        private LocalDateTime firstContributeTime;
        private LocalDateTime lastContributeTime;
    }
}
