diff --git a/build.gradle b/build.gradle index 9d06bd3..855551a 100644 --- a/build.gradle +++ b/build.gradle @@ -5,7 +5,7 @@ plugins { } group = 'com.fhsh.daitda' -version = '0.1.3-SNAPSHOT' +version = '0.1.4-SNAPSHOT' java { toolchain { diff --git a/src/main/java/com/fhsh/daitda/domain/BaseUserEntity.java b/src/main/java/com/fhsh/daitda/domain/BaseUserEntity.java index 972a733..3851685 100644 --- a/src/main/java/com/fhsh/daitda/domain/BaseUserEntity.java +++ b/src/main/java/com/fhsh/daitda/domain/BaseUserEntity.java @@ -7,40 +7,33 @@ import org.springframework.data.annotation.CreatedBy; import org.springframework.data.annotation.LastModifiedBy; import org.springframework.data.jpa.domain.support.AuditingEntityListener; -import org.springframework.util.StringUtils; import java.time.LocalDateTime; +import java.util.UUID; @Getter @MappedSuperclass @EntityListeners(AuditingEntityListener.class) public abstract class BaseUserEntity extends BaseEntity { - private static final int AUDITOR_MAX_LENGTH = 45; - @CreatedBy - @Column(length = AUDITOR_MAX_LENGTH, updatable = false) - protected String createdBy; + @Column(updatable = false) + protected UUID createdBy; @LastModifiedBy - @Column(length = AUDITOR_MAX_LENGTH) - protected String updatedBy; + protected UUID updatedBy; - @Column(length = AUDITOR_MAX_LENGTH) - protected String deletedBy; + protected UUID deletedBy; // Soft Delete 구현 - protected void delete(String deletedBy) { + public void delete(UUID deletedBy) { // 중복 삭제로 인해 삭제 관련 필드가 업데이트되는 상황을 방지 if (isDeleted()) { return; } - - validateAuditorLength(deletedBy); - - // 삭제자가 없으면 SYSTEM 삭제로 간주 - this.updatedBy = StringUtils.hasText(deletedBy) ? deletedBy : "SYSTEM"; - this.deletedBy = StringUtils.hasText(deletedBy) ? deletedBy : "SYSTEM"; + + this.updatedBy = deletedBy; + this.deletedBy = deletedBy; this.updatedAt = LocalDateTime.now(); this.deletedAt = LocalDateTime.now(); @@ -50,23 +43,16 @@ public boolean isDeleted() { return this.deletedAt != null; } - public void restore(String restoredBy) { + // 삭제 복구 + public void restore(UUID restoredBy) { if (!isDeleted()) { return; } - validateAuditorLength(restoredBy); - - this.updatedBy = StringUtils.hasText(restoredBy) ? restoredBy : "SYSTEM"; + this.updatedBy = restoredBy; this.deletedBy = null; this.updatedAt = LocalDateTime.now(); this.deletedAt = null; } - - private void validateAuditorLength(String auditor) { - if (auditor != null && auditor.length() > AUDITOR_MAX_LENGTH) { - throw new IllegalArgumentException("auditor 정보는 %d자를 초과할 수 없습니다.".formatted(AUDITOR_MAX_LENGTH)); - } - } }