API 로그저장, ExceptionHandler 저장, 감사,에러로그API 작업 진행중
This commit is contained in:
181
src/main/java/com/kamco/cd/kamcoback/log/dto/AuditLogDto.java
Normal file
181
src/main/java/com/kamco/cd/kamcoback/log/dto/AuditLogDto.java
Normal file
@@ -0,0 +1,181 @@
|
||||
package com.kamco.cd.kamcoback.log.dto;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import com.kamco.cd.kamcoback.common.utils.interfaces.JsonFormatDttm;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
import org.springframework.data.domain.PageRequest;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.data.domain.Sort;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.ZonedDateTime;
|
||||
|
||||
public class AuditLogDto {
|
||||
|
||||
@Schema(name = "AuditLogBasic", description = "감사로그 기본 정보")
|
||||
@Getter
|
||||
public static class Basic {
|
||||
|
||||
@JsonIgnore
|
||||
private final Long id;
|
||||
private final Long userUid;
|
||||
private final EventType eventType;
|
||||
private final EventStatus eventStatus;
|
||||
private final String menuUid;
|
||||
private final String ipAddress;
|
||||
private final String requestUri;
|
||||
private final String requestBody;
|
||||
private final Long errorLogUid;
|
||||
|
||||
@JsonFormatDttm
|
||||
private final ZonedDateTime createdDttm;
|
||||
|
||||
public Basic(
|
||||
Long id,
|
||||
Long userUid,
|
||||
EventType eventType,
|
||||
EventStatus eventStatus,
|
||||
String menuUid,
|
||||
String ipAddress,
|
||||
String requestUri,
|
||||
String requestBody,
|
||||
Long errorLogUid,
|
||||
ZonedDateTime createdDttm) {
|
||||
this.id = id;
|
||||
this.userUid = userUid;
|
||||
this.eventType = eventType;
|
||||
this.eventStatus = eventStatus;
|
||||
this.menuUid = menuUid;
|
||||
this.ipAddress = ipAddress;
|
||||
this.requestUri = requestUri;
|
||||
this.requestBody = requestBody;
|
||||
this.errorLogUid = errorLogUid;
|
||||
this.createdDttm = createdDttm;
|
||||
}
|
||||
}
|
||||
|
||||
@Schema(name = "AuditList", description = "감사 로그 목록")
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
public static class AuditList {
|
||||
private int readCount;
|
||||
private int cudCount;
|
||||
private int printCount;
|
||||
private int downloadCount;
|
||||
private Long totalCount;
|
||||
|
||||
private Long accountId;
|
||||
private String loginId;
|
||||
private String username;
|
||||
private LocalDateTime baseDate;
|
||||
private Long menuId;
|
||||
private String menuName;
|
||||
|
||||
public AuditList(LocalDateTime baseDate, int readCount, int cudCount, int printCount, int downloadCount, Long totalCount){
|
||||
this.baseDate = baseDate;
|
||||
this.readCount = readCount;
|
||||
this.cudCount = cudCount;
|
||||
this.printCount = printCount;
|
||||
this.downloadCount = downloadCount;
|
||||
this.totalCount = totalCount;
|
||||
}
|
||||
}
|
||||
|
||||
@Schema(name = "AuditDetail", description = "감사 로그 상세")
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
public static class AuditDetail {
|
||||
private Long logId;
|
||||
private LocalDateTime logDateTime;
|
||||
private EventType eventType;
|
||||
private LogDetail detail;
|
||||
|
||||
private String userName;
|
||||
private String loginId;
|
||||
private String menuName;
|
||||
}
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@AllArgsConstructor
|
||||
public static class LogDetail{
|
||||
String serviceName;
|
||||
String parentMenuName;
|
||||
String menuName;
|
||||
String menuUrl;
|
||||
String menuDescription;
|
||||
int sortOrder;
|
||||
boolean used;
|
||||
}
|
||||
|
||||
@Schema(name = "LogDailySearchReq", description = "일자별 로그 검색 요청")
|
||||
@Getter
|
||||
@Setter
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public static class DailySearchReq {
|
||||
|
||||
private LocalDate startDate;
|
||||
private LocalDate endDate;
|
||||
|
||||
// 일자별 로그 검색 조건
|
||||
private LocalDate logDate;
|
||||
|
||||
// 페이징 파라미터
|
||||
private int page = 0;
|
||||
private int size = 20;
|
||||
private String sort;
|
||||
|
||||
public Pageable toPageable() {
|
||||
if (sort != null && !sort.isEmpty()) {
|
||||
String[] sortParams = sort.split(",");
|
||||
String property = sortParams[0];
|
||||
Sort.Direction direction =
|
||||
sortParams.length > 1 ? Sort.Direction.fromString(sortParams[1]) : Sort.Direction.ASC;
|
||||
return PageRequest.of(page, size, Sort.by(direction, property));
|
||||
}
|
||||
return PageRequest.of(page, size);
|
||||
}
|
||||
}
|
||||
|
||||
@Schema(name = "MenuUserSearchReq", description = "메뉴별,사용자별 로그 검색 요청")
|
||||
@Getter
|
||||
@Setter
|
||||
@NoArgsConstructor
|
||||
public static class MenuUserSearchReq {
|
||||
|
||||
// 메뉴별, 사용자별 로그 검색 조건
|
||||
private String searchValue;
|
||||
private String menuUid;
|
||||
private Long userUid; //menuId, userUid 조회
|
||||
|
||||
// 페이징 파라미터
|
||||
private int page = 0;
|
||||
private int size = 20;
|
||||
private String sort;
|
||||
|
||||
public MenuUserSearchReq(String searchValue, String menuUid, Long userUid, int page, int size, String sort) {
|
||||
this.searchValue = searchValue;
|
||||
this.menuUid = menuUid;
|
||||
this.page = page;
|
||||
this.size = size;
|
||||
this.sort = sort;
|
||||
}
|
||||
|
||||
public Pageable toPageable() {
|
||||
if (sort != null && !sort.isEmpty()) {
|
||||
String[] sortParams = sort.split(",");
|
||||
String property = sortParams[0];
|
||||
Sort.Direction direction =
|
||||
sortParams.length > 1 ? Sort.Direction.fromString(sortParams[1]) : Sort.Direction.ASC;
|
||||
return PageRequest.of(page, size, Sort.by(direction, property));
|
||||
}
|
||||
return PageRequest.of(page, size);
|
||||
}
|
||||
}
|
||||
}
|
||||
121
src/main/java/com/kamco/cd/kamcoback/log/dto/ErrorLogDto.java
Normal file
121
src/main/java/com/kamco/cd/kamcoback/log/dto/ErrorLogDto.java
Normal file
@@ -0,0 +1,121 @@
|
||||
package com.kamco.cd.kamcoback.log.dto;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import com.kamco.cd.kamcoback.common.utils.interfaces.JsonFormatDttm;
|
||||
import com.kamco.cd.kamcoback.config.enums.EnumType;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
import org.springframework.data.domain.PageRequest;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.data.domain.Sort;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.ZonedDateTime;
|
||||
|
||||
public class ErrorLogDto {
|
||||
|
||||
@Schema(name = "ErrorLogBasic", description = "에러로그 기본 정보")
|
||||
@Getter
|
||||
public static class Basic {
|
||||
|
||||
@JsonIgnore
|
||||
private final Long id;
|
||||
private final String requestId;
|
||||
private final EventType errorType;
|
||||
private final LogErrorLevel errorLevel;
|
||||
private final String errorCode;
|
||||
private final String errorMessage;
|
||||
private final String stackTrace;
|
||||
private final Long handlerUid;
|
||||
|
||||
@JsonFormatDttm
|
||||
private final ZonedDateTime handledDttm;
|
||||
|
||||
@JsonFormatDttm
|
||||
private final ZonedDateTime createdDttm;
|
||||
|
||||
public Basic(
|
||||
Long id,
|
||||
String requestId,
|
||||
EventType errorType,
|
||||
LogErrorLevel errorLevel,
|
||||
String errorCode,
|
||||
String errorMessage,
|
||||
String stackTrace,
|
||||
Long handlerUid,
|
||||
ZonedDateTime handledDttm,
|
||||
ZonedDateTime createdDttm) {
|
||||
this.id = id;
|
||||
this.requestId = requestId;
|
||||
this.errorType = errorType;
|
||||
this.errorLevel = errorLevel;
|
||||
this.errorCode = errorCode;
|
||||
this.errorMessage = errorMessage;
|
||||
this.stackTrace = stackTrace;
|
||||
this.handlerUid = handlerUid;
|
||||
this.handledDttm = handledDttm;
|
||||
this.createdDttm = createdDttm;
|
||||
}
|
||||
}
|
||||
|
||||
@Schema(name = "ErrorSearchReq", description = "에러로그 검색 요청")
|
||||
@Getter
|
||||
@Setter
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public static class ErrorSearchReq {
|
||||
|
||||
LogErrorLevel errorLevel;
|
||||
EventType eventType;
|
||||
LocalDate startDate;
|
||||
LocalDate endDate;
|
||||
|
||||
// 페이징 파라미터
|
||||
private int page = 0;
|
||||
private int size = 20;
|
||||
private String sort;
|
||||
|
||||
public ErrorSearchReq(LogErrorLevel errorLevel, EventType eventType, LocalDate startDate, LocalDate endDate, int page, int size) {
|
||||
this.errorLevel = errorLevel;
|
||||
this.eventType = eventType;
|
||||
this.startDate = startDate;
|
||||
this.endDate = endDate;
|
||||
this.page = page;
|
||||
this.size = size;
|
||||
}
|
||||
|
||||
public Pageable toPageable() {
|
||||
if (sort != null && !sort.isEmpty()) {
|
||||
String[] sortParams = sort.split(",");
|
||||
String property = sortParams[0];
|
||||
Sort.Direction direction =
|
||||
sortParams.length > 1 ? Sort.Direction.fromString(sortParams[1]) : Sort.Direction.ASC;
|
||||
return PageRequest.of(page, size, Sort.by(direction, property));
|
||||
}
|
||||
return PageRequest.of(page, size);
|
||||
}
|
||||
}
|
||||
|
||||
public enum LogErrorLevel implements EnumType {
|
||||
WARNING("Warning"),
|
||||
ERROR("Error"),
|
||||
CRITICAL("Critical");
|
||||
|
||||
private final String desc;
|
||||
|
||||
LogErrorLevel(String desc) {
|
||||
this.desc = desc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getId() { return name(); }
|
||||
|
||||
@Override
|
||||
public String getText() { return desc; }
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package com.kamco.cd.kamcoback.log.dto;
|
||||
|
||||
import com.kamco.cd.kamcoback.config.enums.EnumType;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
public enum EventStatus implements EnumType {
|
||||
SUCCESS("이벤트 결과 성공"),
|
||||
FAILED("이벤트 결과 실패");
|
||||
|
||||
private final String desc;
|
||||
|
||||
@Override
|
||||
public String getId() { return name(); }
|
||||
|
||||
@Override
|
||||
public String getText() { return desc; }
|
||||
}
|
||||
25
src/main/java/com/kamco/cd/kamcoback/log/dto/EventType.java
Normal file
25
src/main/java/com/kamco/cd/kamcoback/log/dto/EventType.java
Normal file
@@ -0,0 +1,25 @@
|
||||
package com.kamco.cd.kamcoback.log.dto;
|
||||
|
||||
import com.kamco.cd.kamcoback.config.enums.EnumType;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
public enum EventType implements EnumType {
|
||||
CREATE("생성"),
|
||||
READ("조회"),
|
||||
UPDATE("수정"),
|
||||
DELETE("삭제"),
|
||||
DOWNLOAD("다운로드"),
|
||||
PRINT("출력"),
|
||||
OTHER("기타");
|
||||
|
||||
private final String desc;
|
||||
|
||||
@Override
|
||||
public String getId() { return name(); }
|
||||
|
||||
@Override
|
||||
public String getText() { return desc; }
|
||||
}
|
||||
Reference in New Issue
Block a user