-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
47 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 6 additions & 0 deletions
6
src/main/kotlin/com/example/onui/domain/user/exception/ThemeNotFoundException.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
package com.example.onui.domain.user.exception | ||
|
||
import com.example.onui.global.config.error.data.ErrorCode | ||
import com.example.onui.global.config.error.exception.BusinessException | ||
|
||
object ThemeNotFoundException : BusinessException(ErrorCode.THEME_NOT_FOUND) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 9 additions & 0 deletions
9
src/main/kotlin/com/example/onui/domain/user/presentation/dto/request/ChangeRequest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package com.example.onui.domain.user.presentation.dto.request | ||
|
||
import javax.validation.constraints.NotBlank | ||
|
||
data class ChangeRequest( | ||
|
||
@field:NotBlank(message = "theme๊ฐ null์ผ ์ ์์ต๋๋ค.") | ||
val theme: String | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 16 additions & 9 deletions
25
src/main/kotlin/com/example/onui/domain/user/service/UserServiceImpl.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,40 @@ | ||
package com.example.onui.domain.user.service | ||
|
||
import com.example.onui.domain.user.entity.User | ||
import com.example.onui.domain.user.exception.ThemeNotFoundException | ||
import com.example.onui.domain.user.presentation.dto.response.UserProfileResponse | ||
import com.example.onui.domain.user.repository.ThemeRepository | ||
import com.example.onui.domain.user.repository.UserRepository | ||
import com.example.onui.global.common.facade.UserFacade | ||
import org.springframework.data.repository.findByIdOrNull | ||
import org.springframework.stereotype.Service | ||
import org.springframework.transaction.annotation.Transactional | ||
|
||
@Service | ||
@Transactional(readOnly = true) | ||
class UserServiceImpl( | ||
private val userRepository: UserRepository, | ||
private val userFacade: UserFacade | ||
private val userFacade: UserFacade, | ||
private val themeRepository: ThemeRepository | ||
) : UserService { | ||
|
||
@Transactional | ||
override fun rename(name: String): UserProfileResponse { | ||
|
||
val user = userFacade.getCurrentUser() | ||
|
||
return userRepository.save( | ||
User( | ||
user.sub, | ||
name, | ||
user.theme, | ||
user.id | ||
) | ||
).toResponse() | ||
return userRepository.save(User(user.sub, name, user.theme, user.id)).toResponse() | ||
} | ||
|
||
override fun getProfile(): UserProfileResponse = userFacade.getCurrentUser().toResponse() | ||
|
||
@Transactional | ||
override fun changeTheme(themeId: String): UserProfileResponse { | ||
|
||
val user = userFacade.getCurrentUser() | ||
|
||
val theme = themeRepository.findByIdOrNull(themeId) ?: throw ThemeNotFoundException | ||
|
||
return userRepository.save(User(user.sub, user.name, theme, user.id, user.role)).toResponse() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters