logTime 타입처리 수정

This commit is contained in:
2025-08-06 18:51:08 +09:00
parent 78f84bd7b8
commit 11c681e1ad
2 changed files with 26 additions and 4 deletions

View File

@@ -4,12 +4,16 @@ import com.caliverse.admin.domain.entity.FieldChange;
import com.caliverse.admin.domain.entity.HISTORYTYPEDETAIL;
import com.caliverse.admin.mongodb.entity.DBType;
import com.caliverse.admin.mongodb.entity.EDBOperationType;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import org.springframework.data.annotation.Id;
import org.springframework.data.mongodb.core.mapping.Field;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.time.format.DateTimeParseException;
import java.util.List;
@Getter
@@ -20,7 +24,7 @@ public class HistoryLogInfoBase implements historyLog {
@Id
private String id;
private DBType dbType;
private LocalDateTime timestamp;
private String timestamp;
private EDBOperationType operationType;
private HISTORYTYPEDETAIL historyType;
private String tableName;
@@ -30,6 +34,24 @@ public class HistoryLogInfoBase implements historyLog {
private String userId;
private String userIP;
public LocalDateTime getTimestampAsLocalDateTime() {
if (timestamp == null || timestamp.isEmpty()) {
return null;
}
try {
// 기본 형식 시도
return LocalDateTime.parse(timestamp, DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
} catch (DateTimeParseException e1) {
try {
// ISO 형식 시도
return LocalDateTime.parse(timestamp, DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss"));
} catch (DateTimeParseException e2) {
throw new IllegalArgumentException("Unable to parse timestamp: " + timestamp);
}
}
}
public HistoryLogInfoBase(DBType dbType,
LocalDateTime timestamp,
EDBOperationType operationType,
@@ -42,7 +64,7 @@ public class HistoryLogInfoBase implements historyLog {
String userIP
) {
this.dbType = dbType;
this.timestamp = timestamp;
this.timestamp = timestamp != null ? timestamp.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")) : null;
this.operationType = operationType;
this.historyType = historyType;
this.tableName = tableName;

View File

@@ -58,7 +58,7 @@ public class MigrationService {
CompletableFuture<String> logFuture = businessLogService.saveLog(
LogCategory.DYNAMODB,
LogStatus.SUCCESS,
history.getTimestamp(),
history.getTimestampAsLocalDateTime(),
"",
domain,
history.getUserId(),
@@ -96,7 +96,7 @@ public class MigrationService {
CompletableFuture<String> logFuture = businessLogService.saveLog(
LogCategory.DYNAMODB,
LogStatus.SUCCESS,
history.getTimestamp(),
history.getTimestampAsLocalDateTime(),
"",
domain,
history.getUserId(),