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.CompoundIndexes;
import org.springframework.data.mongodb.core.index.Indexed;
import org.springframework.data.mongodb.core.mapping.Document;
import org.springframework.data.mongodb.core.mapping.Field;

import java.time.LocalDate;
import java.time.LocalDateTime;

/**
 * 管理员任务记录 MongoDB 文档
 *
 * @author tf
 * @date 2025-11-25
 */
@Data
@Document(collection = "admin_task_record")
@CompoundIndexes({
        @CompoundIndex(name = "uk_user_cycle_type", def = "{'user_id': 1, 'cycle_start_date': 1, 'task_type': 1}", unique = true),
        @CompoundIndex(name = "idx_user_role", def = "{'user_id': 1, 'user_role': 1}"),
        @CompoundIndex(name = "idx_cycle", def = "{'cycle_start_date': 1, 'cycle_end_date': 1}")
})
public class AdminTaskRecordDO {

    @Id
    private String id;

    @Field("user_id")
    private Long userId;

    @Field("user_role")
    private String userRole;

    @Field("cycle_start_date")
    private LocalDate cycleStartDate;

    @Field("cycle_end_date")
    private LocalDate cycleEndDate;

    @Field("task_type")
    @Indexed
    private String taskType;

    @Field("target_count")
    private Integer targetCount;

    @Field("completed_count")
    private Integer completedCount;

    @Field("status")
    @Indexed
    private String status;

    @Field("completed_at")
    private LocalDateTime completedAt;

    @Field("create_time")
    private LocalDateTime createTime;

    @Field("update_time")
    private LocalDateTime updateTime;
}
