Skip to content

Commit

Permalink
⭐️ :: profile theme변경 API
Browse files Browse the repository at this point in the history
  • Loading branch information
gurdl0525 committed Nov 16, 2023
1 parent 32dbf22 commit 97819da
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand Down
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 ChangeProfileThemeRequest(

@field:NotBlank(message = "profile_theme가 null일 수 없습니다.")
val profileTheme: String?
)
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,6 @@ interface UserService {
fun changeFilter(onFiltering: Boolean): UserProfileResponse

fun getTheme(): ThemeResponse

fun changeProfileTheme(profileTheme: String): UserProfileResponse
}
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
}

0 comments on commit 97819da

Please sign in to comment.