diff --git a/src/main/kotlin/com/example/onui/domain/user/presentation/UserController.kt b/src/main/kotlin/com/example/onui/domain/user/presentation/UserController.kt index 7e8a1e3..03d29db 100644 --- a/src/main/kotlin/com/example/onui/domain/user/presentation/UserController.kt +++ b/src/main/kotlin/com/example/onui/domain/user/presentation/UserController.kt @@ -1,6 +1,7 @@ package com.example.onui.domain.user.presentation import com.example.onui.domain.user.presentation.dto.request.ChangeFilterRequest +import com.example.onui.domain.user.presentation.dto.request.ChangeProfileThemeRequest import com.example.onui.domain.user.presentation.dto.request.ChangeThemeRequest import com.example.onui.domain.user.presentation.dto.request.RenameRequest import com.example.onui.domain.user.presentation.dto.response.ThemeResponse @@ -26,6 +27,12 @@ class UserController( @GetMapping("/profile") fun getProfile(): UserProfileResponse = userService.getProfile() + @PatchMapping("/profile") + fun changeProfileTheme( + @RequestBody @Valid + req: ChangeProfileThemeRequest + ): UserProfileResponse = userService.changeProfileTheme(req.profileTheme!!) + @PatchMapping("/theme") fun changeTheme( @RequestBody @Valid diff --git a/src/main/kotlin/com/example/onui/domain/user/presentation/dto/request/ChangeProfileThemeRequest.kt b/src/main/kotlin/com/example/onui/domain/user/presentation/dto/request/ChangeProfileThemeRequest.kt new file mode 100644 index 0000000..b43526b --- /dev/null +++ b/src/main/kotlin/com/example/onui/domain/user/presentation/dto/request/ChangeProfileThemeRequest.kt @@ -0,0 +1,9 @@ +package com.example.onui.domain.user.presentation.dto.request + +import javax.validation.constraints.NotBlank + +data class ChangeProfileThemeRequest( + + @field:NotBlank(message = "profile_theme가 null일 수 없습니다.") + val profileTheme: String? +) diff --git a/src/main/kotlin/com/example/onui/domain/user/service/UserService.kt b/src/main/kotlin/com/example/onui/domain/user/service/UserService.kt index 1b553db..af49e74 100644 --- a/src/main/kotlin/com/example/onui/domain/user/service/UserService.kt +++ b/src/main/kotlin/com/example/onui/domain/user/service/UserService.kt @@ -16,4 +16,6 @@ interface UserService { fun changeFilter(onFiltering: Boolean): UserProfileResponse fun getTheme(): ThemeResponse + + fun changeProfileTheme(profileTheme: String): UserProfileResponse } \ No newline at end of file diff --git a/src/main/kotlin/com/example/onui/domain/user/service/UserServiceImpl.kt b/src/main/kotlin/com/example/onui/domain/user/service/UserServiceImpl.kt index fed19eb..1c9c9f8 100644 --- a/src/main/kotlin/com/example/onui/domain/user/service/UserServiceImpl.kt +++ b/src/main/kotlin/com/example/onui/domain/user/service/UserServiceImpl.kt @@ -90,4 +90,21 @@ class UserServiceImpl( } override fun getTheme() = ThemeResponse(userFacade.getCurrentUser().theme.id) + + @Transactional + override fun changeProfileTheme(profileTheme: String): UserProfileResponse { + val user = userFacade.getCurrentUser() + + return userRepository.save( + User( + user.sub, + user.name, + profileTheme, + user.theme, + user.id, + user.role, + user.onFiltering + ) + ).toResponse() + } } \ No newline at end of file