Skip to content

Commit

Permalink
Get back @Cacheable already was there.
Browse files Browse the repository at this point in the history
  • Loading branch information
MalazAlkoj committed Jun 25, 2024
1 parent e7263df commit b4b8f75
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
package no.nav.syfo.brukertilgang

import org.springframework.beans.factory.annotation.Autowired
import org.springframework.cache.annotation.Cacheable
import org.springframework.stereotype.Service

@Service
class BrukertilgangService @Autowired constructor(
private var brukertilgangClient: BrukertilgangClient
) {

@Cacheable(
cacheNames = ["tilgangtilident"],
key = "#innloggetIdent.concat(#oppslaattFnr)",
condition = "#innloggetIdent != null && #oppslaattFnr != null"
)
fun tilgangTilOppslattIdent(innloggetIdent: String, oppslaattFnr: String): Boolean {
return oppslaattFnr == innloggetIdent || brukertilgangClient.hasAccessToAnsatt(oppslaattFnr)
}
Expand Down
6 changes: 5 additions & 1 deletion src/main/kotlin/no/nav/syfo/ereg/EregClient.kt
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,11 @@ class EregClient @Inject constructor(
throw e
}
}

/*@Cacheable(
value = [CacheConfig.CACHENAME_EREG_VIRKSOMHETSNAVN],
key = "#virksomhetsnummer",
condition = "#virksomhetsnummer != null",
)*/
fun virksomhetsnavn(virksomhetsnummer: String): String {
return eregResponse(virksomhetsnummer).navn()
}
Expand Down
2 changes: 2 additions & 0 deletions src/main/kotlin/no/nav/syfo/kontaktinfo/KrrClient.kt
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import no.nav.syfo.util.NAV_PERSONIDENT_HEADER
import org.slf4j.LoggerFactory
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.beans.factory.annotation.Value
import org.springframework.cache.annotation.Cacheable
import org.springframework.http.HttpEntity
import org.springframework.http.HttpHeaders
import org.springframework.http.HttpMethod
Expand All @@ -24,6 +25,7 @@ class KrrClient @Autowired constructor(
@Value("\${krr.scope}") private val krrScope: String,
@Value("\${krr.url}") val krrUrl: String,
) {
@Cacheable(cacheNames = ["krr_fnr"], key = "#fnr", condition = "#fnr != null")
fun kontaktinformasjon(fnr: String): DigitalKontaktinfo {
val accessToken = "Bearer ${azureAdTokenConsumer.getSystemToken(krrScope)}"
val response = RestTemplate().exchange(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import no.nav.syfo.util.NAV_PERSONIDENT_HEADER
import no.nav.syfo.util.bearerHeader
import org.slf4j.LoggerFactory
import org.springframework.beans.factory.annotation.Value
import org.springframework.cache.annotation.Cacheable
import org.springframework.http.HttpEntity
import org.springframework.http.HttpHeaders
import org.springframework.http.HttpMethod
Expand All @@ -26,6 +27,7 @@ class NarmesteLederClient(
private val tokenDingsConsumer: TokenDingsConsumer,
private val contextHolder: TokenValidationContextHolder,
) {
@Cacheable(value = ["aktive_ledere"], key = "#ansattFnr", condition = "#ansattFnr != null")
fun alleLedereForSykmeldt(
ansattFnr: String,
): List<NarmesteLederRelasjonDTO> {
Expand All @@ -51,6 +53,11 @@ class NarmesteLederClient(
}
}

@Cacheable(
value = ["aktive_ansatte"],
key = "{#ansattFnr, #virksomhetsnummer}",
condition = "{#ansattFnr != null, #virksomhetsnummer != null}"
)
fun aktivNarmesteLederIVirksomhet(
ansattFnr: String,
virksomhetsnummer: String,
Expand Down

0 comments on commit b4b8f75

Please sign in to comment.