From 65b60f4fb3cf31250ad1c227bb2a87e158949511 Mon Sep 17 00:00:00 2001 From: devxb Date: Mon, 6 Jan 2025 23:17:10 +0900 Subject: [PATCH] =?UTF-8?q?fix:=20=EA=B8=B8=EB=93=9C=EC=97=90=20=EC=9C=A0?= =?UTF-8?q?=EC=A0=80=EA=B0=80=20=ED=95=9C=EB=AA=85=EC=9D=BC=EB=95=8C=20?= =?UTF-8?q?=ED=8E=AB=EC=9D=B4=20=EB=B3=B4=EC=9D=B4=EC=A7=80=20=EC=95=8A?= =?UTF-8?q?=EB=8A=94=20=EB=B2=84=EA=B7=B8=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../org/gitanimals/guild/app/DrawGuildFacade.kt | 12 ++++++------ .../kotlin/org/gitanimals/guild/app/RenderApi.kt | 6 +++--- .../render/controller/InternalPersonaController.kt | 10 +++++----- ...naIdRequest.kt => UsernameAndPersonaIdRequest.kt} | 4 ++-- .../org/gitanimals/render/domain/UserRepository.kt | 4 ++-- .../org/gitanimals/render/domain/UserService.kt | 4 ++-- 6 files changed, 20 insertions(+), 20 deletions(-) rename src/main/kotlin/org/gitanimals/render/controller/request/{UserIdAndPersonaIdRequest.kt => UsernameAndPersonaIdRequest.kt} (53%) diff --git a/src/main/kotlin/org/gitanimals/guild/app/DrawGuildFacade.kt b/src/main/kotlin/org/gitanimals/guild/app/DrawGuildFacade.kt index 5f3cc41..6802229 100644 --- a/src/main/kotlin/org/gitanimals/guild/app/DrawGuildFacade.kt +++ b/src/main/kotlin/org/gitanimals/guild/app/DrawGuildFacade.kt @@ -43,19 +43,19 @@ class DrawGuildFacade( } private fun getRenderUsers(guild: Guild): List { - val userIdAndPersonaIdRequests = guild.getMembers().map { - RenderApi.UserIdAndPersonaIdRequest( + val usernameAndPersonaIdRequests = guild.getMembers().map { + RenderApi.UsernameAndPersonaIdRequest( personaId = it.personaId, - userId = it.userId, + username = it.name, ) - } + RenderApi.UserIdAndPersonaIdRequest( + } + RenderApi.UsernameAndPersonaIdRequest( personaId = guild.getLeaderPersonaId(), - userId = guild.getLeaderUserId(), + username = guild.getLeaderName(), ) return renderApi.getAllPersonasByUserIdsAndPersonaIds( internalSecret = internalSecret, - userIdAndPersonaIdRequests = userIdAndPersonaIdRequests, + usernameAndPersonaIdRequests = usernameAndPersonaIdRequests, ) } diff --git a/src/main/kotlin/org/gitanimals/guild/app/RenderApi.kt b/src/main/kotlin/org/gitanimals/guild/app/RenderApi.kt index 739a18b..bbb1ef1 100644 --- a/src/main/kotlin/org/gitanimals/guild/app/RenderApi.kt +++ b/src/main/kotlin/org/gitanimals/guild/app/RenderApi.kt @@ -14,7 +14,7 @@ interface RenderApi { @GetExchange("/internals/personas/all") fun getAllPersonasByUserIdsAndPersonaIds( @RequestHeader(INTERNAL_SECRET_KEY) internalSecret: String, - @RequestBody userIdAndPersonaIdRequests: List, + @RequestBody usernameAndPersonaIdRequests: List, ): List data class UserResponse( @@ -31,8 +31,8 @@ interface RenderApi { ) } - data class UserIdAndPersonaIdRequest( - val userId: Long, + data class UsernameAndPersonaIdRequest( + val username: String, val personaId: Long, ) diff --git a/src/main/kotlin/org/gitanimals/render/controller/InternalPersonaController.kt b/src/main/kotlin/org/gitanimals/render/controller/InternalPersonaController.kt index db55cc3..e28b562 100644 --- a/src/main/kotlin/org/gitanimals/render/controller/InternalPersonaController.kt +++ b/src/main/kotlin/org/gitanimals/render/controller/InternalPersonaController.kt @@ -5,7 +5,7 @@ import org.gitanimals.core.AuthorizationException import org.gitanimals.render.app.UserFacade import org.gitanimals.render.controller.request.AddMultiplyPersonaRequest import org.gitanimals.render.controller.request.AddPersonaRequest -import org.gitanimals.render.controller.request.UserIdAndPersonaIdRequest +import org.gitanimals.render.controller.request.UsernameAndPersonaIdRequest import org.gitanimals.render.controller.response.ErrorResponse import org.gitanimals.render.controller.response.PersonaResponse import org.gitanimals.render.controller.response.UserResponse @@ -86,14 +86,14 @@ class InternalPersonaController( @GetMapping("/internals/personas/all") @ResponseStatus(HttpStatus.OK) fun getAllPersonasByUserIdsAndPersonaIds( - @RequestBody userIdAndPersonaIdRequests: List + @RequestBody usernameAndPersonaIdRequests: List ): List { - val users = userService.findAllUsersByIdWithContributions( - userIdAndPersonaIdRequests.map { it.userId }.toSet() + val users = userService.findAllUsersByNameWithContributions( + usernameAndPersonaIdRequests.map { it.username }.toSet() ) return users.map { user -> - val personaId = userIdAndPersonaIdRequests.first { it.userId == user.id }.personaId + val personaId = usernameAndPersonaIdRequests.first { it.username == user.name }.personaId UserResponse.fromWithSpecificPersona(user, listOf(personaId)) } } diff --git a/src/main/kotlin/org/gitanimals/render/controller/request/UserIdAndPersonaIdRequest.kt b/src/main/kotlin/org/gitanimals/render/controller/request/UsernameAndPersonaIdRequest.kt similarity index 53% rename from src/main/kotlin/org/gitanimals/render/controller/request/UserIdAndPersonaIdRequest.kt rename to src/main/kotlin/org/gitanimals/render/controller/request/UsernameAndPersonaIdRequest.kt index 1395a7f..2f9028f 100644 --- a/src/main/kotlin/org/gitanimals/render/controller/request/UserIdAndPersonaIdRequest.kt +++ b/src/main/kotlin/org/gitanimals/render/controller/request/UsernameAndPersonaIdRequest.kt @@ -1,6 +1,6 @@ package org.gitanimals.render.controller.request -data class UserIdAndPersonaIdRequest( - val userId: Long, +data class UsernameAndPersonaIdRequest( + val username: String, val personaId: Long, ) diff --git a/src/main/kotlin/org/gitanimals/render/domain/UserRepository.kt b/src/main/kotlin/org/gitanimals/render/domain/UserRepository.kt index 42e5d1a..a0eed24 100644 --- a/src/main/kotlin/org/gitanimals/render/domain/UserRepository.kt +++ b/src/main/kotlin/org/gitanimals/render/domain/UserRepository.kt @@ -21,10 +21,10 @@ interface UserRepository : JpaRepository { """ select u from user as u left join fetch u.contributions - where u.id in :userIds + where u.name in :usernames """ ) - fun findAllByIdsWithContributions(@Param("userIds") userIds: Set): List + fun findAllByIdsWithContributions(@Param("usernames") usernames: Set): List fun existsByName(name: String): Boolean } diff --git a/src/main/kotlin/org/gitanimals/render/domain/UserService.kt b/src/main/kotlin/org/gitanimals/render/domain/UserService.kt index c8b20ce..c76361a 100644 --- a/src/main/kotlin/org/gitanimals/render/domain/UserService.kt +++ b/src/main/kotlin/org/gitanimals/render/domain/UserService.kt @@ -160,8 +160,8 @@ class UserService( ?: throw IllegalArgumentException("Cannot find matched persona \"$personaId\" by user name \"$name\"") } - fun findAllUsersByIdWithContributions(userIds: Set): List { - return userRepository.findAllByIdsWithContributions(userIds) + fun findAllUsersByNameWithContributions(usernames: Set): List { + return userRepository.findAllByIdsWithContributions(usernames) } companion object {