API 로그저장, ExceptionHandler 저장, 감사,에러로그API 작업 진행중
This commit is contained in:
@@ -0,0 +1,85 @@
|
||||
package com.kamco.cd.kamcoback.postgres.entity;
|
||||
|
||||
import com.kamco.cd.kamcoback.log.dto.AuditLogDto;
|
||||
import com.kamco.cd.kamcoback.log.dto.EventStatus;
|
||||
import com.kamco.cd.kamcoback.log.dto.EventType;
|
||||
import com.kamco.cd.kamcoback.postgres.CommonCreateEntity;
|
||||
import jakarta.persistence.*;
|
||||
import lombok.AccessLevel;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@Entity
|
||||
@Getter
|
||||
@NoArgsConstructor(access = AccessLevel.PROTECTED)
|
||||
@Table(name = "tb_audit_log")
|
||||
public class AuditLogEntity extends CommonCreateEntity {
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
@Column(name = "audit_log_uid")
|
||||
private Long id;
|
||||
|
||||
@Column(name = "user_uid")
|
||||
private Long userUid;
|
||||
|
||||
@Enumerated(EnumType.STRING)
|
||||
private EventType eventType;
|
||||
|
||||
@Enumerated(EnumType.STRING)
|
||||
private EventStatus eventStatus;
|
||||
|
||||
@Column(name = "menu_uid")
|
||||
private String menuUid;
|
||||
|
||||
@Column(name = "ip_address")
|
||||
private String ipAddress;
|
||||
|
||||
@Column(name = "request_uri")
|
||||
private String requestUri;
|
||||
|
||||
@Column(name = "request_body")
|
||||
private String requestBody;
|
||||
|
||||
@Column(name = "error_log_uid")
|
||||
private Long errorLogUid;
|
||||
|
||||
public AuditLogEntity(Long userUid, EventType eventType, EventStatus eventStatus, String menuUid, String ipAddress, String requestUri, String requestBody, Long errorLogUid) {
|
||||
this.userUid = userUid;
|
||||
this.eventType = eventType;
|
||||
this.eventStatus = eventStatus;
|
||||
this.menuUid = menuUid;
|
||||
this.ipAddress = ipAddress;
|
||||
this.requestUri = requestUri;
|
||||
this.requestBody = requestBody;
|
||||
this.errorLogUid = errorLogUid;
|
||||
}
|
||||
|
||||
public AuditLogDto.Basic toDto() {
|
||||
return new AuditLogDto.Basic(
|
||||
this.id,
|
||||
this.userUid,
|
||||
this.eventType,
|
||||
this.eventStatus,
|
||||
this.menuUid,
|
||||
this.ipAddress,
|
||||
this.requestUri,
|
||||
this.requestBody,
|
||||
this.errorLogUid,
|
||||
super.getCreatedDate());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString(){
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append(this.id).append("\n")
|
||||
.append(this.userUid).append("\n")
|
||||
.append(this.eventType).append("\n")
|
||||
.append(this.eventStatus).append("\n")
|
||||
.append(this.menuUid).append("\n")
|
||||
.append(this.ipAddress).append("\n")
|
||||
.append(this.requestUri).append("\n")
|
||||
.append(this.requestBody).append("\n")
|
||||
.append(this.errorLogUid);
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
package com.kamco.cd.kamcoback.postgres.entity;
|
||||
|
||||
import com.kamco.cd.kamcoback.log.dto.ErrorLogDto;
|
||||
import com.kamco.cd.kamcoback.log.dto.EventType;
|
||||
import com.kamco.cd.kamcoback.postgres.CommonCreateEntity;
|
||||
import jakarta.persistence.*;
|
||||
import lombok.AccessLevel;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.ZonedDateTime;
|
||||
|
||||
@Entity
|
||||
@Getter
|
||||
@NoArgsConstructor(access = AccessLevel.PROTECTED)
|
||||
@Table(name = "tb_error_log")
|
||||
public class ErrorLogEntity extends CommonCreateEntity {
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
@Column(name = "error_log_uid")
|
||||
private Long id;
|
||||
|
||||
@Column(name = "request_id")
|
||||
private String requestId;
|
||||
|
||||
@Column(name = "error_type")
|
||||
@Enumerated(EnumType.STRING)
|
||||
private EventType errorType;
|
||||
|
||||
@Enumerated(EnumType.STRING)
|
||||
private ErrorLogDto.LogErrorLevel errorLevel;
|
||||
private String errorCode;
|
||||
private String errorMessage;
|
||||
private String stackTrace;
|
||||
private Long handlerUid;
|
||||
private ZonedDateTime handledDttm;
|
||||
|
||||
public ErrorLogEntity(String requestId, EventType errorType, ErrorLogDto.LogErrorLevel errorLevel, String errorCode, String errorMessage, String stackTrace
|
||||
, Long handlerUid, ZonedDateTime handledDttm) {
|
||||
this.requestId = requestId;
|
||||
this.errorType = errorType;
|
||||
this.errorLevel = errorLevel;
|
||||
this.errorCode = errorCode;
|
||||
this.errorMessage = errorMessage;
|
||||
this.stackTrace = stackTrace;
|
||||
this.handlerUid = handlerUid;
|
||||
this.handledDttm = handledDttm;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
package com.kamco.cd.kamcoback.postgres.entity;
|
||||
|
||||
import com.kamco.cd.kamcoback.log.dto.EventStatus;
|
||||
import com.kamco.cd.kamcoback.log.dto.EventType;
|
||||
import com.kamco.cd.kamcoback.postgres.CommonDateEntity;
|
||||
import jakarta.persistence.*;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.AccessLevel;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Entity
|
||||
@Getter
|
||||
@NoArgsConstructor(access = AccessLevel.PROTECTED)
|
||||
@Table(name = "tb_menu")
|
||||
public class MenuEntity extends CommonDateEntity {
|
||||
@Id
|
||||
@Column(name = "menu_uid")
|
||||
private String menuUid;
|
||||
|
||||
@Column(name = "menu_nm")
|
||||
private String menuNm;
|
||||
|
||||
@Column(name = "menu_url")
|
||||
private String menuUrl;
|
||||
|
||||
@Column(name = "description")
|
||||
private String description;
|
||||
|
||||
@Column(name = "menu_order")
|
||||
private Long menuOrder;
|
||||
|
||||
@NotNull
|
||||
@Column(name = "is_use", nullable = true)
|
||||
private Boolean isUse = true;
|
||||
|
||||
@NotNull
|
||||
@Column(name = "deleted", nullable = false)
|
||||
private Boolean deleted = false;
|
||||
|
||||
private Long createdUid;
|
||||
private Long updatedUid;
|
||||
|
||||
@ManyToOne(fetch = FetchType.LAZY)
|
||||
@JoinColumn(name = "parent_menu_uid")
|
||||
private MenuEntity parent;
|
||||
|
||||
@OneToMany(mappedBy = "parent", fetch = FetchType.LAZY, cascade = CascadeType.ALL)
|
||||
private List<MenuEntity> children = new ArrayList<>();
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
package com.kamco.cd.kamcoback.postgres.entity;
|
||||
|
||||
import com.kamco.cd.kamcoback.log.dto.ErrorLogDto;
|
||||
import com.kamco.cd.kamcoback.log.dto.EventType;
|
||||
import com.kamco.cd.kamcoback.postgres.CommonDateEntity;
|
||||
import jakarta.persistence.*;
|
||||
import lombok.AccessLevel;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.time.ZonedDateTime;
|
||||
|
||||
@Entity
|
||||
@Getter
|
||||
@NoArgsConstructor(access = AccessLevel.PROTECTED)
|
||||
@Table(name = "tb_user")
|
||||
public class UserEntity extends CommonDateEntity {
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
@Column(name = "user_uid")
|
||||
private Long id;
|
||||
|
||||
@Column(name = "user_nm")
|
||||
private String userNm;
|
||||
|
||||
@Column(name = "user_id")
|
||||
private String userId;
|
||||
|
||||
@Column(name = "pswd")
|
||||
private String pswd; //TODO: 암호화
|
||||
|
||||
//@Enumerated(EnumType.STRING)
|
||||
private String state; //TODO: 추후 enum -> ACTIVE : 정상, LOCKED : 잠김, EXPIRED : 만료, WITHDRAWAL : 탈퇴
|
||||
|
||||
private ZonedDateTime dateWithdrawal;
|
||||
|
||||
private String userEmail;
|
||||
private Long createdUid;
|
||||
private Long updatedUid;
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user