Skip to content

Commit

Permalink
🔧 changed all {nickname} endpoints to decode the nickname parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
jafacode committed Jan 26, 2025
1 parent d150723 commit c2d7b3c
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import org.springframework.http.ResponseEntity
import org.springframework.web.bind.annotation.PathVariable
import org.springframework.web.bind.annotation.PutMapping
import org.springframework.web.bind.annotation.RestController
import java.net.URLDecoder

@RestController
class MannerController(
Expand All @@ -15,7 +16,10 @@ class MannerController(
@PathVariable nickname: String,
@PathVariable mannerType: MannerType,
): ResponseEntity<String> {
mannerService.increaseMannerCount(nickname, mannerType)
// Decode the nickname
val decodedNickname = URLDecoder.decode(nickname, "UTF-8")

mannerService.increaseMannerCount(decodedNickname, mannerType)
return ResponseEntity.noContent().build()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import org.springframework.web.bind.annotation.PutMapping
import org.springframework.web.bind.annotation.RequestBody
import org.springframework.web.bind.annotation.RequestParam
import org.springframework.web.bind.annotation.RestController
import java.net.URLDecoder

@RestController
class ProfileController(
Expand All @@ -37,7 +38,10 @@ class ProfileController(
fun getProfile(
@PathVariable nickname: String,
): ResponseEntity<ProfileResponse> {
val profile = profileService.getProfile(nickname)
// Decode nickname
val decodedNickname = URLDecoder.decode(nickname, "UTF-8")

val profile = profileService.getProfile(decodedNickname)
return ResponseEntity.ok(profile)
}

Expand All @@ -46,7 +50,10 @@ class ProfileController(
@PathVariable nickname: String,
@RequestParam articleId: Long,
): ResponseEntity<List<Item>> {
val itemList: List<Item> = profileService.getProfileSells(nickname, articleId)
// Decode nickname
val decodedNickname = URLDecoder.decode(nickname, "UTF-8")

val itemList: List<Item> = profileService.getProfileSells(decodedNickname, articleId)
return ResponseEntity.ok(itemList)
}

Expand All @@ -63,7 +70,10 @@ class ProfileController(
fun getManners(
@PathVariable nickname: String,
): ResponseEntity<MannersResponse> {
val manners = profileService.getManner(nickname)
// Decode nickname
val decodedNickname = URLDecoder.decode(nickname, "UTF-8")

val manners = profileService.getManner(decodedNickname)
return ResponseEntity.ok(manners)
}

Expand All @@ -72,7 +82,10 @@ class ProfileController(
@PathVariable nickname: String,
@RequestParam("reviewId") reviewId: Long,
): ResponseEntity<ReviewsResponse> {
val reviews = profileService.getPreviousReviews(nickname, reviewId)
// Decode nickname
val decodedNickname = URLDecoder.decode(nickname, "UTF-8")

val reviews = profileService.getPreviousReviews(decodedNickname, reviewId)
return ResponseEntity.ok(reviews)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ 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.RestController
import java.net.URLDecoder

@RestController
class ReviewController(
Expand All @@ -19,7 +20,10 @@ class ReviewController(
@PathVariable sellerNickname: String,
@AuthUser user: User,
): ResponseEntity<ReviewCreateResponse> {
val review = reviewService.createReview(sellerNickname, user.nickname, request.content, request.location)
// Decode the sellerNickname
val decodedSellerNickname = URLDecoder.decode(sellerNickname, "UTF-8")

val review = reviewService.createReview(decodedSellerNickname, user.nickname, request.content, request.location)
return ResponseEntity.status(201).body(review)
}
}
Expand Down

0 comments on commit c2d7b3c

Please sign in to comment.