@@ -61,8 +61,8 @@ class UserService(
61
61
62
62
@Retryable(retryFor = [ObjectOptimisticLockingFailureException ::class ], maxAttempts = 100 )
63
63
@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 )
66
66
67
67
user.changePersonaVisible(
68
68
personChangeRequest.personaId.toLong(),
@@ -72,10 +72,10 @@ class UserService(
72
72
73
73
@Retryable(retryFor = [ObjectOptimisticLockingFailureException ::class ], maxAttempts = 100 )
74
74
@Transactional
75
- fun addPersona (id : Long , personaType : String , idempotencyKey : String ): PersonaResponse {
75
+ fun addPersona (name : String , personaType : String , idempotencyKey : String ): PersonaResponse {
76
76
requireIdempotency(" addPersona:$idempotencyKey " )
77
77
78
- val user = getUserById(id )
78
+ val user = getUserByName(name )
79
79
80
80
return user.addPersona(PersonaType .valueOf(personaType.uppercase()))
81
81
}
@@ -90,19 +90,16 @@ class UserService(
90
90
91
91
@Retryable(retryFor = [ObjectOptimisticLockingFailureException ::class ], maxAttempts = 100 )
92
92
@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 )
95
95
96
96
return user.deletePersona(personaId)
97
97
}
98
98
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
101
101
.find { it.id == personaId }
102
102
?.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 \" " )
104
104
}
105
-
106
- private fun getUserById (id : Long ) = (userRepository.findByIdOrNull(id)
107
- ? : throw IllegalArgumentException (" Cannot find exists user by id \" $id \" " ))
108
105
}
0 commit comments