package com.example.demo.model;

import jakarta.persistence.*;
import java.math.BigDecimal;
import java.time.LocalDate;
import java.time.LocalDateTime;

@Entity
@Table(name = "user_activity_stats")
public class UserActivityStats {
    
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;
    
    @Column(name = "activity_date", nullable = false, unique = true)
    private LocalDate activityDate;
    
    @Column(name = "daily_active_users", nullable = false)
    private Integer dailyActiveUsers = 0;
    
    @Column(name = "monthly_active_users", nullable = false)
    private Integer monthlyActiveUsers = 0;
    
    @Column(name = "new_users", nullable = false)
    private Integer newUsers = 0;
    
    @Column(name = "returning_users", nullable = false)
    private Integer returningUsers = 0;
    
    @Column(name = "session_count", nullable = false)
    private Integer sessionCount = 0;
    
    @Column(name = "avg_session_duration", precision = 10, scale = 2)
    private BigDecimal avgSessionDuration = BigDecimal.ZERO;
    
    @Column(name = "created_at", nullable = false)
    private LocalDateTime createdAt;
    
    @Column(name = "updated_at")
    private LocalDateTime updatedAt;
    
    @PrePersist
    protected void onCreate() {
        createdAt = LocalDateTime.now();
        updatedAt = LocalDateTime.now();
    }
    
    @PreUpdate
    protected void onUpdate() {
        updatedAt = LocalDateTime.now();
    }
    
    // Getters and Setters
    public Long getId() { return id; }
    public void setId(Long id) { this.id = id; }
    
    public LocalDate getActivityDate() { return activityDate; }
    public void setActivityDate(LocalDate activityDate) { this.activityDate = activityDate; }
    
    public Integer getDailyActiveUsers() { return dailyActiveUsers; }
    public void setDailyActiveUsers(Integer dailyActiveUsers) { this.dailyActiveUsers = dailyActiveUsers; }
    
    public Integer getMonthlyActiveUsers() { return monthlyActiveUsers; }
    public void setMonthlyActiveUsers(Integer monthlyActiveUsers) { this.monthlyActiveUsers = monthlyActiveUsers; }
    
    public Integer getNewUsers() { return newUsers; }
    public void setNewUsers(Integer newUsers) { this.newUsers = newUsers; }
    
    public Integer getReturningUsers() { return returningUsers; }
    public void setReturningUsers(Integer returningUsers) { this.returningUsers = returningUsers; }
    
    public Integer getSessionCount() { return sessionCount; }
    public void setSessionCount(Integer sessionCount) { this.sessionCount = sessionCount; }
    
    public BigDecimal getAvgSessionDuration() { return avgSessionDuration; }
    public void setAvgSessionDuration(BigDecimal avgSessionDuration) { this.avgSessionDuration = avgSessionDuration; }
    
    public LocalDateTime getCreatedAt() { return createdAt; }
    public void setCreatedAt(LocalDateTime createdAt) { this.createdAt = createdAt; }
    
    public LocalDateTime getUpdatedAt() { return updatedAt; }
    public void setUpdatedAt(LocalDateTime updatedAt) { this.updatedAt = updatedAt; }
}
