Skip to content

Commit

Permalink
refac: 필요없는 ResponseEntity 정리
Browse files Browse the repository at this point in the history
  • Loading branch information
korECM committed Aug 7, 2022
1 parent 628015e commit 3dd74b2
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 24 deletions.
6 changes: 2 additions & 4 deletions src/main/kotlin/zip/cafe/api/FeedController.kt
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package zip.cafe.api

import org.springframework.http.ResponseEntity
import org.springframework.http.ResponseEntity.ok
import org.springframework.web.bind.annotation.GetMapping
import org.springframework.web.bind.annotation.RequestParam
import org.springframework.web.bind.annotation.RestController
Expand All @@ -21,8 +19,8 @@ class FeedController(
@LoginUserId memberId: Long,
@RequestParam(required = false) minReviewId: Long?,
@RequestParam(required = false, defaultValue = "10") limit: Long
): ResponseEntity<ApiResponse<List<FeedInfo>>> {
): ApiResponse<List<FeedInfo>> {
val feeds = feedService.getReviewFeeds(memberId, minReviewIdInFeed = minReviewId, limit = limit)
return ok(success(feeds))
return success(feeds)
}
}
6 changes: 2 additions & 4 deletions src/main/kotlin/zip/cafe/api/HealthController.kt
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
package zip.cafe.api

import org.springframework.http.ResponseEntity
import org.springframework.http.ResponseEntity.ok
import org.springframework.web.bind.annotation.GetMapping
import org.springframework.web.bind.annotation.RestController

@RestController
class HealthController {

@GetMapping("/health")
fun health(): ResponseEntity<String> {
return ok("Hello")
fun health(): String {
return "Hello"
}
}
10 changes: 4 additions & 6 deletions src/main/kotlin/zip/cafe/api/LocalAuthController.kt
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package zip.cafe.api

import org.springframework.http.ResponseEntity
import org.springframework.http.ResponseEntity.ok
import org.springframework.web.bind.annotation.PostMapping
import org.springframework.web.bind.annotation.RequestBody
import org.springframework.web.bind.annotation.RequestMapping
Expand All @@ -21,16 +19,16 @@ class LocalAuthController(
) {

@PostMapping("/signUp")
fun signUp(@Valid @RequestBody request: LocalSignUpRequest): ResponseEntity<ApiResponse<LocalSignUpResponse>> {
fun signUp(@Valid @RequestBody request: LocalSignUpRequest): ApiResponse<LocalSignUpResponse> {
val registeredMemberId = localAuthService.signUp(request.toDto())
val token = authService.generateToken(registeredMemberId, Date())
return ok().body(success(LocalSignUpResponse(token)))
return success(LocalSignUpResponse(token))
}

@PostMapping("/signIn")
fun signIn(@Valid @RequestBody request: LocalSignInRequest): ResponseEntity<ApiResponse<LocalSignInResponse>> {
fun signIn(@Valid @RequestBody request: LocalSignInRequest): ApiResponse<LocalSignInResponse> {
val memberId = localAuthService.signIn(request.toDto())
val token = authService.generateToken(memberId, Date())
return ok().body(success(LocalSignInResponse(token)))
return success(LocalSignInResponse(token))
}
}
6 changes: 2 additions & 4 deletions src/main/kotlin/zip/cafe/api/MemberController.kt
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package zip.cafe.api

import org.springframework.http.ResponseEntity
import org.springframework.http.ResponseEntity.ok
import org.springframework.web.bind.annotation.PostMapping
import org.springframework.web.bind.annotation.RequestMapping
import org.springframework.web.bind.annotation.RequestParam
Expand All @@ -20,9 +18,9 @@ class MemberController(
@PostMapping("/nickname/duplicate")
fun nicknameDuplicationCheck(
@RequestParam nickname: String
): ResponseEntity<ApiResponse<CheckNicknameDuplicationResponse>> {
): ApiResponse<CheckNicknameDuplicationResponse> {
val isDuplicated = memberService.checkNicknameDuplication(nickname)
val response = CheckNicknameDuplicationResponse(isDuplicated)
return ok(success(response))
return success(response)
}
}
13 changes: 7 additions & 6 deletions src/main/kotlin/zip/cafe/api/MemberFollowController.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@ package zip.cafe.api

import org.springframework.http.HttpStatus.ACCEPTED
import org.springframework.http.HttpStatus.CREATED
import org.springframework.http.ResponseEntity
import org.springframework.http.ResponseEntity.status
import org.springframework.web.bind.annotation.PathVariable
import org.springframework.web.bind.annotation.PostMapping
import org.springframework.web.bind.annotation.ResponseStatus
import org.springframework.web.bind.annotation.RestController
import zip.cafe.api.dto.ApiResponse
import zip.cafe.api.dto.ApiResponse.Companion.success
Expand All @@ -17,15 +16,17 @@ class MemberFollowController(
private val memberFollowService: MemberFollowService
) {

@ResponseStatus(CREATED)
@PostMapping("/members/{targetMemberId}/follow")
fun follow(@LoginUserId loginMemberId: Long, @PathVariable targetMemberId: Long): ResponseEntity<ApiResponse<Nothing>> {
fun follow(@LoginUserId loginMemberId: Long, @PathVariable targetMemberId: Long): ApiResponse<Nothing> {
memberFollowService.follow(loginMemberId, targetMemberId)
return status(CREATED).body(success(null))
return success(null)
}

@ResponseStatus(ACCEPTED)
@PostMapping("/members/{targetMemberId}/unfollow")
fun unfollow(@LoginUserId loginMemberId: Long, @PathVariable targetMemberId: Long): ResponseEntity<ApiResponse<Nothing>> {
fun unfollow(@LoginUserId loginMemberId: Long, @PathVariable targetMemberId: Long): ApiResponse<Nothing> {
memberFollowService.unfollow(loginMemberId, targetMemberId)
return status(ACCEPTED).body(success(null))
return success(null)
}
}

0 comments on commit 3dd74b2

Please sign in to comment.