logTime 타입처리 수정
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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(),
|
||||
|
||||
Reference in New Issue
Block a user