Skip to content

Commit

Permalink
fix: 회원 프로필이 없는 경우에 예외 처리 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
jschoi-96 committed Apr 11, 2024
1 parent 3058986 commit aa65fc3
Showing 1 changed file with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package balancetalk.module.member.dto;

import balancetalk.module.file.domain.File;
import balancetalk.module.member.domain.Member;
import io.swagger.v3.oas.annotations.media.Schema;
import com.fasterxml.jackson.annotation.JsonFormat;
Expand All @@ -8,6 +9,7 @@
import lombok.Data;

import java.time.LocalDateTime;
import java.util.Optional;

@Data
@Builder
Expand All @@ -33,8 +35,11 @@ public class ProfileResponse {
private int level;

public static ProfileResponse fromEntity(Member member) {
String profileImageUrl = Optional.ofNullable(member.getProfilePhoto())
.map(File::getUrl)
.orElse(null);
return ProfileResponse.builder()
.profileImageUrl(member.getProfilePhoto().getUrl())
.profileImageUrl(profileImageUrl)
.nickname(member.getNickname())
.createdAt(member.getCreatedAt())
.postsCount(member.getPostCount())
Expand Down

0 comments on commit aa65fc3

Please sign in to comment.