feat: format error
This commit is contained in:
@@ -4,8 +4,8 @@ import com.kamco.cd.kamcoback.config.api.ApiResponseDto;
|
||||
import com.kamco.cd.kamcoback.log.dto.AuditLogDto;
|
||||
import com.kamco.cd.kamcoback.postgres.core.AuditLogCoreService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.responses.ApiResponse;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import java.time.LocalDate;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
@@ -13,8 +13,6 @@ import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.time.LocalDate;
|
||||
|
||||
@Tag(name = "감사 로그", description = "감사 로그 관리 API")
|
||||
@RequiredArgsConstructor
|
||||
@RestController
|
||||
@@ -26,18 +24,15 @@ public class AuditLogApiController {
|
||||
@Operation(summary = "일자별 로그 조회")
|
||||
@GetMapping("/daily")
|
||||
public ApiResponseDto<Page<AuditLogDto.AuditList>> getDailyLogs(
|
||||
@RequestParam(required = false) LocalDate startDate,
|
||||
@RequestParam(required = false) LocalDate endDate,
|
||||
@RequestParam int page,
|
||||
@RequestParam(defaultValue = "20") int size
|
||||
) {
|
||||
AuditLogDto.DailySearchReq searchReq = new AuditLogDto.DailySearchReq(startDate, endDate, null, page, size, "created_dttm,desc");
|
||||
@RequestParam(required = false) LocalDate startDate,
|
||||
@RequestParam(required = false) LocalDate endDate,
|
||||
@RequestParam int page,
|
||||
@RequestParam(defaultValue = "20") int size) {
|
||||
AuditLogDto.DailySearchReq searchReq =
|
||||
new AuditLogDto.DailySearchReq(startDate, endDate, null, page, size, "created_dttm,desc");
|
||||
|
||||
Page<AuditLogDto.AuditList> result = auditLogCoreService.getLogByDaily(
|
||||
searchReq,
|
||||
startDate,
|
||||
endDate
|
||||
);
|
||||
Page<AuditLogDto.AuditList> result =
|
||||
auditLogCoreService.getLogByDaily(searchReq, startDate, endDate);
|
||||
|
||||
return ApiResponseDto.ok(result);
|
||||
}
|
||||
@@ -45,83 +40,69 @@ public class AuditLogApiController {
|
||||
@Operation(summary = "일자별 로그 상세")
|
||||
@GetMapping("/daily/result")
|
||||
public ApiResponseDto<Page<AuditLogDto.AuditDetail>> getDailyResultLogs(
|
||||
@RequestParam LocalDate logDate,
|
||||
@RequestParam int page,
|
||||
@RequestParam(defaultValue = "20") int size
|
||||
) {
|
||||
AuditLogDto.DailySearchReq searchReq = new AuditLogDto.DailySearchReq(null, null, logDate, page, size, "created_dttm,desc");
|
||||
Page<AuditLogDto.AuditDetail> result = auditLogCoreService.getLogByDailyResult(
|
||||
searchReq,
|
||||
logDate
|
||||
);
|
||||
@RequestParam LocalDate logDate,
|
||||
@RequestParam int page,
|
||||
@RequestParam(defaultValue = "20") int size) {
|
||||
AuditLogDto.DailySearchReq searchReq =
|
||||
new AuditLogDto.DailySearchReq(null, null, logDate, page, size, "created_dttm,desc");
|
||||
Page<AuditLogDto.AuditDetail> result =
|
||||
auditLogCoreService.getLogByDailyResult(searchReq, logDate);
|
||||
|
||||
return ApiResponseDto.ok(result);
|
||||
}
|
||||
|
||||
@Operation(summary = "메뉴별 로그 조회")
|
||||
|
||||
@GetMapping("/menu")
|
||||
public ApiResponseDto<Page<AuditLogDto.AuditList>> getMenuLogs(
|
||||
@RequestParam(required = false) String searchValue,
|
||||
@RequestParam int page,
|
||||
@RequestParam(defaultValue = "20") int size
|
||||
) {
|
||||
AuditLogDto.MenuUserSearchReq searchReq = new AuditLogDto.MenuUserSearchReq(searchValue, null, null, page, size, "created_dttm,desc");
|
||||
Page<AuditLogDto.AuditList> result = auditLogCoreService.getLogByMenu(
|
||||
searchReq, searchValue
|
||||
);
|
||||
@RequestParam(required = false) String searchValue,
|
||||
@RequestParam int page,
|
||||
@RequestParam(defaultValue = "20") int size) {
|
||||
AuditLogDto.MenuUserSearchReq searchReq =
|
||||
new AuditLogDto.MenuUserSearchReq(searchValue, null, null, page, size, "created_dttm,desc");
|
||||
Page<AuditLogDto.AuditList> result = auditLogCoreService.getLogByMenu(searchReq, searchValue);
|
||||
|
||||
return ApiResponseDto.ok(result);
|
||||
}
|
||||
|
||||
@Operation(summary = "메뉴별 로그 상세")
|
||||
|
||||
@GetMapping("/menu/result")
|
||||
public ApiResponseDto<Page<AuditLogDto.AuditDetail>> getMenuResultLogs(
|
||||
@RequestParam String menuId,
|
||||
@RequestParam int page,
|
||||
@RequestParam(defaultValue = "20") int size
|
||||
) {
|
||||
AuditLogDto.MenuUserSearchReq searchReq = new AuditLogDto.MenuUserSearchReq(null, menuId, null, page, size, "created_dttm,desc");
|
||||
Page<AuditLogDto.AuditDetail> result = auditLogCoreService.getLogByMenuResult(
|
||||
searchReq,
|
||||
menuId
|
||||
);
|
||||
@RequestParam String menuId,
|
||||
@RequestParam int page,
|
||||
@RequestParam(defaultValue = "20") int size) {
|
||||
AuditLogDto.MenuUserSearchReq searchReq =
|
||||
new AuditLogDto.MenuUserSearchReq(null, menuId, null, page, size, "created_dttm,desc");
|
||||
Page<AuditLogDto.AuditDetail> result =
|
||||
auditLogCoreService.getLogByMenuResult(searchReq, menuId);
|
||||
|
||||
return ApiResponseDto.ok(result);
|
||||
}
|
||||
|
||||
@Operation(summary = "사용자별 로그 조회")
|
||||
|
||||
@GetMapping("/account")
|
||||
public ApiResponseDto<Page<AuditLogDto.AuditList>> getAccountLogs(
|
||||
@RequestParam(required = false) String searchValue,
|
||||
@RequestParam int page,
|
||||
@RequestParam(defaultValue = "20") int size
|
||||
) {
|
||||
AuditLogDto.MenuUserSearchReq searchReq = new AuditLogDto.MenuUserSearchReq(searchValue, null, null, page, size, "created_dttm,desc");
|
||||
Page<AuditLogDto.AuditList> result = auditLogCoreService.getLogByAccount(
|
||||
searchReq, searchValue
|
||||
);
|
||||
@RequestParam(required = false) String searchValue,
|
||||
@RequestParam int page,
|
||||
@RequestParam(defaultValue = "20") int size) {
|
||||
AuditLogDto.MenuUserSearchReq searchReq =
|
||||
new AuditLogDto.MenuUserSearchReq(searchValue, null, null, page, size, "created_dttm,desc");
|
||||
Page<AuditLogDto.AuditList> result =
|
||||
auditLogCoreService.getLogByAccount(searchReq, searchValue);
|
||||
|
||||
return ApiResponseDto.ok(result);
|
||||
}
|
||||
|
||||
@Operation(summary = "사용자별 로그 상세")
|
||||
|
||||
@GetMapping("/account/result")
|
||||
public ApiResponseDto<Page<AuditLogDto.AuditDetail>> getAccountResultLogs(
|
||||
@RequestParam Long userUid,
|
||||
@RequestParam int page,
|
||||
@RequestParam(defaultValue = "20") int size
|
||||
) {
|
||||
AuditLogDto.MenuUserSearchReq searchReq = new AuditLogDto.MenuUserSearchReq(null, null, userUid, page, size, "created_dttm,desc");
|
||||
Page<AuditLogDto.AuditDetail> result = auditLogCoreService.getLogByAccountResult(
|
||||
searchReq,
|
||||
userUid
|
||||
);
|
||||
@RequestParam Long userUid,
|
||||
@RequestParam int page,
|
||||
@RequestParam(defaultValue = "20") int size) {
|
||||
AuditLogDto.MenuUserSearchReq searchReq =
|
||||
new AuditLogDto.MenuUserSearchReq(null, null, userUid, page, size, "created_dttm,desc");
|
||||
Page<AuditLogDto.AuditDetail> result =
|
||||
auditLogCoreService.getLogByAccountResult(searchReq, userUid);
|
||||
|
||||
return ApiResponseDto.ok(result);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,25 +1,19 @@
|
||||
package com.kamco.cd.kamcoback.log;
|
||||
|
||||
import com.kamco.cd.kamcoback.config.api.ApiResponseDto;
|
||||
import com.kamco.cd.kamcoback.log.dto.AuditLogDto;
|
||||
import com.kamco.cd.kamcoback.log.dto.ErrorLogDto;
|
||||
import com.kamco.cd.kamcoback.log.dto.EventType;
|
||||
import com.kamco.cd.kamcoback.postgres.core.AuditLogCoreService;
|
||||
import com.kamco.cd.kamcoback.postgres.core.ErrorLogCoreService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import java.time.LocalDate;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.util.List;
|
||||
|
||||
@Tag(name = "에러 로그", description = "에러 로그 관리 API")
|
||||
@RequiredArgsConstructor
|
||||
@RestController
|
||||
@@ -29,17 +23,17 @@ public class ErrorLogApiController {
|
||||
private final ErrorLogCoreService errorLogCoreService;
|
||||
|
||||
@Operation(summary = "에러로그 조회")
|
||||
|
||||
@GetMapping("/error")
|
||||
public ApiResponseDto<Page<ErrorLogDto.Basic>> getErrorLogs(
|
||||
@RequestParam(required = false) ErrorLogDto.LogErrorLevel logErrorLevel,
|
||||
@RequestParam(required = false) EventType eventType,
|
||||
@RequestParam(required = false) LocalDate startDate,
|
||||
@RequestParam(required = false) LocalDate endDate,
|
||||
@RequestParam int page,
|
||||
@RequestParam(defaultValue = "20") int size
|
||||
) {
|
||||
ErrorLogDto.ErrorSearchReq searchReq = new ErrorLogDto.ErrorSearchReq(logErrorLevel, eventType, startDate, endDate, page, size, "created_dttm,desc");
|
||||
@RequestParam(required = false) ErrorLogDto.LogErrorLevel logErrorLevel,
|
||||
@RequestParam(required = false) EventType eventType,
|
||||
@RequestParam(required = false) LocalDate startDate,
|
||||
@RequestParam(required = false) LocalDate endDate,
|
||||
@RequestParam int page,
|
||||
@RequestParam(defaultValue = "20") int size) {
|
||||
ErrorLogDto.ErrorSearchReq searchReq =
|
||||
new ErrorLogDto.ErrorSearchReq(
|
||||
logErrorLevel, eventType, startDate, endDate, page, size, "created_dttm,desc");
|
||||
Page<ErrorLogDto.Basic> result = errorLogCoreService.findLogByError(searchReq);
|
||||
|
||||
return ApiResponseDto.ok(result);
|
||||
|
||||
@@ -3,6 +3,9 @@ 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 java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.ZonedDateTime;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
@@ -11,18 +14,13 @@ 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;
|
||||
@JsonIgnore private final Long id;
|
||||
private final Long userUid;
|
||||
private final EventType eventType;
|
||||
private final EventStatus eventStatus;
|
||||
@@ -32,30 +30,29 @@ public class AuditLogDto {
|
||||
private final String requestBody;
|
||||
private final Long errorLogUid;
|
||||
|
||||
@JsonFormatDttm
|
||||
private final ZonedDateTime createdDttm;
|
||||
@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;
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -76,7 +73,13 @@ public class AuditLogDto {
|
||||
private Long menuId;
|
||||
private String menuName;
|
||||
|
||||
public AuditList(LocalDateTime baseDate, int readCount, int cudCount, int printCount, int downloadCount, Long totalCount){
|
||||
public AuditList(
|
||||
LocalDateTime baseDate,
|
||||
int readCount,
|
||||
int cudCount,
|
||||
int printCount,
|
||||
int downloadCount,
|
||||
Long totalCount) {
|
||||
this.baseDate = baseDate;
|
||||
this.readCount = readCount;
|
||||
this.cudCount = cudCount;
|
||||
@@ -103,7 +106,7 @@ public class AuditLogDto {
|
||||
@Getter
|
||||
@Setter
|
||||
@AllArgsConstructor
|
||||
public static class LogDetail{
|
||||
public static class LogDetail {
|
||||
String serviceName;
|
||||
String parentMenuName;
|
||||
String menuName;
|
||||
@@ -152,14 +155,15 @@ public class AuditLogDto {
|
||||
// 메뉴별, 사용자별 로그 검색 조건
|
||||
private String searchValue;
|
||||
private String menuUid;
|
||||
private Long userUid; //menuId, userUid 조회
|
||||
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) {
|
||||
public MenuUserSearchReq(
|
||||
String searchValue, String menuUid, Long userUid, int page, int size, String sort) {
|
||||
this.searchValue = searchValue;
|
||||
this.menuUid = menuUid;
|
||||
this.page = page;
|
||||
|
||||
@@ -4,6 +4,8 @@ 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 java.time.LocalDate;
|
||||
import java.time.ZonedDateTime;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
@@ -12,18 +14,13 @@ 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;
|
||||
@JsonIgnore private final Long id;
|
||||
private final String requestId;
|
||||
private final EventType errorType;
|
||||
private final LogErrorLevel errorLevel;
|
||||
@@ -32,23 +29,21 @@ public class ErrorLogDto {
|
||||
private final String stackTrace;
|
||||
private final Long handlerUid;
|
||||
|
||||
@JsonFormatDttm
|
||||
private final ZonedDateTime handledDttm;
|
||||
@JsonFormatDttm private final ZonedDateTime handledDttm;
|
||||
|
||||
@JsonFormatDttm
|
||||
private final ZonedDateTime createdDttm;
|
||||
@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) {
|
||||
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;
|
||||
@@ -79,7 +74,13 @@ public class ErrorLogDto {
|
||||
private int size = 20;
|
||||
private String sort;
|
||||
|
||||
public ErrorSearchReq(LogErrorLevel errorLevel, EventType eventType, LocalDate startDate, LocalDate endDate, int page, int size) {
|
||||
public ErrorSearchReq(
|
||||
LogErrorLevel errorLevel,
|
||||
EventType eventType,
|
||||
LocalDate startDate,
|
||||
LocalDate endDate,
|
||||
int page,
|
||||
int size) {
|
||||
this.errorLevel = errorLevel;
|
||||
this.eventType = eventType;
|
||||
this.startDate = startDate;
|
||||
@@ -93,7 +94,7 @@ public class ErrorLogDto {
|
||||
String[] sortParams = sort.split(",");
|
||||
String property = sortParams[0];
|
||||
Sort.Direction direction =
|
||||
sortParams.length > 1 ? Sort.Direction.fromString(sortParams[1]) : Sort.Direction.ASC;
|
||||
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);
|
||||
@@ -112,10 +113,13 @@ public class ErrorLogDto {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getId() { return name(); }
|
||||
public String getId() {
|
||||
return name();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getText() { return desc; }
|
||||
public String getText() {
|
||||
return desc;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -13,8 +13,12 @@ public enum EventStatus implements EnumType {
|
||||
private final String desc;
|
||||
|
||||
@Override
|
||||
public String getId() { return name(); }
|
||||
public String getId() {
|
||||
return name();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getText() { return desc; }
|
||||
public String getText() {
|
||||
return desc;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,8 +18,12 @@ public enum EventType implements EnumType {
|
||||
private final String desc;
|
||||
|
||||
@Override
|
||||
public String getId() { return name(); }
|
||||
public String getId() {
|
||||
return name();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getText() { return desc; }
|
||||
public String getText() {
|
||||
return desc;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user