diff --git a/src/main/kotlin/no/nav/arbeidsgiver/min_side/varslingstatus/VarslingStatusController.kt b/src/main/kotlin/no/nav/arbeidsgiver/min_side/varslingstatus/VarslingStatusController.kt index 1ab8b20a..8cc5bd8a 100644 --- a/src/main/kotlin/no/nav/arbeidsgiver/min_side/varslingstatus/VarslingStatusController.kt +++ b/src/main/kotlin/no/nav/arbeidsgiver/min_side/varslingstatus/VarslingStatusController.kt @@ -1,7 +1,9 @@ package no.nav.arbeidsgiver.min_side.varslingstatus +import no.nav.arbeidsgiver.min_side.config.GittMiljø import no.nav.arbeidsgiver.min_side.controller.AuthenticatedUserHolder import no.nav.arbeidsgiver.min_side.services.altinn.AltinnService +import no.nav.arbeidsgiver.min_side.varslingstatus.VarslingStatusDto.Status import org.springframework.web.bind.annotation.PostMapping import org.springframework.web.bind.annotation.RequestBody import org.springframework.web.bind.annotation.RestController @@ -13,8 +15,25 @@ class VarslingStatusController( private val authenticatedUserHolder: AuthenticatedUserHolder, private val altinnService: AltinnService, private val repository: VarslingStatusRepository, + private val gittMiljø: GittMiljø, ) { + /** + * midlertidig simuler mangler kofuvi i dev da dette mangler. + * TODO: fjern før merge + */ + fun mapStatus(varslingStatus: VarslingStatus) = gittMiljø.resolve( + prod = { + varslingStatus + }, + other = { + when(varslingStatus.status) { + Status.OK -> varslingStatus + else -> varslingStatus.copy(status = Status.MANGLER_KOFUVI) + } + }, + ) + @PostMapping("/api/varslingStatus/v1") fun getVarslingStatus(@RequestBody requestBody: VarslingStatusRequest): VarslingStatus { val virksomhetsnummer = requestBody.virksomhetsnummer @@ -29,7 +48,7 @@ class VarslingStatusController( ) } - return repository.varslingStatus(virksomhetsnummer = virksomhetsnummer) + return mapStatus(repository.varslingStatus(virksomhetsnummer = virksomhetsnummer)) } data class VarslingStatusRequest( diff --git a/src/main/kotlin/no/nav/arbeidsgiver/min_side/varslingstatus/VarslingStatusRepository.kt b/src/main/kotlin/no/nav/arbeidsgiver/min_side/varslingstatus/VarslingStatusRepository.kt index 1a535f1e..e59e4911 100644 --- a/src/main/kotlin/no/nav/arbeidsgiver/min_side/varslingstatus/VarslingStatusRepository.kt +++ b/src/main/kotlin/no/nav/arbeidsgiver/min_side/varslingstatus/VarslingStatusRepository.kt @@ -4,6 +4,7 @@ import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonIgnoreProperties import com.fasterxml.jackson.annotation.JsonProperty import com.fasterxml.jackson.databind.ObjectMapper +import no.nav.arbeidsgiver.min_side.varslingstatus.VarslingStatusDto.Status import org.apache.kafka.clients.consumer.ConsumerRecord import org.springframework.context.annotation.Profile import org.springframework.jdbc.core.JdbcTemplate @@ -97,12 +98,12 @@ data class VarslingStatusDto @JsonCreator(mode = JsonCreator.Mode.PROPERTIES) co @param:JsonProperty("kvittertEventTimestamp") val eventTimestamp: Instant, @param:JsonProperty("status") val status: Status, @param:JsonProperty("version") val version: String, -) - -enum class Status { - OK, - MANGLER_KOFUVI, - ANNEN_FEIL, +) { + enum class Status { + OK, + MANGLER_KOFUVI, + ANNEN_FEIL, + } }