Skip to content

Commit

Permalink
release: 1.1.1 (#234)
Browse files Browse the repository at this point in the history
  • Loading branch information
devxb authored Jan 6, 2025
2 parents 2d75a1c + 65b60f4 commit 779cd62
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 20 deletions.
12 changes: 6 additions & 6 deletions src/main/kotlin/org/gitanimals/guild/app/DrawGuildFacade.kt
Original file line number Diff line number Diff line change
Expand Up @@ -43,19 +43,19 @@ class DrawGuildFacade(
}

private fun getRenderUsers(guild: Guild): List<RenderApi.UserResponse> {
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,
)
}

Expand Down
6 changes: 3 additions & 3 deletions src/main/kotlin/org/gitanimals/guild/app/RenderApi.kt
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ interface RenderApi {
@GetExchange("/internals/personas/all")
fun getAllPersonasByUserIdsAndPersonaIds(
@RequestHeader(INTERNAL_SECRET_KEY) internalSecret: String,
@RequestBody userIdAndPersonaIdRequests: List<UserIdAndPersonaIdRequest>,
@RequestBody usernameAndPersonaIdRequests: List<UsernameAndPersonaIdRequest>,
): List<UserResponse>

data class UserResponse(
Expand All @@ -31,8 +31,8 @@ interface RenderApi {
)
}

data class UserIdAndPersonaIdRequest(
val userId: Long,
data class UsernameAndPersonaIdRequest(
val username: String,
val personaId: Long,
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -86,14 +86,14 @@ class InternalPersonaController(
@GetMapping("/internals/personas/all")
@ResponseStatus(HttpStatus.OK)
fun getAllPersonasByUserIdsAndPersonaIds(
@RequestBody userIdAndPersonaIdRequests: List<UserIdAndPersonaIdRequest>
@RequestBody usernameAndPersonaIdRequests: List<UsernameAndPersonaIdRequest>
): List<UserResponse> {
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))
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -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,
)
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ interface UserRepository : JpaRepository<User, Long> {
"""
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<Long>): List<User>
fun findAllByIdsWithContributions(@Param("usernames") usernames: Set<String>): List<User>

fun existsByName(name: String): Boolean
}
4 changes: 2 additions & 2 deletions src/main/kotlin/org/gitanimals/render/domain/UserService.kt
Original file line number Diff line number Diff line change
Expand Up @@ -160,8 +160,8 @@ class UserService(
?: throw IllegalArgumentException("Cannot find matched persona \"$personaId\" by user name \"$name\"")
}

fun findAllUsersByIdWithContributions(userIds: Set<Long>): List<User> {
return userRepository.findAllByIdsWithContributions(userIds)
fun findAllUsersByNameWithContributions(usernames: Set<String>): List<User> {
return userRepository.findAllByIdsWithContributions(usernames)
}

companion object {
Expand Down

0 comments on commit 779cd62

Please sign in to comment.