Skip to content

Commit

Permalink
feat: userId header에서 QueryString으로 변경 (#34)
Browse files Browse the repository at this point in the history
  • Loading branch information
eogus2513 authored Mar 15, 2023
1 parent 2df4c92 commit d630c4d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
package com.xquare.authorization.v1authorizationservice.authority.accessmanagement.handler

import com.xquare.authorization.domain.authority.useraccessmanagement.api.AccessManagementService
import com.xquare.authorization.domain.authority.useraccessmanagement.api.dtos.AuthorityListByTypeResponse
import com.xquare.authorization.v1authorizationservice.configuration.validate.BadRequestException
import com.xquare.authorization.v1authorizationservice.configuration.validate.RequestBodyValidator
import java.net.URI
import java.util.UUID
import kotlinx.coroutines.reactor.awaitSingle
import org.springframework.stereotype.Component
import org.springframework.web.reactive.function.server.ServerRequest
import org.springframework.web.reactive.function.server.ServerResponse
import org.springframework.web.reactive.function.server.bodyToMono
import org.springframework.web.reactive.function.server.bodyValueAndAwait
import org.springframework.web.reactive.function.server.buildAndAwait
import org.springframework.web.reactive.function.server.queryParamOrNull
import java.net.URI
import java.util.*

@Component
class AccessManagementHandler(
Expand All @@ -30,10 +33,10 @@ class AccessManagementHandler(
return ServerResponse.ok().bodyValueAndAwait(authorityList)
}

suspend fun handleGetAuthorityListByType(serverRequest: ServerRequest): ServerResponse{
val userId = serverRequest.headers().firstHeader("Request-User-Id")
val type = serverRequest.pathVariable("type")
val authorityList = accessManagementService.getUserAuthorityListByType(UUID.fromString(userId), type)
suspend fun handleGetAuthorityListByType(serverRequest: ServerRequest): ServerResponse {
val userId = UUID.fromString(serverRequest.pathVariable("userId"))
val type = serverRequest.queryParamOrNull("type") ?: throw BadRequestException("Type Not Found")
val authorityList = accessManagementService.getUserAuthorityListByType(userId, type)
return ServerResponse.ok().bodyValueAndAwait(authorityList)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ class AccessManagementRouter(
"/authorities/access-management".nest {
POST("/basic", accessManagementHandler::createUserBaseAccessManagement)
GET("/{userId}", accessManagementHandler::handleGetAuthorityList)
GET("/type/{type}", accessManagementHandler::handleGetAuthorityListByType)
GET("/type/{userId}", accessManagementHandler::handleGetAuthorityListByType)
DELETE("/basic/{userId}", accessManagementHandler::handleDeleteBaseAccessManagement)
}
}
Expand Down

0 comments on commit d630c4d

Please sign in to comment.