65 lines
1.6 KiB
Java
65 lines
1.6 KiB
Java
|
|
package com.gcsc.guide.entity;
|
||
|
|
|
||
|
|
import jakarta.persistence.*;
|
||
|
|
import lombok.AllArgsConstructor;
|
||
|
|
import lombok.Builder;
|
||
|
|
import lombok.Getter;
|
||
|
|
import lombok.NoArgsConstructor;
|
||
|
|
|
||
|
|
import java.time.LocalDateTime;
|
||
|
|
|
||
|
|
@Entity
|
||
|
|
@Table(name = "api_access_logs", indexes = {
|
||
|
|
@Index(name = "idx_access_logs_created", columnList = "created_at"),
|
||
|
|
@Index(name = "idx_access_logs_user", columnList = "user_id"),
|
||
|
|
@Index(name = "idx_access_logs_uri", columnList = "request_uri")
|
||
|
|
})
|
||
|
|
@Getter
|
||
|
|
@NoArgsConstructor
|
||
|
|
@AllArgsConstructor
|
||
|
|
@Builder
|
||
|
|
public class ApiAccessLog {
|
||
|
|
|
||
|
|
@Id
|
||
|
|
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||
|
|
private Long id;
|
||
|
|
|
||
|
|
@Column(name = "user_id")
|
||
|
|
private Long userId;
|
||
|
|
|
||
|
|
@Column(name = "user_email")
|
||
|
|
private String userEmail;
|
||
|
|
|
||
|
|
@Column(name = "client_ip", length = 45)
|
||
|
|
private String clientIp;
|
||
|
|
|
||
|
|
@Column(name = "origin_domain")
|
||
|
|
private String originDomain;
|
||
|
|
|
||
|
|
@Column(name = "http_method", nullable = false, length = 10)
|
||
|
|
private String httpMethod;
|
||
|
|
|
||
|
|
@Column(name = "request_uri", nullable = false, length = 500)
|
||
|
|
private String requestUri;
|
||
|
|
|
||
|
|
@Column(name = "query_string", length = 2000)
|
||
|
|
private String queryString;
|
||
|
|
|
||
|
|
@Column(name = "response_status")
|
||
|
|
private Integer responseStatus;
|
||
|
|
|
||
|
|
@Column(name = "duration_ms")
|
||
|
|
private Long durationMs;
|
||
|
|
|
||
|
|
@Column(name = "user_agent", length = 500)
|
||
|
|
private String userAgent;
|
||
|
|
|
||
|
|
@Column(name = "created_at", nullable = false, updatable = false)
|
||
|
|
private LocalDateTime createdAt;
|
||
|
|
|
||
|
|
@PrePersist
|
||
|
|
protected void onCreate() {
|
||
|
|
this.createdAt = LocalDateTime.now();
|
||
|
|
}
|
||
|
|
}
|