diff --git a/src/main/kotlin/org/meogo/domain/user/domain/User.kt b/src/main/kotlin/org/meogo/domain/user/domain/User.kt index dd9168f..44d96e2 100644 --- a/src/main/kotlin/org/meogo/domain/user/domain/User.kt +++ b/src/main/kotlin/org/meogo/domain/user/domain/User.kt @@ -27,12 +27,10 @@ class User( @Enumerated(EnumType.STRING) val role: UserRole ) : BaseUUIDEntity(id) { - fun updateProfile(name: String, enrolledSchool: Int, profile: String?): User { + fun updateProfile(name: String, enrolledSchool: Int, profile: String): User { this.name = name this.enrolledSchool = enrolledSchool - if (profile != null) { - this.profile = profile - } + this.profile = profile return this } } diff --git a/src/main/kotlin/org/meogo/domain/user/service/ModifyUserInfoService.kt b/src/main/kotlin/org/meogo/domain/user/service/ModifyUserInfoService.kt index 1d41cc1..57a0af6 100644 --- a/src/main/kotlin/org/meogo/domain/user/service/ModifyUserInfoService.kt +++ b/src/main/kotlin/org/meogo/domain/user/service/ModifyUserInfoService.kt @@ -24,8 +24,8 @@ class ModifyUserInfoService( fun execute(request: UserModifyRequest, file: MultipartFile?) { val user = userFacade.currentUser() ?: throw UserNotFoundException - if (file != null && user.profile != defaultImage) fileUtil.delete(user.profile, Path.USER) - val url = file?.let { fileUtil.upload(it, Path.USER) } + if (user.profile != defaultImage) fileUtil.delete(user.profile, Path.USER) + val url = file?.let { fileUtil.upload(it, Path.USER) } ?: defaultImage userRepository.save( user.updateProfile(request.name, request.enrolledSchool, url)