package com.test.entity;
import jakarta.persistence.*;
import lombok.*;
import org.hibernate.annotations.Comment;
import java.time.Instant;
import java.util.Objects;
@Comment("操作日志表")
@Entity // @Entity注解的类将会初始化为一张数据库表
@Table(name = "sys_operation_log", schema = "controllerLogToDB")
@NoArgsConstructor // 自动生成无参构造函数,无参构造函数是 JPA 要求的,因为 JPA 需要通过反射创建实体实例
@AllArgsConstructor // 自动生成包含所有字段的构造函数,便于快速创建对象实例
@Getter // 自动生成所有字段的 getter 和 setter 方法,简化属性访问
@Setter // 自动生成所有字段的 getter 和 setter 方法,简化属性访问
@ToString // 自动生成 toString() 方法,输出对象的字符串表示,便于调试和日志记录
public class SysOperationLog {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "id", nullable = false)
private Long id;
@Comment("操作模块")
@Column(name = "module", length = 50)
private String module;
@Comment("操作类型")
@Column(name = "type", length = 50)
private String type;
@Comment("操作描述")
@Column(name = "description")
private String description;
@Comment("请求方法")
@Column(name = "method", length = 100)
private String method;
@Comment("请求路径")
@Column(name = "request_url")
private String requestUrl;
@Comment("请求方式")
@Column(name = "request_method", length = 20)
private String requestMethod;
@Comment("请求参数")
@Lob
@Column(name = "request_params")
private String requestParams;
@Comment("响应结果")
@Lob
@Column(name = "response_result",columnDefinition = "TEXT")
private String responseResult;
@Comment("操作用户")
@Column(name = "username", length = 50)
private String username;
@Comment("IP地址")
@Column(name = "ip_address", length = 50)
private String ipAddress;
@Comment("操作状态(0-失败,1-成功)")
@Column(name = "status")
private Integer status;
@Comment("错误信息")
@Lob
@Column(name = "error_msg")
private String errorMsg;
@Comment("创建时间")
@Column(name = "create_time")
private Instant createTime;
@Comment("执行时长(毫秒)")
@Column(name = "duration")
private Long duration;
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
SysOperationLog that = (SysOperationLog) o;
return Objects.equals(id, that.id) && Objects.equals(module, that.module) && Objects.equals(type, that.type) && Objects.equals(description, that.description) && Objects.equals(method, that.method) && Objects.equals(requestUrl, that.requestUrl) && Objects.equals(requestMethod, that.requestMethod) && Objects.equals(requestParams, that.requestParams) && Objects.equals(responseResult, that.responseResult) && Objects.equals(username, that.username) && Objects.equals(ipAddress, that.ipAddress) && Objects.equals(status, that.status) && Objects.equals(errorMsg, that.errorMsg) && Objects.equals(createTime, that.createTime) && Objects.equals(duration, that.duration);
}
@Override
public int hashCode() {
return Objects.hash(id, module, type, description, method, requestUrl, requestMethod, requestParams, responseResult, username, ipAddress, status, errorMsg, createTime, duration);
}
}
ddl-auto: create
于 2025-01-19 03:45:04 首次发布