Skip to content

Commit

Permalink
Add StaffReponse.staffIdentifier in ap-and-delius
Browse files Browse the repository at this point in the history
This commits adds the `staffIdentifier` field to `StaffResponse`, matching the field already provided by `StaffDetail`. This helps approved-premise limit the number of requests required to build domain events involving keyworkers.
  • Loading branch information
davidatkinsuk committed Nov 28, 2024
1 parent 90be6df commit 3506c3f
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package uk.gov.justice.digital.hmpps.model

data class StaffResponse(
val code: String,
val staffIdentifier: Long,
val name: PersonName,
val grade: StaffGrade?,
val keyWorker: Boolean
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ class StaffService(

fun Staff.toResponse(approvedPremisesCode: String) = StaffResponse(
code = code,
staffIdentifier = id,
name = PersonName(forename, surname, middleName),
grade = grade?.let { grade -> StaffGrade(grade.code, grade.description) },
keyWorker = approvedPremises.map { ap -> ap.code.code }.contains(approvedPremisesCode)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ internal class StaffServiceTest {
assertThat(results.content.map { it.name.surname }, equalTo(listOf("Staff 1", "Staff 2")))
assertThat(results.content.map { it.keyWorker }, equalTo(listOf(false, true)))
assertThat(results.content[0].code, equalTo(staffEntities[0].code))
assertThat(results.content[0].staffIdentifier, equalTo(staffEntities[0].id))
assertThat(results.content[0].name.forename, equalTo(staffEntities[0].forename))
assertThat(results.content[0].name.middleName, equalTo(staffEntities[0].middleName))
assertThat(results.content[0].name.surname, equalTo(staffEntities[0].surname))
Expand Down

0 comments on commit 3506c3f

Please sign in to comment.