Skip to content

Commit 5f7819d

Browse files
authored
release: 0.4.7 (#54)
2 parents 8b70488 + 4dce8eb commit 5f7819d

File tree

3 files changed

+14
-18
lines changed

3 files changed

+14
-18
lines changed

src/main/kotlin/org/gitanimals/render/app/UserFacade.kt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,24 +14,24 @@ class UserFacade(
1414
fun changePersona(token: String, personChangeRequest: PersonaChangeRequest) {
1515
val user = identityApi.getUserByToken(token)
1616

17-
userService.changePersona(user.id.toLong(), personChangeRequest)
17+
userService.changePersona(user.username, personChangeRequest)
1818
}
1919

2020
fun addPersona(token: String, idempotencyKey: String, personaType: String): PersonaResponse {
2121
val user = identityApi.getUserByToken(token)
2222

23-
return userService.addPersona(user.id.toLong(), personaType, idempotencyKey)
23+
return userService.addPersona(user.username, personaType, idempotencyKey)
2424
}
2525

2626
fun deletePersona(token: String, personaId: Long): PersonaResponse {
2727
val user = identityApi.getUserByToken(token)
2828

29-
return userService.deletePersona(user.id.toLong(), personaId)
29+
return userService.deletePersona(user.username, personaId)
3030
}
3131

3232
fun getPersona(token: String, personaId: Long): PersonaResponse {
3333
val user = identityApi.getUserByToken(token)
3434

35-
return userService.getPersona(user.id.toLong(), personaId)
35+
return userService.getPersona(user.username, personaId)
3636
}
3737
}

src/main/kotlin/org/gitanimals/render/domain/UserService.kt

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,8 @@ class UserService(
6161

6262
@Retryable(retryFor = [ObjectOptimisticLockingFailureException::class], maxAttempts = 100)
6363
@Transactional
64-
fun changePersona(id: Long, personChangeRequest: PersonaChangeRequest) {
65-
val user = getUserById(id)
64+
fun changePersona(name: String, personChangeRequest: PersonaChangeRequest) {
65+
val user = getUserByName(name)
6666

6767
user.changePersonaVisible(
6868
personChangeRequest.personaId.toLong(),
@@ -72,10 +72,10 @@ class UserService(
7272

7373
@Retryable(retryFor = [ObjectOptimisticLockingFailureException::class], maxAttempts = 100)
7474
@Transactional
75-
fun addPersona(id: Long, personaType: String, idempotencyKey: String): PersonaResponse {
75+
fun addPersona(name: String, personaType: String, idempotencyKey: String): PersonaResponse {
7676
requireIdempotency("addPersona:$idempotencyKey")
7777

78-
val user = getUserById(id)
78+
val user = getUserByName(name)
7979

8080
return user.addPersona(PersonaType.valueOf(personaType.uppercase()))
8181
}
@@ -90,19 +90,16 @@ class UserService(
9090

9191
@Retryable(retryFor = [ObjectOptimisticLockingFailureException::class], maxAttempts = 100)
9292
@Transactional
93-
fun deletePersona(id: Long, personaId: Long): PersonaResponse {
94-
val user = getUserById(id)
93+
fun deletePersona(name: String, personaId: Long): PersonaResponse {
94+
val user = getUserByName(name)
9595

9696
return user.deletePersona(personaId)
9797
}
9898

99-
fun getPersona(id: Long, personaId: Long): PersonaResponse {
100-
return getUserById(id).personas
99+
fun getPersona(name: String, personaId: Long): PersonaResponse {
100+
return getUserByName(name).personas
101101
.find { it.id == personaId }
102102
?.let { PersonaResponse.from(it) }
103-
?: throw IllegalArgumentException("Cannot find matched persona \"$personaId\" by user \"$id\"")
103+
?: throw IllegalArgumentException("Cannot find matched persona \"$personaId\" by user name \"$name\"")
104104
}
105-
106-
private fun getUserById(id: Long) = (userRepository.findByIdOrNull(id)
107-
?: throw IllegalArgumentException("Cannot find exists user by id \"$id\""))
108105
}

src/test/kotlin/org/gitanimals/render/domain/UserServiceTest.kt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,9 @@ internal class UserServiceTest(
3333
describe("deletePersona 메소드는") {
3434
context("userId와 personaId를 받으면,") {
3535
val personaId = user.personas[0].id
36-
val userId = user.id
3736

3837
it("persona를 삭제한다.") {
39-
val response = userService.deletePersona(userId, personaId)
38+
val response = userService.deletePersona(user.name, personaId)
4039
val user = userService.getUserByName(user.name)
4140

4241
user.personas

0 commit comments

Comments
 (0)