From 9b5e279de86a7e98d8fe65916e2b3e25707221ae Mon Sep 17 00:00:00 2001 From: soohyeon Date: Tue, 8 Oct 2024 23:23:42 +0900 Subject: [PATCH] refactor --- src/main/kotlin/org/meogo/domain/user/domain/User.kt | 6 ++---- .../org/meogo/domain/user/service/ModifyUserInfoService.kt | 4 ++-- 2 files changed, 4 insertions(+), 6 deletions(-) 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)