Skip to content

Commit

Permalink
feat: #17 API 성공 시 응답 형식으로 사용하는 BaseResponse 제거
Browse files Browse the repository at this point in the history
  • Loading branch information
Wo-ogie committed Jul 25, 2024
1 parent 73a544a commit d233e7a
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 40 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import com.routebox.routebox.application.auth.AppleLoginUseCase
import com.routebox.routebox.application.auth.KakaoLoginUseCase
import com.routebox.routebox.application.auth.dto.AppleLoginCommand
import com.routebox.routebox.application.auth.dto.KakaoLoginCommand
import com.routebox.routebox.controller.common.BaseResponse
import io.swagger.v3.oas.annotations.Operation
import io.swagger.v3.oas.annotations.media.Content
import io.swagger.v3.oas.annotations.responses.ApiResponse
Expand Down Expand Up @@ -32,9 +31,9 @@ class AuthController(
ApiResponse(responseCode = "400", description = "[10000] Kakao API 서버로부터 오류를 응답받은 경우.", content = [Content()]),
)
@PostMapping("/v1/auth/login/kakao")
fun kakaoLoginV1(@RequestBody @Valid request: KakaoLoginRequest): BaseResponse<LoginResponse> {
fun kakaoLoginV1(@RequestBody @Valid request: KakaoLoginRequest): LoginResponse {
val result = kakaoLoginUseCase(KakaoLoginCommand(request.kakaoAccessToken))
return BaseResponse.success(LoginResponse.from(result))
return LoginResponse.from(result)
}

@Operation(
Expand All @@ -47,8 +46,8 @@ class AuthController(
ApiResponse(responseCode = "401", description = "[10201] Id token이 유효하지 않은 경우", content = [Content()]),
)
@PostMapping("/v1/auth/login/apple")
fun appleLoginV1(@RequestBody @Valid request: AppleLoginRequest): BaseResponse<LoginResponse> {
fun appleLoginV1(@RequestBody @Valid request: AppleLoginRequest): LoginResponse {
val result = appleLoginUseCase(AppleLoginCommand(request.idToken))
return BaseResponse.success(LoginResponse.from(result))
return LoginResponse.from(result)
}
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package com.routebox.routebox.controller.user
import com.routebox.routebox.application.user.CheckNicknameAvailabilityUseCase
import com.routebox.routebox.application.user.UpdateUserInfoUseCase
import com.routebox.routebox.application.user.dto.UpdateUserInfoCommand
import com.routebox.routebox.controller.common.BaseResponse
import com.routebox.routebox.controller.user.dto.CheckNicknameAvailabilityResponse
import com.routebox.routebox.controller.user.dto.UpdateUserInfoRequest
import com.routebox.routebox.controller.user.dto.UserResponse
Expand Down Expand Up @@ -44,9 +43,9 @@ class UserController(
description = "이용 가능 여부를 확인할 닉네임. 닉네임은 한글, 영문, 숫자로 이루어진, 특수문자와 공백을 제외한 2~8 글자여야 합니다.",
example = "고작가",
) nickname: String,
): BaseResponse<CheckNicknameAvailabilityResponse> {
): CheckNicknameAvailabilityResponse {
val isAvailable = checkNicknameAvailabilityUseCase(nickname)
return BaseResponse.success(CheckNicknameAvailabilityResponse(nickname, isAvailable))
return CheckNicknameAvailabilityResponse(nickname, isAvailable)
}

@Operation(
Expand All @@ -63,7 +62,7 @@ class UserController(
fun updateUserInfo(
@AuthenticationPrincipal userPrincipal: UserPrincipal,
@RequestBody @Valid request: UpdateUserInfoRequest,
): BaseResponse<UserResponse> {
): UserResponse {
val updateUserInfo = updateUserInfoUseCase(
UpdateUserInfoCommand(
id = userPrincipal.userId,
Expand All @@ -73,6 +72,6 @@ class UserController(
introduction = request.introduction,
),
)
return BaseResponse.success(UserResponse.from(updateUserInfo))
return UserResponse.from(updateUserInfo)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,10 @@ class AuthControllerTest @Autowired constructor(
.contentType(MediaType.APPLICATION_JSON)
.content(mapper.writeValueAsString(KakaoLoginRequest(kakaoAccessToken))),
).andExpect(status().isOk)
.andExpect(jsonPath("$.result.isNew").value(expectedResult.isNew))
.andExpect(jsonPath("$.result.loginType").value(expectedResult.loginType.toString()))
.andExpect(jsonPath("$.result.accessToken.token").value(expectedResult.accessToken.token))
.andExpect(jsonPath("$.result.refreshToken.token").value(expectedResult.refreshToken.token))
.andExpect(jsonPath("$.isNew").value(expectedResult.isNew))
.andExpect(jsonPath("$.loginType").value(expectedResult.loginType.toString()))
.andExpect(jsonPath("$.accessToken.token").value(expectedResult.accessToken.token))
.andExpect(jsonPath("$.refreshToken.token").value(expectedResult.refreshToken.token))
then(kakaoLoginUseCase).should().invoke(KakaoLoginCommand(kakaoAccessToken))
verifyEveryMocksShouldHaveNoMoreInteractions()
}
Expand All @@ -80,10 +80,10 @@ class AuthControllerTest @Autowired constructor(
.contentType(MediaType.APPLICATION_JSON)
.content(mapper.writeValueAsString(AppleLoginRequest(appleIdToken))),
).andExpect(status().isOk)
.andExpect(jsonPath("$.result.isNew").value(expectedResult.isNew))
.andExpect(jsonPath("$.result.loginType").value(expectedResult.loginType.toString()))
.andExpect(jsonPath("$.result.accessToken.token").value(expectedResult.accessToken.token))
.andExpect(jsonPath("$.result.refreshToken.token").value(expectedResult.refreshToken.token))
.andExpect(jsonPath("$.isNew").value(expectedResult.isNew))
.andExpect(jsonPath("$.loginType").value(expectedResult.loginType.toString()))
.andExpect(jsonPath("$.accessToken.token").value(expectedResult.accessToken.token))
.andExpect(jsonPath("$.refreshToken.token").value(expectedResult.refreshToken.token))
then(appleLoginUseCase).should().invoke(AppleLoginCommand(appleIdToken))
verifyEveryMocksShouldHaveNoMoreInteractions()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ class UserControllerTest @Autowired constructor(
mvc.perform(
get("/api/v1/users/nickname/{nickname}/availability", nickname),
).andExpect(status().isOk)
.andExpect(jsonPath("$.result.nickname").value(nickname))
.andExpect(jsonPath("$.result.isAvailable").value(expectedResult))
.andExpect(jsonPath("$.nickname").value(nickname))
.andExpect(jsonPath("$.isAvailable").value(expectedResult))
then(checkNicknameAvailabilityUseCase).should().invoke(nickname)
verifyEveryMocksShouldHaveNoMoreInteractions()
}
Expand Down Expand Up @@ -92,10 +92,10 @@ class UserControllerTest @Autowired constructor(
.content(mapper.writeValueAsString(request))
.with(user(createUserPrincipal(userId))),
).andExpect(status().isOk)
.andExpect(jsonPath("$.result.id").value(expectedResult.id))
.andExpect(jsonPath("$.result.nickname").value(expectedResult.nickname))
.andExpect(jsonPath("$.result.gender").value(expectedResult.gender.toString()))
.andExpect(jsonPath("$.result.birthDay").value(expectedResult.birthDay.toString()))
.andExpect(jsonPath("$.id").value(expectedResult.id))
.andExpect(jsonPath("$.nickname").value(expectedResult.nickname))
.andExpect(jsonPath("$.gender").value(expectedResult.gender.toString()))
.andExpect(jsonPath("$.birthDay").value(expectedResult.birthDay.toString()))
then(updateUserInfoUseCase).should().invoke(command)
verifyEveryMocksShouldHaveNoMoreInteractions()
}
Expand Down

0 comments on commit d233e7a

Please sign in to comment.