로그관리 API return 구조 수정

This commit is contained in:
2025-11-21 10:53:24 +09:00
parent f8001f2c58
commit d934f37488
6 changed files with 169 additions and 159 deletions

View File

@@ -266,10 +266,10 @@ public class GlobalExceptionHandler {
// TODO : 로그인 개발되면 이것도 연결해야 함 // TODO : 로그인 개발되면 이것도 연결해야 함
Long userid = Long.valueOf(Optional.ofNullable(ApiLogFunction.getUserId(request)).orElse("1")); Long userid = Long.valueOf(Optional.ofNullable(ApiLogFunction.getUserId(request)).orElse("1"));
// TODO : stackTrace limit 10줄? 확인 필요 // TODO : stackTrace limit 20줄? 확인 필요
String stackTraceStr = String stackTraceStr =
Arrays.stream(stackTrace) Arrays.stream(stackTrace)
.limit(10) // .limit(20)
.map(StackTraceElement::toString) .map(StackTraceElement::toString)
.collect(Collectors.joining("\n")); .collect(Collectors.joining("\n"));

View File

@@ -23,15 +23,15 @@ public class AuditLogApiController {
@Operation(summary = "일자별 로그 조회") @Operation(summary = "일자별 로그 조회")
@GetMapping("/daily") @GetMapping("/daily")
public ApiResponseDto<Page<AuditLogDto.AuditList>> getDailyLogs( public ApiResponseDto<Page<AuditLogDto.DailyAuditList>> getDailyLogs(
@RequestParam(required = false) LocalDate startDate, @RequestParam(required = false) LocalDate startDate,
@RequestParam(required = false) LocalDate endDate, @RequestParam(required = false) LocalDate endDate,
@RequestParam int page, @RequestParam int page,
@RequestParam(defaultValue = "20") int size) { @RequestParam(defaultValue = "20") int size) {
AuditLogDto.DailySearchReq searchReq = AuditLogDto.searchReq searchReq =
new AuditLogDto.DailySearchReq(startDate, endDate, null, page, size, "created_dttm,desc"); new AuditLogDto.searchReq(page, size, "created_dttm,desc");
Page<AuditLogDto.AuditList> result = Page<AuditLogDto.DailyAuditList> result =
auditLogCoreService.getLogByDaily(searchReq, startDate, endDate); auditLogCoreService.getLogByDaily(searchReq, startDate, endDate);
return ApiResponseDto.ok(result); return ApiResponseDto.ok(result);
@@ -39,13 +39,13 @@ public class AuditLogApiController {
@Operation(summary = "일자별 로그 상세") @Operation(summary = "일자별 로그 상세")
@GetMapping("/daily/result") @GetMapping("/daily/result")
public ApiResponseDto<Page<AuditLogDto.AuditDetail>> getDailyResultLogs( public ApiResponseDto<Page<AuditLogDto.DailyDetail>> getDailyResultLogs(
@RequestParam LocalDate logDate, @RequestParam LocalDate logDate,
@RequestParam int page, @RequestParam int page,
@RequestParam(defaultValue = "20") int size) { @RequestParam(defaultValue = "20") int size) {
AuditLogDto.DailySearchReq searchReq = AuditLogDto.searchReq searchReq =
new AuditLogDto.DailySearchReq(null, null, logDate, page, size, "created_dttm,desc"); new AuditLogDto.searchReq(page, size, "created_dttm,desc");
Page<AuditLogDto.AuditDetail> result = Page<AuditLogDto.DailyDetail> result =
auditLogCoreService.getLogByDailyResult(searchReq, logDate); auditLogCoreService.getLogByDailyResult(searchReq, logDate);
return ApiResponseDto.ok(result); return ApiResponseDto.ok(result);
@@ -53,26 +53,26 @@ public class AuditLogApiController {
@Operation(summary = "메뉴별 로그 조회") @Operation(summary = "메뉴별 로그 조회")
@GetMapping("/menu") @GetMapping("/menu")
public ApiResponseDto<Page<AuditLogDto.AuditList>> getMenuLogs( public ApiResponseDto<Page<AuditLogDto.MenuAuditList>> getMenuLogs(
@RequestParam(required = false) String searchValue, @RequestParam(required = false) String searchValue,
@RequestParam int page, @RequestParam int page,
@RequestParam(defaultValue = "20") int size) { @RequestParam(defaultValue = "20") int size) {
AuditLogDto.MenuUserSearchReq searchReq = AuditLogDto.searchReq searchReq =
new AuditLogDto.MenuUserSearchReq(searchValue, null, null, page, size, "created_dttm,desc"); new AuditLogDto.searchReq(page, size, "created_dttm,desc");
Page<AuditLogDto.AuditList> result = auditLogCoreService.getLogByMenu(searchReq, searchValue); Page<AuditLogDto.MenuAuditList> result = auditLogCoreService.getLogByMenu(searchReq, searchValue);
return ApiResponseDto.ok(result); return ApiResponseDto.ok(result);
} }
@Operation(summary = "메뉴별 로그 상세") @Operation(summary = "메뉴별 로그 상세")
@GetMapping("/menu/result") @GetMapping("/menu/result")
public ApiResponseDto<Page<AuditLogDto.AuditDetail>> getMenuResultLogs( public ApiResponseDto<Page<AuditLogDto.MenuDetail>> getMenuResultLogs(
@RequestParam String menuId, @RequestParam String menuId,
@RequestParam int page, @RequestParam int page,
@RequestParam(defaultValue = "20") int size) { @RequestParam(defaultValue = "20") int size) {
AuditLogDto.MenuUserSearchReq searchReq = AuditLogDto.searchReq searchReq =
new AuditLogDto.MenuUserSearchReq(null, menuId, null, page, size, "created_dttm,desc"); new AuditLogDto.searchReq(page, size, "created_dttm,desc");
Page<AuditLogDto.AuditDetail> result = Page<AuditLogDto.MenuDetail> result =
auditLogCoreService.getLogByMenuResult(searchReq, menuId); auditLogCoreService.getLogByMenuResult(searchReq, menuId);
return ApiResponseDto.ok(result); return ApiResponseDto.ok(result);
@@ -80,13 +80,13 @@ public class AuditLogApiController {
@Operation(summary = "사용자별 로그 조회") @Operation(summary = "사용자별 로그 조회")
@GetMapping("/account") @GetMapping("/account")
public ApiResponseDto<Page<AuditLogDto.AuditList>> getAccountLogs( public ApiResponseDto<Page<AuditLogDto.UserAuditList>> getAccountLogs(
@RequestParam(required = false) String searchValue, @RequestParam(required = false) String searchValue,
@RequestParam int page, @RequestParam int page,
@RequestParam(defaultValue = "20") int size) { @RequestParam(defaultValue = "20") int size) {
AuditLogDto.MenuUserSearchReq searchReq = AuditLogDto.searchReq searchReq =
new AuditLogDto.MenuUserSearchReq(searchValue, null, null, page, size, "created_dttm,desc"); new AuditLogDto.searchReq(page, size, "created_dttm,desc");
Page<AuditLogDto.AuditList> result = Page<AuditLogDto.UserAuditList> result =
auditLogCoreService.getLogByAccount(searchReq, searchValue); auditLogCoreService.getLogByAccount(searchReq, searchValue);
return ApiResponseDto.ok(result); return ApiResponseDto.ok(result);
@@ -94,13 +94,13 @@ public class AuditLogApiController {
@Operation(summary = "사용자별 로그 상세") @Operation(summary = "사용자별 로그 상세")
@GetMapping("/account/result") @GetMapping("/account/result")
public ApiResponseDto<Page<AuditLogDto.AuditDetail>> getAccountResultLogs( public ApiResponseDto<Page<AuditLogDto.UserDetail>> getAccountResultLogs(
@RequestParam Long userUid, @RequestParam Long userUid,
@RequestParam int page, @RequestParam int page,
@RequestParam(defaultValue = "20") int size) { @RequestParam(defaultValue = "20") int size) {
AuditLogDto.MenuUserSearchReq searchReq = AuditLogDto.searchReq searchReq =
new AuditLogDto.MenuUserSearchReq(null, null, userUid, page, size, "created_dttm,desc"); new AuditLogDto.searchReq(page, size, "created_dttm,desc");
Page<AuditLogDto.AuditDetail> result = Page<AuditLogDto.UserDetail> result =
auditLogCoreService.getLogByAccountResult(searchReq, userUid); auditLogCoreService.getLogByAccountResult(searchReq, userUid);
return ApiResponseDto.ok(result); return ApiResponseDto.ok(result);

View File

@@ -56,51 +56,104 @@ public class AuditLogDto {
} }
} }
@Schema(name = "AuditList", description = "감사 로그 목록") @Schema(name = "AuditCommon", description = "목록 공통")
@Getter @Getter
@AllArgsConstructor @AllArgsConstructor
public static class AuditList { public static class AuditCommon {
private int readCount; private int readCount;
private int cudCount; private int cudCount;
private int printCount; private int printCount;
private int downloadCount; private int downloadCount;
private Long totalCount; private Long totalCount;
}
private Long accountId; @Schema(name = "DailyAuditList", description = "일자별 목록")
private String loginId; @Getter
private String username; public static class DailyAuditList extends AuditCommon {
private LocalDateTime baseDate; private final String baseDate;
private Long menuId;
private String menuName;
public AuditList( public DailyAuditList(int readCount, int cudCount, int printCount, int downloadCount, Long totalCount, String baseDate) {
LocalDateTime baseDate, super(readCount, cudCount, printCount, downloadCount, totalCount);
int readCount,
int cudCount,
int printCount,
int downloadCount,
Long totalCount) {
this.baseDate = baseDate; this.baseDate = baseDate;
this.readCount = readCount;
this.cudCount = cudCount;
this.printCount = printCount;
this.downloadCount = downloadCount;
this.totalCount = totalCount;
} }
} }
@Schema(name = "AuditDetail", description = "감사 로그 상세") @Schema(name = "MenuAuditList", description = "메뉴별 목록")
@Getter
public static class MenuAuditList extends AuditCommon {
private final String menuId;
private final String menuName;
public MenuAuditList(String menuId, String menuName, int readCount, int cudCount, int printCount, int downloadCount, Long totalCount) {
super(readCount, cudCount, printCount, downloadCount, totalCount);
this.menuId = menuId;
this.menuName = menuName;
}
}
@Schema(name = "UserAuditList", description = "사용자별 목록")
@Getter
public static class UserAuditList extends AuditCommon {
private final Long accountId;
private final String loginId;
private final String username;
public UserAuditList(Long accountId, String loginId, String username, int readCount, int cudCount, int printCount, int downloadCount, Long totalCount) {
super(readCount, cudCount, printCount, downloadCount, totalCount);
this.accountId = accountId;
this.loginId = loginId;
this.username = username;
}
}
@Schema(name = "AuditDetail", description = "감사 로그 상세 공통")
@Getter @Getter
@AllArgsConstructor @AllArgsConstructor
public static class AuditDetail { public static class AuditDetail {
private Long logId; private Long logId;
private LocalDateTime logDateTime;
private EventType eventType; private EventType eventType;
private LogDetail detail; private LogDetail detail;
}
private String userName; @Schema(name = "DailyDetail", description = "일자별 로그 상세")
private String loginId; @Getter
private String menuName; public static class DailyDetail extends AuditDetail {
private final String userName;
private final String loginId;
private final String menuName;
public DailyDetail(Long logId, String userName, String loginId, String menuName, EventType eventType, LogDetail detail){
super(logId, eventType, detail);
this.userName = userName;
this.loginId = loginId;
this.menuName = menuName;
}
}
@Schema(name = "MenuDetail", description = "메뉴별 로그 상세")
@Getter
public static class MenuDetail extends AuditDetail {
private final String logDateTime;
private final String userName;
private final String loginId;
public MenuDetail(Long logId, String logDateTime, String userName, String loginId, EventType eventType, LogDetail detail){
super(logId, eventType, detail);
this.logDateTime = logDateTime;
this.userName = userName;
this.loginId = loginId;
}
}
@Schema(name = "UserDetail", description = "사용자별 로그 상세")
@Getter
public static class UserDetail extends AuditDetail {
private final String logDateTime;
private final String menuNm;
public UserDetail(Long logId, String logDateTime, String menuNm, EventType eventType, LogDetail detail){
super(logId, eventType, detail);
this.logDateTime = logDateTime;
this.menuNm = menuNm;
}
} }
@Getter @Getter
@@ -112,22 +165,16 @@ public class AuditLogDto {
String menuName; String menuName;
String menuUrl; String menuUrl;
String menuDescription; String menuDescription;
int sortOrder; Long sortOrder;
boolean used; boolean used;
} }
@Schema(name = "LogDailySearchReq", description = "일자별 로그 검색 요청") @Schema(name = "searchReq", description = "일자별 로그 검색 요청")
@Getter @Getter
@Setter @Setter
@NoArgsConstructor @NoArgsConstructor
@AllArgsConstructor @AllArgsConstructor
public static class DailySearchReq { public static class searchReq {
private LocalDate startDate;
private LocalDate endDate;
// 일자별 로그 검색 조건
private LocalDate logDate;
// 페이징 파라미터 // 페이징 파라미터
private int page = 0; private int page = 0;
@@ -145,41 +192,4 @@ public class AuditLogDto {
return PageRequest.of(page, size); 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);
}
}
} }

View File

@@ -13,7 +13,7 @@ import org.springframework.transaction.annotation.Transactional;
@RequiredArgsConstructor @RequiredArgsConstructor
@Transactional(readOnly = true) @Transactional(readOnly = true)
public class AuditLogCoreService public class AuditLogCoreService
implements BaseCoreService<AuditLogDto.AuditList, Long, AuditLogDto.DailySearchReq> { implements BaseCoreService<AuditLogDto.DailyAuditList, Long, AuditLogDto.searchReq> {
private final AuditLogRepository auditLogRepository; private final AuditLogRepository auditLogRepository;
@@ -21,42 +21,42 @@ public class AuditLogCoreService
public void remove(Long aLong) {} public void remove(Long aLong) {}
@Override @Override
public AuditLogDto.AuditList getOneById(Long aLong) { public AuditLogDto.DailyAuditList getOneById(Long aLong) {
return null; return null;
} }
@Override @Override
public Page<AuditLogDto.AuditList> search(AuditLogDto.DailySearchReq searchReq) { public Page<AuditLogDto.DailyAuditList> search(AuditLogDto.searchReq searchReq) {
return null; return null;
} }
public Page<AuditLogDto.AuditList> getLogByDaily( public Page<AuditLogDto.DailyAuditList> getLogByDaily(
AuditLogDto.DailySearchReq searchRange, LocalDate startDate, LocalDate endDate) { AuditLogDto.searchReq searchRange, LocalDate startDate, LocalDate endDate) {
return auditLogRepository.findLogByDaily(searchRange, startDate, endDate); return auditLogRepository.findLogByDaily(searchRange, startDate, endDate);
} }
public Page<AuditLogDto.AuditList> getLogByMenu( public Page<AuditLogDto.MenuAuditList> getLogByMenu(
AuditLogDto.MenuUserSearchReq searchRange, String searchValue) { AuditLogDto.searchReq searchRange, String searchValue) {
return auditLogRepository.findLogByMenu(searchRange, searchValue); return auditLogRepository.findLogByMenu(searchRange, searchValue);
} }
public Page<AuditLogDto.AuditList> getLogByAccount( public Page<AuditLogDto.UserAuditList> getLogByAccount(
AuditLogDto.MenuUserSearchReq searchRange, String searchValue) { AuditLogDto.searchReq searchRange, String searchValue) {
return auditLogRepository.findLogByAccount(searchRange, searchValue); return auditLogRepository.findLogByAccount(searchRange, searchValue);
} }
public Page<AuditLogDto.AuditDetail> getLogByDailyResult( public Page<AuditLogDto.DailyDetail> getLogByDailyResult(
AuditLogDto.DailySearchReq searchRange, LocalDate logDate) { AuditLogDto.searchReq searchRange, LocalDate logDate) {
return auditLogRepository.findLogByDailyResult(searchRange, logDate); return auditLogRepository.findLogByDailyResult(searchRange, logDate);
} }
public Page<AuditLogDto.AuditDetail> getLogByMenuResult( public Page<AuditLogDto.MenuDetail> getLogByMenuResult(
AuditLogDto.MenuUserSearchReq searchRange, String menuId) { AuditLogDto.searchReq searchRange, String menuId) {
return auditLogRepository.findLogByMenuResult(searchRange, menuId); return auditLogRepository.findLogByMenuResult(searchRange, menuId);
} }
public Page<AuditLogDto.AuditDetail> getLogByAccountResult( public Page<AuditLogDto.UserDetail> getLogByAccountResult(
AuditLogDto.MenuUserSearchReq searchRange, Long accountId) { AuditLogDto.searchReq searchRange, Long accountId) {
return auditLogRepository.findLogByAccountResult(searchRange, accountId); return auditLogRepository.findLogByAccountResult(searchRange, accountId);
} }
} }

View File

@@ -6,21 +6,21 @@ import org.springframework.data.domain.Page;
public interface AuditLogRepositoryCustom { public interface AuditLogRepositoryCustom {
Page<AuditLogDto.AuditList> findLogByDaily( Page<AuditLogDto.DailyAuditList> findLogByDaily(
AuditLogDto.DailySearchReq searchReq, LocalDate startDate, LocalDate endDate); AuditLogDto.searchReq searchReq, LocalDate startDate, LocalDate endDate);
Page<AuditLogDto.AuditList> findLogByMenu( Page<AuditLogDto.MenuAuditList> findLogByMenu(
AuditLogDto.MenuUserSearchReq searchReq, String searchValue); AuditLogDto.searchReq searchReq, String searchValue);
Page<AuditLogDto.AuditList> findLogByAccount( Page<AuditLogDto.UserAuditList> findLogByAccount(
AuditLogDto.MenuUserSearchReq searchReq, String searchValue); AuditLogDto.searchReq searchReq, String searchValue);
Page<AuditLogDto.AuditDetail> findLogByDailyResult( Page<AuditLogDto.DailyDetail> findLogByDailyResult(
AuditLogDto.DailySearchReq searchReq, LocalDate logDate); AuditLogDto.searchReq searchReq, LocalDate logDate);
Page<AuditLogDto.AuditDetail> findLogByMenuResult( Page<AuditLogDto.MenuDetail> findLogByMenuResult(
AuditLogDto.MenuUserSearchReq searchReq, String menuId); AuditLogDto.searchReq searchReq, String menuId);
Page<AuditLogDto.AuditDetail> findLogByAccountResult( Page<AuditLogDto.UserDetail> findLogByAccountResult(
AuditLogDto.MenuUserSearchReq searchReq, Long accountId); AuditLogDto.searchReq searchReq, Long accountId);
} }

View File

@@ -36,24 +36,25 @@ public class AuditLogRepositoryImpl extends QuerydslRepositorySupport
} }
@Override @Override
public Page<AuditLogDto.AuditList> findLogByDaily( public Page<AuditLogDto.DailyAuditList> findLogByDaily(
AuditLogDto.DailySearchReq searchReq, LocalDate startDate, LocalDate endDate) { AuditLogDto.searchReq searchReq, LocalDate startDate, LocalDate endDate) {
DateTimeExpression<LocalDateTime> groupDateTime = StringExpression groupDateTime =
Expressions.dateTimeTemplate( Expressions.stringTemplate("to_char({0}, 'YYYY-MM-DD')", auditLogEntity.createdDate);
LocalDateTime.class, "date_trunc('day', {0})", auditLogEntity.createdDate);
Pageable pageable = searchReq.toPageable(); Pageable pageable = searchReq.toPageable();
List<AuditLogDto.AuditList> foundContent = List<AuditLogDto.DailyAuditList> foundContent =
queryFactory queryFactory
.select( .select(
Projections.constructor( Projections.constructor(
AuditLogDto.AuditList.class, AuditLogDto.DailyAuditList.class,
groupDateTime.as("baseDate"),
readCount().as("readCount"), readCount().as("readCount"),
cudCount().as("cudCount"), cudCount().as("cudCount"),
printCount().as("printCount"), printCount().as("printCount"),
downloadCount().as("downloadCount"), downloadCount().as("downloadCount"),
auditLogEntity.count().as("totalCount"))) auditLogEntity.count().as("totalCount"),
groupDateTime.as("baseDate")
)
)
.from(auditLogEntity) .from(auditLogEntity)
.where(eventEndedAtBetween(startDate, endDate)) .where(eventEndedAtBetween(startDate, endDate))
.groupBy(groupDateTime) .groupBy(groupDateTime)
@@ -73,14 +74,14 @@ public class AuditLogRepositoryImpl extends QuerydslRepositorySupport
} }
@Override @Override
public Page<AuditLogDto.AuditList> findLogByMenu( public Page<AuditLogDto.MenuAuditList> findLogByMenu(
AuditLogDto.MenuUserSearchReq searchReq, String searchValue) { AuditLogDto.searchReq searchReq, String searchValue) {
Pageable pageable = searchReq.toPageable(); Pageable pageable = searchReq.toPageable();
List<AuditLogDto.AuditList> foundContent = List<AuditLogDto.MenuAuditList> foundContent =
queryFactory queryFactory
.select( .select(
Projections.constructor( Projections.constructor(
AuditLogDto.AuditList.class, AuditLogDto.MenuAuditList.class,
auditLogEntity.menuUid.as("menuId"), auditLogEntity.menuUid.as("menuId"),
menuEntity.menuNm.max().as("menuName"), menuEntity.menuNm.max().as("menuName"),
readCount().as("readCount"), readCount().as("readCount"),
@@ -113,14 +114,14 @@ public class AuditLogRepositoryImpl extends QuerydslRepositorySupport
} }
@Override @Override
public Page<AuditLogDto.AuditList> findLogByAccount( public Page<AuditLogDto.UserAuditList> findLogByAccount(
AuditLogDto.MenuUserSearchReq searchReq, String searchValue) { AuditLogDto.searchReq searchReq, String searchValue) {
Pageable pageable = searchReq.toPageable(); Pageable pageable = searchReq.toPageable();
List<AuditLogDto.AuditList> foundContent = List<AuditLogDto.UserAuditList> foundContent =
queryFactory queryFactory
.select( .select(
Projections.constructor( Projections.constructor(
AuditLogDto.AuditList.class, AuditLogDto.UserAuditList.class,
auditLogEntity.userUid.as("accountId"), auditLogEntity.userUid.as("accountId"),
userEntity.userId.as("loginId"), userEntity.userId.as("loginId"),
userEntity.userNm.as("username"), userEntity.userNm.as("username"),
@@ -152,8 +153,8 @@ public class AuditLogRepositoryImpl extends QuerydslRepositorySupport
} }
@Override @Override
public Page<AuditLogDto.AuditDetail> findLogByDailyResult( public Page<AuditLogDto.DailyDetail> findLogByDailyResult(
AuditLogDto.DailySearchReq searchReq, LocalDate logDate) { AuditLogDto.searchReq searchReq, LocalDate logDate) {
Pageable pageable = searchReq.toPageable(); Pageable pageable = searchReq.toPageable();
QMenuEntity parent = new QMenuEntity("parent"); QMenuEntity parent = new QMenuEntity("parent");
// 1depth menu name // 1depth menu name
@@ -170,11 +171,11 @@ public class AuditLogRepositoryImpl extends QuerydslRepositorySupport
.then(NULL_STRING) .then(NULL_STRING)
.otherwise(menuEntity.menuNm); .otherwise(menuEntity.menuNm);
List<AuditLogDto.AuditDetail> foundContent = List<AuditLogDto.DailyDetail> foundContent =
queryFactory queryFactory
.select( .select(
Projections.constructor( Projections.constructor(
AuditLogDto.AuditDetail.class, AuditLogDto.DailyDetail.class,
auditLogEntity.id.as("logId"), auditLogEntity.id.as("logId"),
userEntity.userNm.as("userName"), userEntity.userNm.as("userName"),
userEntity.userId.as("loginId"), userEntity.userId.as("loginId"),
@@ -217,8 +218,8 @@ public class AuditLogRepositoryImpl extends QuerydslRepositorySupport
} }
@Override @Override
public Page<AuditLogDto.AuditDetail> findLogByMenuResult( public Page<AuditLogDto.MenuDetail> findLogByMenuResult(
AuditLogDto.MenuUserSearchReq searchReq, String menuUid) { AuditLogDto.searchReq searchReq, String menuUid) {
Pageable pageable = searchReq.toPageable(); Pageable pageable = searchReq.toPageable();
QMenuEntity parent = new QMenuEntity("parent"); QMenuEntity parent = new QMenuEntity("parent");
// 1depth menu name // 1depth menu name
@@ -235,13 +236,13 @@ public class AuditLogRepositoryImpl extends QuerydslRepositorySupport
.then(NULL_STRING) .then(NULL_STRING)
.otherwise(menuEntity.menuNm); .otherwise(menuEntity.menuNm);
List<AuditLogDto.AuditDetail> foundContent = List<AuditLogDto.MenuDetail> foundContent =
queryFactory queryFactory
.select( .select(
Projections.constructor( Projections.constructor(
AuditLogDto.AuditDetail.class, AuditLogDto.MenuDetail.class,
auditLogEntity.id.as("logId"), auditLogEntity.id.as("logId"),
auditLogEntity.createdDate.as("logDateTime"), Expressions.stringTemplate("to_char({0}, 'YYYY-MM-DD')", auditLogEntity.createdDate).as("logDateTime"), //??
userEntity.userNm.as("userName"), userEntity.userNm.as("userName"),
userEntity.userId.as("loginId"), userEntity.userId.as("loginId"),
auditLogEntity.eventType.as("eventType"), auditLogEntity.eventType.as("eventType"),
@@ -282,8 +283,8 @@ public class AuditLogRepositoryImpl extends QuerydslRepositorySupport
} }
@Override @Override
public Page<AuditLogDto.AuditDetail> findLogByAccountResult( public Page<AuditLogDto.UserDetail> findLogByAccountResult(
AuditLogDto.MenuUserSearchReq searchReq, Long userUid) { AuditLogDto.searchReq searchReq, Long userUid) {
Pageable pageable = searchReq.toPageable(); Pageable pageable = searchReq.toPageable();
QMenuEntity parent = new QMenuEntity("parent"); QMenuEntity parent = new QMenuEntity("parent");
// 1depth menu name // 1depth menu name
@@ -300,13 +301,13 @@ public class AuditLogRepositoryImpl extends QuerydslRepositorySupport
.then(NULL_STRING) .then(NULL_STRING)
.otherwise(menuEntity.menuNm); .otherwise(menuEntity.menuNm);
List<AuditLogDto.AuditDetail> foundContent = List<AuditLogDto.UserDetail> foundContent =
queryFactory queryFactory
.select( .select(
Projections.constructor( Projections.constructor(
AuditLogDto.AuditDetail.class, AuditLogDto.UserDetail.class,
auditLogEntity.id.as("logId"), auditLogEntity.id.as("logId"),
auditLogEntity.createdDate.as("logDateTime"), Expressions.stringTemplate("to_char({0}, 'YYYY-MM-DD')", auditLogEntity.createdDate).as("logDateTime"),
menuEntity.menuNm.as("menuName"), menuEntity.menuNm.as("menuName"),
auditLogEntity.eventType.as("eventType"), auditLogEntity.eventType.as("eventType"),
Projections.constructor( Projections.constructor(
@@ -390,12 +391,11 @@ public class AuditLogRepositoryImpl extends QuerydslRepositorySupport
} }
private BooleanExpression eventEndedAtEqDate(LocalDate logDate) { private BooleanExpression eventEndedAtEqDate(LocalDate logDate) {
DateTimeExpression<LocalDateTime> eventEndedDate = StringExpression eventEndedDate =
Expressions.dateTimeTemplate( Expressions.stringTemplate("to_char({0}, 'YYYY-MM-DD')", auditLogEntity.createdDate);
LocalDateTime.class, "date_trunc('day', {0})", auditLogEntity.createdDate);
LocalDateTime comparisonDate = logDate.atStartOfDay(); LocalDateTime comparisonDate = logDate.atStartOfDay();
return eventEndedDate.eq(comparisonDate); return eventEndedDate.eq(comparisonDate.toString());
} }
private BooleanExpression menuUidEq(String menuUid) { private BooleanExpression menuUidEq(String menuUid) {