Skip to content

Commit 87dc12a

Browse files
committed
fix: 유저 프로필 조회 NPE 수정 및 updatePersonalInfo 트랜잭션 추가
1 parent f7540ee commit 87dc12a

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/main/java/guesthouse/user/service/UserService.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import guesthouse.certificate.repository.CertificateRepository;
55
import guesthouse.user.domain.model.User;
66
import guesthouse.user.domain.vo.Gender;
7+
import guesthouse.user.domain.vo.PersonalInfo;
78
import guesthouse.user.dto.ProfileDTO;
89
import guesthouse.user.exception.UserErrorCode;
910
import guesthouse.user.exception.UserException;
@@ -28,6 +29,7 @@ public User findById(Long id) {
2829
.orElseThrow(() -> new UserException(UserErrorCode.NOT_FOUND));
2930
}
3031

32+
@Transactional
3133
public void updatePersonalInfo(String name,
3234
String phoneNumber,
3335
LocalDate birthDate,
@@ -47,8 +49,9 @@ public ProfileDTO getProfile(Long userId) {
4749
boolean hasInReview = certificates.stream()
4850
.anyMatch(certificate -> certificate.getStatus().isInReview());
4951

52+
PersonalInfo personalInfo = user.getPersonalInfo();
5053
return new ProfileDTO(
51-
user.getPersonalInfo().getName(),
54+
personalInfo != null ? personalInfo.getName() : null,
5255
user.getProfileImageUrl(),
5356
isOwner,
5457
hasInReview

0 commit comments

Comments
 (0)