generated from ministryofjustice/template-repository
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* PI-2469: Added external api refdata endpoint * Formatting changes * PI-2469: Added external api refdata endpoint --------- Co-authored-by: probation-integration-bot[bot] <177347787+probation-integration-bot[bot]@users.noreply.github.com>
- Loading branch information
1 parent
dbcc4ea
commit 31677b2
Showing
9 changed files
with
140 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
...delius/src/main/kotlin/uk/gov/justice/digital/hmpps/controller/ReferenceDataController.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package uk.gov.justice.digital.hmpps.controller | ||
|
||
import io.swagger.v3.oas.annotations.Operation | ||
import io.swagger.v3.oas.annotations.tags.Tag | ||
import org.springframework.security.access.prepost.PreAuthorize | ||
import org.springframework.web.bind.annotation.GetMapping | ||
import org.springframework.web.bind.annotation.RequestMapping | ||
import org.springframework.web.bind.annotation.RestController | ||
import uk.gov.justice.digital.hmpps.service.ReferenceDataService | ||
|
||
@RestController | ||
@RequestMapping("/reference-data") | ||
@PreAuthorize("hasRole('PROBATION_API__HMPPS_API__CASE_DETAIL')") | ||
@Tag(name = "Identifier Converter", description = "Requires PROBATION_API__HMPPS_API__CASE_DETAIL") | ||
class ReferenceDataController( | ||
private val referenceDataService: ReferenceDataService | ||
) { | ||
@GetMapping | ||
@Operation(summary = "Gets delius reference data ") | ||
fun refData() = referenceDataService.getReferenceData() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
...cts/external-api-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/model/RefData.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package uk.gov.justice.digital.hmpps.model | ||
|
||
import io.swagger.v3.oas.annotations.media.Schema | ||
|
||
data class RefData( | ||
@Schema(description = "reference data code", example = "M") | ||
val code: String, | ||
@Schema(description = "reference data description", example = "MALE") | ||
val description: String | ||
) | ||
|
||
data class ProbationReferenceData( | ||
val probationReferenceData: Map<String, List<RefData>> | ||
) |
17 changes: 17 additions & 0 deletions
17
...i-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/service/ReferenceDataService.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package uk.gov.justice.digital.hmpps.service | ||
|
||
import org.springframework.stereotype.Service | ||
import uk.gov.justice.digital.hmpps.integration.delius.entity.RegistrationRepository | ||
import uk.gov.justice.digital.hmpps.model.ProbationReferenceData | ||
import uk.gov.justice.digital.hmpps.model.RefData | ||
|
||
@Service | ||
class ReferenceDataService( | ||
private val registrationRepository: RegistrationRepository, | ||
) { | ||
fun getReferenceData(): ProbationReferenceData = | ||
ProbationReferenceData( | ||
registrationRepository.getReferenceData() | ||
.groupByTo(LinkedHashMap(), { it.codeSet.trim() }, { RefData(it.code.trim(), it.description) }) | ||
) | ||
} |