@@ -46,6 +46,8 @@ public class UserService {
4646
4747 private final ImageFileValidator imageFileValidator ;
4848
49+ private static final String DEFAULT_PROFILE_IMAGE_URL = "https://nconb-assets.s3.ap-northeast-2.amazonaws.com/users/profile/ncb.png" ;
50+
4951 // 내 정보 조회
5052 @ Transactional (readOnly = true )
5153 public UserResponse getMyInfo (User user ) {
@@ -56,12 +58,14 @@ public UserResponse getMyInfo(User user) {
5658 // 회원 가입(로컬)
5759 public User createLocalUser (SignupRequest req , String encodedPassword ) {
5860
61+ String profileImage = defaultProfileImage (req .getProfileImage ());
62+
5963 User user = User .builder ()
6064 .email (req .getEmail ())
6165 .nickname (req .getNickname ())
6266 .password (encodedPassword )
6367 .birth (LocalDate .parse (req .getBirth ()))
64- .profileImage (req . getProfileImage () )
68+ .profileImage (profileImage )
6569 .socialType (SocialType .LOCAL )
6670 .socialId (null )
6771 .build ();
@@ -82,6 +86,8 @@ public User createSocialUser(
8286 String socialId
8387 ) {
8488
89+ profileImage = defaultProfileImage (profileImage );
90+
8591 User user = User .builder ()
8692 .email (email )
8793 .nickname (nickname )
@@ -147,7 +153,7 @@ public String updateProfileImage(User user, MultipartFile file) {
147153
148154 // 기존 이미지 즉시 삭제
149155 // TODO: 추후 지연 삭제 스케줄러로 리팩토링
150- if (oldImageUrl != null ) {
156+ if (oldImageUrl != null && ! isDefaultProfileImage ( oldImageUrl ) ) {
151157 try {
152158 fileStorageService .delete (oldImageUrl );
153159 } catch (Exception e ) {
@@ -268,4 +274,14 @@ public UserPublicResponse getUserById(Long userId) {
268274
269275 return UserPublicResponse .from (user );
270276 }
277+
278+ private String defaultProfileImage (String profileImage ) {
279+ return profileImage != null
280+ ? profileImage
281+ : DEFAULT_PROFILE_IMAGE_URL ;
282+ }
283+
284+ private boolean isDefaultProfileImage (String imageUrl ) {
285+ return DEFAULT_PROFILE_IMAGE_URL .equals (imageUrl );
286+ }
271287}
0 commit comments