Skip to content

Commit

Permalink
refactor :: requestBody 삭제
Browse files Browse the repository at this point in the history
  • Loading branch information
4mjeo committed Feb 15, 2024
1 parent 2091d0f commit 8fc30ce
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@ import com.example.v1oauthauthorizationservice.infrastructure.oauth2.presentatio
import com.example.v1oauthauthorizationservice.infrastructure.oauth2.presentation.dto.response.RegisterClientResponse
import com.example.v1oauthauthorizationservice.infrastructure.oauth2.presentation.dto.response.ClientsResponse
import com.example.v1oauthauthorizationservice.infrastructure.oauth2.presentation.dto.response.UpdateClientResponse
import com.example.v1oauthauthorizationservice.infrastructure.user.repository.dtos.UserInformationDto
import java.util.UUID

interface OAuthApi {
fun getClient(request: RegisterClientRequest): ClientsResponse
fun getClient(): ClientsResponse
fun registerClient(request: RegisterClientRequest): RegisterClientResponse
fun updateClient(clientId: String, request: UpdateClientRequest): UpdateClientResponse
fun regenerateSecret(clientId: String): RegenerateSecretResponse
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ import com.example.v1oauthauthorizationservice.domain.security.spi.SecuritySpi
import com.example.v1oauthauthorizationservice.infrastructure.configuration.oauth2.exceptions.RegisteredClientAlreadyExistsException
import com.example.v1oauthauthorizationservice.infrastructure.oauth2.presentation.dto.request.RegisterClientRequest
import com.example.v1oauthauthorizationservice.infrastructure.oauth2.presentation.dto.request.UpdateClientRequest
import com.example.v1oauthauthorizationservice.infrastructure.oauth2.presentation.dto.response.RegisterClientResponse
import com.example.v1oauthauthorizationservice.infrastructure.oauth2.presentation.dto.response.ClientsResponse
import com.example.v1oauthauthorizationservice.infrastructure.oauth2.presentation.dto.response.RegenerateSecretResponse
import com.example.v1oauthauthorizationservice.infrastructure.oauth2.presentation.dto.response.RegisterClientResponse
import com.example.v1oauthauthorizationservice.infrastructure.oauth2.presentation.dto.response.UpdateClientResponse
import org.springframework.stereotype.Component
import org.springframework.transaction.annotation.Transactional
Expand All @@ -20,7 +20,7 @@ class OAuthApiImpl(
private val securitySpi: SecuritySpi
) : OAuthApi {

override fun getClient(request: RegisterClientRequest): ClientsResponse {
override fun getClient(): ClientsResponse {
val userId = securitySpi.getCurrentUserId()
return ClientsResponse(
registeredClientSpi.getByUserId(userId)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,27 +3,24 @@ package com.example.v1oauthauthorizationservice.infrastructure.oauth2.presentati
import com.example.v1oauthauthorizationservice.domain.oauth.api.OAuthApi
import com.example.v1oauthauthorizationservice.infrastructure.oauth2.presentation.dto.request.RegisterClientRequest
import com.example.v1oauthauthorizationservice.infrastructure.oauth2.presentation.dto.request.UpdateClientRequest
import com.example.v1oauthauthorizationservice.infrastructure.oauth2.presentation.dto.response.ClientsResponse
import com.example.v1oauthauthorizationservice.infrastructure.oauth2.presentation.dto.response.RegenerateSecretResponse
import com.example.v1oauthauthorizationservice.infrastructure.oauth2.presentation.dto.response.RegisterClientResponse
import com.example.v1oauthauthorizationservice.infrastructure.oauth2.presentation.dto.response.ClientsResponse
import com.example.v1oauthauthorizationservice.infrastructure.oauth2.presentation.dto.response.UpdateClientResponse
import org.springframework.web.bind.annotation.GetMapping
import org.springframework.web.bind.annotation.PatchMapping
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 com.example.v1oauthauthorizationservice.infrastructure.user.repository.dtos.UserInformationDto
import com.example.v1oauthauthorizationservice.infrastructure.user.security.AuthDetailsService
import org.springframework.web.bind.annotation.*

@RestController
@RequestMapping("/oauth2")
class OAuthController(
private val OAuthApi: OAuthApi
private val OAuthApi: OAuthApi,
private val authDetailsService: AuthDetailsService
) {

@GetMapping("/client")
fun getClient(@RequestBody request: RegisterClientRequest): ClientsResponse {
return OAuthApi.getClient(request)
fun getClient(): ClientsResponse {
return OAuthApi.getClient()
}

@PostMapping("/client")
Expand All @@ -40,4 +37,9 @@ class OAuthController(
fun regenerateSecret(@PathVariable("client-id") clientId: String): RegenerateSecretResponse {
return OAuthApi.regenerateSecret(clientId)
}

@GetMapping("/userinfo/{account-id}")
fun getUserInfo(@PathVariable("account-id") accountId: String): UserInformationDto {
return authDetailsService.getUserInformation(accountId)
}
}

0 comments on commit 8fc30ce

Please sign in to comment.