로그관리 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

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

View File

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

View File

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