kmbin92_2025081101 #1

Merged
sohot8653 merged 9 commits from kmbin92_2025081101 into main 2025-08-13 10:42:57 +09:00
75 changed files with 28766 additions and 72 deletions
Showing only changes of commit d1bf1dd477 - Show all commits

View File

@@ -44,14 +44,4 @@ public class Member extends BaseEntity {
@Column(name = "last_login_at") @Column(name = "last_login_at")
private LocalDateTime lastLoginAt; private LocalDateTime lastLoginAt;
/**
* 엔티티 저장 후 실행되는 메서드
* createdOid와 updatedOid를 자기 자신의 oid로 설정
*/
@PostPersist
protected void onPostPersist() {
if (this.getCreatedOid() == null) {
this.setCreatedOid(this.getOid());
}
}
} }

View File

@@ -17,6 +17,8 @@ import org.springframework.transaction.annotation.Transactional;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import static com.bio.bio_backend.global.utils.OidUtil.generateOid;
@Service @Service
@RequiredArgsConstructor @RequiredArgsConstructor
@Slf4j @Slf4j
@@ -52,6 +54,10 @@ public class MemberServiceImpl implements MemberService {
.password(bCryptPasswordEncoder.encode(memberDTO.getPassword())) .password(bCryptPasswordEncoder.encode(memberDTO.getPassword()))
.role(MemberRole.getDefault()) .role(MemberRole.getDefault())
.build(); .build();
Long oid = generateOid();
member.setOid(oid);
member.setCreatedOid(oid);
Member savedMember = memberRepository.save(member); Member savedMember = memberRepository.save(member);

View File

@@ -6,10 +6,11 @@ import lombok.Setter;
import org.springframework.data.annotation.CreatedDate; import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.annotation.LastModifiedDate; import org.springframework.data.annotation.LastModifiedDate;
import org.springframework.data.jpa.domain.support.AuditingEntityListener; import org.springframework.data.jpa.domain.support.AuditingEntityListener;
import com.bio.bio_backend.global.utils.OidUtil;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import static com.bio.bio_backend.global.utils.OidUtil.generateOid;
/** /**
* 모든 엔티티가 상속받는 기본 엔티티 클래스 * 모든 엔티티가 상속받는 기본 엔티티 클래스
* 공통 필드들을 정의하고 JPA Auditing을 지원합니다. * 공통 필드들을 정의하고 JPA Auditing을 지원합니다.
@@ -40,14 +41,7 @@ public abstract class BaseEntity {
@PrePersist @PrePersist
protected void onCreate() { protected void onCreate() {
LocalDateTime now = LocalDateTime.now(); if(this.oid == null) this.oid = generateOid();
this.oid = OidUtil.generateOid(); if(this.createdOid != null && this.updatedOid == null) this.updatedOid = this.createdOid;
this.createdAt = now;
this.updatedAt = now;
}
@PreUpdate
protected void onUpdate() {
this.updatedAt = LocalDateTime.now();
} }
} }