Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ public class UserService {

private final ImageFileValidator imageFileValidator;

private static final String DEFAULT_PROFILE_IMAGE_URL = "https://nconb-assets.s3.ap-northeast-2.amazonaws.com/users/profile/ncb.png";

// 내 정보 조회
@Transactional(readOnly = true)
public UserResponse getMyInfo(User user) {
Expand All @@ -56,12 +58,14 @@ public UserResponse getMyInfo(User user) {
// 회원 가입(로컬)
public User createLocalUser(SignupRequest req, String encodedPassword) {

String profileImage = defaultProfileImage(req.getProfileImage());

User user = User.builder()
.email(req.getEmail())
.nickname(req.getNickname())
.password(encodedPassword)
.birth(LocalDate.parse(req.getBirth()))
.profileImage(req.getProfileImage())
.profileImage(profileImage)
.socialType(SocialType.LOCAL)
.socialId(null)
.build();
Expand All @@ -82,6 +86,8 @@ public User createSocialUser(
String socialId
) {

profileImage = defaultProfileImage(profileImage);

User user = User.builder()
.email(email)
.nickname(nickname)
Expand Down Expand Up @@ -147,7 +153,7 @@ public String updateProfileImage(User user, MultipartFile file) {

// 기존 이미지 즉시 삭제
// TODO: 추후 지연 삭제 스케줄러로 리팩토링
if (oldImageUrl != null) {
if (oldImageUrl != null && !isDefaultProfileImage(oldImageUrl)) {
try {
fileStorageService.delete(oldImageUrl);
} catch (Exception e) {
Expand Down Expand Up @@ -268,4 +274,14 @@ public UserPublicResponse getUserById(Long userId) {

return UserPublicResponse.from(user);
}

private String defaultProfileImage(String profileImage) {
return profileImage != null
? profileImage
: DEFAULT_PROFILE_IMAGE_URL;
}

private boolean isDefaultProfileImage(String imageUrl) {
return DEFAULT_PROFILE_IMAGE_URL.equals(imageUrl);
}
}