File tree Expand file tree Collapse file tree 3 files changed +23
-0
lines changed
src/main/kotlin/org/gitanimals/render Expand file tree Collapse file tree 3 files changed +23
-0
lines changed Original file line number Diff line number Diff line change @@ -28,4 +28,10 @@ class UserFacade(
28
28
29
29
return userService.deletePersona(user.id.toLong(), personaId)
30
30
}
31
+
32
+ fun getPersona (token : String , personaId : Long ): PersonaResponse {
33
+ val user = identityApi.getUserByToken(token)
34
+
35
+ return userService.getPersona(user.id.toLong(), personaId)
36
+ }
31
37
}
Original file line number Diff line number Diff line change @@ -22,6 +22,16 @@ class PersonaController(
22
22
return UserResponse .from(userService.getUserByName(username))
23
23
}
24
24
25
+ @GetMapping(" /personas/{persona-id}" )
26
+ fun getPersonaById (
27
+ @RequestHeader(HttpHeaders .AUTHORIZATION ) token : String ,
28
+ @PathVariable(" persona-id" ) personaId : Long ,
29
+ ): PersonaResponse {
30
+ val persona = userFacade.getPersona(token, personaId)
31
+
32
+ return PersonaResponse (persona.id, persona.type, persona.level)
33
+ }
34
+
25
35
@PatchMapping(" /personas" )
26
36
@ResponseStatus(HttpStatus .OK )
27
37
fun changePersona (
Original file line number Diff line number Diff line change @@ -94,6 +94,13 @@ class UserService(
94
94
return user.deletePersona(personaId)
95
95
}
96
96
97
+ fun getPersona (id : Long , personaId : Long ): PersonaResponse {
98
+ return getUserById(id).personas
99
+ .find { it.id == personaId }
100
+ ?.let { PersonaResponse .from(it) }
101
+ ? : throw IllegalArgumentException (" Cannot find matched persona \" $personaId \" by user \" $id \" " )
102
+ }
103
+
97
104
private fun getUserById (id : Long ) = (userRepository.findByIdOrNull(id)
98
105
? : throw IllegalArgumentException (" Cannot find exists user by id \" $id \" " ))
99
106
}
You can’t perform that action at this time.
0 commit comments