Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

profileUrl을 pathVariable에서 RequestBody로 받도록 수정 #74

Merged
merged 1 commit into from
Nov 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@ import org.springframework.http.HttpStatus
import org.springframework.http.ResponseEntity
import org.springframework.web.bind.annotation.PathVariable
import org.springframework.web.bind.annotation.PostMapping
import org.springframework.web.bind.annotation.RequestBody
import org.springframework.web.bind.annotation.RequestMapping
import org.springframework.web.bind.annotation.RestController
import team.themoment.gsmNetworking.common.manager.AuthenticatedUserManager
import team.themoment.gsmNetworking.domain.user.dto.ProfileUrlRegistrationDto
import team.themoment.gsmNetworking.domain.user.service.ProfileUrlRegistrationService

@RestController
Expand All @@ -16,10 +18,10 @@ class UserController(
private val profileUrlRegistrationService: ProfileUrlRegistrationService
) {

@PostMapping("/profile/{profileUrl}")
fun profileUrlRegistration(@PathVariable profileUrl: String): ResponseEntity<Void> {
@PostMapping("/profile-url")
fun profileUrlRegistration(@RequestBody dto: ProfileUrlRegistrationDto): ResponseEntity<Void> {
val authenticationId = authenticatedUserManager.getName()
profileUrlRegistrationService.execute(authenticationId, profileUrl)
profileUrlRegistrationService.execute(authenticationId, dto)
return ResponseEntity.status(HttpStatus.CREATED).build()
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package team.themoment.gsmNetworking.domain.user.dto

data class ProfileUrlRegistrationDto(
val profileUrl: String?
)
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import org.springframework.stereotype.Service
import org.springframework.transaction.annotation.Transactional
import team.themoment.gsmNetworking.common.exception.ExpectedException
import team.themoment.gsmNetworking.domain.user.domain.User
import team.themoment.gsmNetworking.domain.user.dto.ProfileUrlRegistrationDto
import team.themoment.gsmNetworking.domain.user.repository.UserRepository

@Service
Expand All @@ -13,14 +14,14 @@ class ProfileUrlRegistrationService(
private val userRepository: UserRepository
) {

fun execute(authenticationId: Long, profileUrl: String) {
fun execute(authenticationId: Long, dto: ProfileUrlRegistrationDto) {
val user = userRepository.findByAuthenticationId(authenticationId)
?: throw ExpectedException("user를 찾을 수 없습니다.", HttpStatus.NOT_FOUND)

profileUrlRegistered(user, profileUrl)
profileUrlRegistered(user, dto.profileUrl)
}

fun profileUrlRegistered(user: User, profileUrl: String) {
fun profileUrlRegistered(user: User, profileUrl: String?) {
val userUpdatedProfileUrl = User(
user.userId,
user.authenticationId,
Expand Down