-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
♻️ Gidder ikke bruke SaksbehandlerVisitor ved lagring av saksbehandler
- Loading branch information
Showing
1 changed file
with
8 additions
and
21 deletions.
There are no files selected for viewing
29 changes: 8 additions & 21 deletions
29
spesialist-selve/src/main/kotlin/no/nav/helse/mediator/saksbehandler/SaksbehandlerLagrer.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 |
---|---|---|
@@ -1,31 +1,18 @@ | ||
package no.nav.helse.mediator.saksbehandler | ||
|
||
import no.nav.helse.db.SaksbehandlerDao | ||
import no.nav.helse.db.SaksbehandlerFraDatabase | ||
import no.nav.helse.modell.saksbehandler.Saksbehandler | ||
import no.nav.helse.modell.saksbehandler.SaksbehandlerVisitor | ||
import java.util.UUID | ||
|
||
class SaksbehandlerLagrer(private val saksbehandlerDao: SaksbehandlerDao) : SaksbehandlerVisitor { | ||
private lateinit var saksbehandlerFraDatabase: SaksbehandlerFraDatabase | ||
import no.nav.helse.modell.saksbehandler.Saksbehandler.Companion.toDto | ||
|
||
class SaksbehandlerLagrer(private val saksbehandlerDao: SaksbehandlerDao) { | ||
internal fun lagre(saksbehandler: Saksbehandler) { | ||
saksbehandler.accept(this) | ||
val dto = saksbehandler.toDto() | ||
saksbehandlerDao.opprettEllerOppdater( | ||
oid = saksbehandlerFraDatabase.oid, | ||
navn = saksbehandlerFraDatabase.navn, | ||
epost = saksbehandlerFraDatabase.epostadresse, | ||
ident = saksbehandlerFraDatabase.ident, | ||
oid = dto.oid, | ||
navn = dto.navn, | ||
epost = dto.epostadresse, | ||
ident = dto.ident, | ||
) | ||
saksbehandlerDao.oppdaterSistObservert(saksbehandlerFraDatabase.oid) | ||
} | ||
|
||
override fun visitSaksbehandler( | ||
epostadresse: String, | ||
oid: UUID, | ||
navn: String, | ||
ident: String, | ||
) { | ||
saksbehandlerFraDatabase = SaksbehandlerFraDatabase(epostadresse, oid, navn, ident) | ||
saksbehandlerDao.oppdaterSistObservert(dto.oid) | ||
} | ||
} |