-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
IS-1879: Add api for dialogmote statusendringer
- Loading branch information
1 parent
6b5d02c
commit 880da2d
Showing
16 changed files
with
381 additions
and
8 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
13 changes: 13 additions & 0 deletions
13
src/main/kotlin/no/nav/syfo/dialogmote/api/domain/DialogmoteStatusEndringDTO.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,13 @@ | ||
package no.nav.syfo.dialogmote.api.domain | ||
|
||
import no.nav.syfo.dialogmote.domain.DialogmoteStatus | ||
import java.time.LocalDateTime | ||
|
||
data class DialogmoteStatusEndringDTO( | ||
val uuid: String, | ||
val createdAt: LocalDateTime, | ||
val dialogmoteId: Int, | ||
val dialogmoteOpprettetAv: String, | ||
val status: DialogmoteStatus, | ||
val statusEndringOpprettetAv: String, | ||
) |
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
2 changes: 1 addition & 1 deletion
2
...yfo/dialogmote/database/MoteRepository.kt → ...ote/database/repository/MoteRepository.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
60 changes: 60 additions & 0 deletions
60
src/main/kotlin/no/nav/syfo/dialogmote/database/repository/MoteStatusEndretRepository.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,60 @@ | ||
package no.nav.syfo.dialogmote.database.repository | ||
|
||
import no.nav.syfo.application.database.DatabaseInterface | ||
import no.nav.syfo.application.database.toList | ||
import no.nav.syfo.dialogmote.api.domain.DialogmoteStatusEndringDTO | ||
import no.nav.syfo.dialogmote.database.domain.PMoteStatusEndret | ||
import no.nav.syfo.dialogmote.domain.DialogmoteStatus | ||
import no.nav.syfo.domain.PersonIdent | ||
import java.sql.ResultSet | ||
import java.util.* | ||
|
||
class MoteStatusEndretRepository(private val database: DatabaseInterface) { | ||
|
||
fun getMoteStatusEndringer(personident: PersonIdent): List<DialogmoteStatusEndringDTO> = | ||
database.connection.use { connection -> | ||
connection.prepareStatement(GET_MOTE_STATUS_ENDRINGER).use { ps -> | ||
ps.setString(1, personident.value) | ||
ps.executeQuery() | ||
.toList { | ||
val pDialogmoteStatusEndret = toPMoteStatusEndret() | ||
DialogmoteStatusEndringDTO( | ||
uuid = pDialogmoteStatusEndret.uuid.toString(), | ||
createdAt = pDialogmoteStatusEndret.createdAt, | ||
dialogmoteId = pDialogmoteStatusEndret.moteId, | ||
dialogmoteOpprettetAv = getString("mote_opprettet_av"), | ||
status = pDialogmoteStatusEndret.status, | ||
statusEndringOpprettetAv = pDialogmoteStatusEndret.opprettetAv, | ||
) | ||
} | ||
} | ||
} | ||
|
||
companion object { | ||
private const val GET_MOTE_STATUS_ENDRINGER = | ||
""" | ||
SELECT | ||
mse.*, | ||
m.opprettet_av as mote_opprettet_av | ||
FROM mote_status_endret mse | ||
INNER JOIN mote m on mse.mote_id = m.id | ||
INNER JOIN motedeltaker_arbeidstaker mda on m.id = mda.mote_id | ||
WHERE mda.personident = ? | ||
ORDER BY mse.created_at DESC | ||
""" | ||
} | ||
} | ||
|
||
internal fun ResultSet.toPMoteStatusEndret(): PMoteStatusEndret = | ||
PMoteStatusEndret( | ||
id = getInt("id"), | ||
uuid = UUID.fromString(getString("uuid")), | ||
createdAt = getTimestamp("created_at").toLocalDateTime(), | ||
updatedAt = getTimestamp("updated_at").toLocalDateTime(), | ||
moteId = getInt("mote_id"), | ||
motedeltakerBehandler = getBoolean("motedeltaker_behandler"), | ||
status = DialogmoteStatus.valueOf(getString("status")), | ||
opprettetAv = getString("opprettet_av"), | ||
tilfelleStart = getTimestamp("tilfelle_start").toLocalDateTime().toLocalDate(), | ||
publishedAt = getTimestamp("published_at")?.toLocalDateTime(), | ||
) |
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
Oops, something went wrong.