package com.walkguide.entity;

import jakarta.persistence.*;
import lombok.*;
import java.time.LocalDateTime;

@Entity
@Table(name = "geofence_configs")
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class GeofenceConfig {

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;

    @Column(name = "guardian_id")
    private Long guardianId;

    @Column(name = "user_id", nullable = false, unique = true)
    private Long userId;

    @Column(name = "center_lat")
    private Double centerLat;

    @Column(name = "center_lng")
    private Double centerLng;

    @Column(name = "radius_meters", nullable = false)
    @Builder.Default
    private Double radiusMeters = 500.0;

    @Column(nullable = false)
    @Builder.Default
    private Boolean enabled = false;

    @Column(name = "updated_at", nullable = false)
    private LocalDateTime updatedAt;

    @PrePersist
    @PreUpdate
    protected void onUpdate() {
        updatedAt = LocalDateTime.now();
    }
}
