package research.loghunter.entity;

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

@Entity
@Table(name = "server_log_paths")
@Getter
@Setter
@NoArgsConstructor
@AllArgsConstructor
@Builder
public class ServerLogPath {

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

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "server_id", nullable = false)
    private Server server;

    @Column(nullable = false)
    private String path;  // 예: /var/log/tomcat/

    @Column(nullable = false)
    private String filePattern;  // 예: catalina.*.log, *.log

    private String description;  // 설명 (예: Tomcat 로그)

    @Column(nullable = false)
    private Boolean active;

    @Column(nullable = false, updatable = false)
    private LocalDateTime createdAt;

    @PrePersist
    protected void onCreate() {
        createdAt = LocalDateTime.now();
        if (active == null) active = true;
    }
}
