-
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.
Merge branch 'feat/security' of https://github.com/wafflestudio/22-5-…
…team7-server into feat/security
- Loading branch information
Showing
7 changed files
with
53 additions
and
48 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
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
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
16 changes: 5 additions & 11 deletions
16
src/main/kotlin/com/toyProject7/karrot/review/controller/ReviewController.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,36 +1,30 @@ | ||
package com.toyProject7.karrot.review.controller | ||
|
||
import com.toyProject7.karrot.review.service.ReviewService | ||
import com.toyProject7.karrot.user.AuthUser | ||
import com.toyProject7.karrot.user.controller.User | ||
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.RestController | ||
import java.net.URLDecoder | ||
|
||
@RestController | ||
class ReviewController( | ||
private val reviewService: ReviewService, | ||
) { | ||
@PostMapping("/api/{sellerNickname}/review") | ||
@PostMapping("/api/review/post") | ||
fun createReview( | ||
@RequestBody request: ReviewCreateRequest, | ||
@PathVariable sellerNickname: String, | ||
@AuthUser user: User, | ||
): ResponseEntity<ReviewCreateResponse> { | ||
// Decode the sellerNickname | ||
val decodedSellerNickname = URLDecoder.decode(sellerNickname, "UTF-8") | ||
|
||
val review = reviewService.createReview(decodedSellerNickname, user.nickname, request.content, request.location) | ||
val review = reviewService.createReview(request) | ||
return ResponseEntity.status(201).body(review) | ||
} | ||
} | ||
|
||
data class ReviewCreateRequest( | ||
val content: String, | ||
val location: String, | ||
val isWritedByBuyer: Boolean, | ||
val sellerId: String, | ||
val buyerId: String, | ||
) | ||
|
||
typealias ReviewCreateResponse = Review |
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