Skip to content

Commit

Permalink
🔀 :: (#95) feignBadRequest error 해결 (#229)
Browse files Browse the repository at this point in the history
* ♻️ :: feignBadRequest error 해결

* 🐛 :: 공지사항 알림 버그 해결

* ♻️ :: , 추가
  • Loading branch information
jyk1029 authored Jun 21, 2023
1 parent e847f4f commit d887a01
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ class NotificationDetailApiImpl(
postDetailSettingRepositorySpi.findAllUserIdByTopicAndIsActivated(topic, true)
}


val detailList = userIdList
.stream()
.map {
Expand All @@ -64,7 +63,6 @@ class NotificationDetailApiImpl(
content,
threadId,
)

}

override fun postNotification(userId: UUID, topic: String, content: String, threadId: String) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package io.github.v1servicenotification.domain.user.domain.repository

import io.github.v1servicenotification.detail.spi.PostDetailUserSpi
import io.github.v1servicenotification.infrastructure.feign.client.UserClient
import io.github.v1servicenotification.infrastructure.feign.client.dto.request.GetExcludeUserIdsRequest
import io.github.v1servicenotification.infrastructure.feign.client.dto.request.GetUserIdListRequest
import io.github.v1servicenotification.infrastructure.feign.error.FeignBadRequestException
import org.springframework.stereotype.Component
import java.util.UUID
Expand All @@ -12,12 +12,12 @@ class CustomPostDetailUserImpl(
private val userClient: UserClient
) : PostDetailUserSpi {
override fun getExcludeUserIdList(userIdList: List<UUID>): List<UUID> {
val userIdsRequest = GetExcludeUserIdsRequest(userIdList)
return userClient.getExcludeUserIdList(userIdsRequest).userIdList
val excludeUserIdList = GetUserIdListRequest(userIdList)
return userClient.getExcludeUserIdList(excludeUserIdList).userIdList
}

override fun getDeviceToken(userId: UUID): String {
val result = userClient.token(listOf(userId)).tokens
val result = userClient.token(GetUserIdListRequest(listOf(userId))).tokens

if (result.isEmpty()) {
throw FeignBadRequestException.EXCEPTION
Expand All @@ -26,6 +26,6 @@ class CustomPostDetailUserImpl(
}

override fun getDeviceTokenList(userIdList: List<UUID>): List<String> {
return userClient.token(userIdList).tokens
return userClient.token(GetUserIdListRequest(userIdList)).tokens
}
}
Original file line number Diff line number Diff line change
@@ -1,20 +1,18 @@
package io.github.v1servicenotification.infrastructure.feign.client

import io.github.v1servicenotification.infrastructure.feign.client.dto.request.GetExcludeUserIdsRequest
import io.github.v1servicenotification.infrastructure.feign.client.dto.request.GetUserIdListRequest
import io.github.v1servicenotification.infrastructure.feign.client.dto.response.TokenResponse
import io.github.v1servicenotification.infrastructure.feign.client.dto.response.UserIdListResponse
import org.springframework.cloud.openfeign.FeignClient
import org.springframework.web.bind.annotation.GetMapping
import org.springframework.web.bind.annotation.PostMapping
import org.springframework.web.bind.annotation.RequestBody
import org.springframework.web.bind.annotation.RequestParam
import java.util.UUID

@FeignClient(name = "UserClient", url = "\${service.scheme}://\${service.user.host}")
interface UserClient {

@GetMapping("/users/device-token")
fun token(@RequestParam("users") userList: List<UUID>): TokenResponse
@PostMapping("/users/device-token")
fun token(@RequestBody request: GetUserIdListRequest): TokenResponse

@GetMapping("/users/exclude")
fun getExcludeUserIdList(@RequestBody request: GetExcludeUserIdsRequest): UserIdListResponse
@PostMapping("/users/exclude")
fun getExcludeUserIdList(@RequestBody request: GetUserIdListRequest): UserIdListResponse
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ package io.github.v1servicenotification.infrastructure.feign.client.dto.request

import java.util.UUID

data class GetExcludeUserIdsRequest(
data class GetUserIdListRequest(
val userIdList: List<UUID>,
)
)

0 comments on commit d887a01

Please sign in to comment.