package research.loghunter.entity; import jakarta.persistence.*; import lombok.*; import java.time.LocalDateTime; @Entity @Table(name = "error_logs") @Getter @Setter @NoArgsConstructor @AllArgsConstructor @Builder public class ErrorLog { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) private Long id; @ManyToOne(fetch = FetchType.LAZY) @JoinColumn(name = "server_id", nullable = false) private Server server; @ManyToOne(fetch = FetchType.LAZY) @JoinColumn(name = "pattern_id", nullable = false) private Pattern pattern; @ManyToOne(fetch = FetchType.LAZY) @JoinColumn(name = "scan_history_id") private ScanHistory scanHistory; @Column(nullable = false) private String filePath; // 로그 파일 경로 private Integer lineNumber; // 에러 발생 라인 번호 @Column(nullable = false, length = 500) private String summary; // 에러 요약 (첫 줄 또는 일부) @Column(nullable = false, columnDefinition = "TEXT") private String context; // 캡처된 전체 컨텍스트 @Column(nullable = false) private String severity; // CRITICAL, ERROR, WARN @Column(nullable = false) private LocalDateTime occurredAt; // 에러 발생 시간 (로그 파일 내 시간 파싱) @Column(nullable = false) private LocalDateTime scannedAt; // 스캔/분석 시간 @Column(nullable = false, updatable = false) private LocalDateTime createdAt; // DB 저장 시간 @PrePersist protected void onCreate() { createdAt = LocalDateTime.now(); if (scannedAt == null) scannedAt = LocalDateTime.now(); if (occurredAt == null) occurredAt = LocalDateTime.now(); } }