From 91be5d66c5cfed0d8cce4f7457c1c260b9af8dec Mon Sep 17 00:00:00 2001 From: Jim Martens Date: Thu, 26 Oct 2023 19:17:06 +0200 Subject: [PATCH] Use HourAtDay --- .../timetable/bahnApi/mapper/BahnTimetableMapper.kt | 6 +++--- .../twomartens/timetable/bahnApi/model/db/BahnTimetable.kt | 4 ++-- .../timetable/bahnApi/service/BahnDatabaseService.kt | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/module-server/src/main/kotlin/de/twomartens/timetable/bahnApi/mapper/BahnTimetableMapper.kt b/module-server/src/main/kotlin/de/twomartens/timetable/bahnApi/mapper/BahnTimetableMapper.kt index ec2e32d..55cd41d 100644 --- a/module-server/src/main/kotlin/de/twomartens/timetable/bahnApi/mapper/BahnTimetableMapper.kt +++ b/module-server/src/main/kotlin/de/twomartens/timetable/bahnApi/mapper/BahnTimetableMapper.kt @@ -1,9 +1,9 @@ package de.twomartens.timetable.bahnApi.mapper import de.twomartens.timetable.bahnApi.model.db.BahnTimetable +import de.twomartens.timetable.types.HourAtDay import de.twomartens.timetable.types.NonEmptyString import org.mapstruct.* -import java.time.LocalDateTime @Mapper( collectionMappingStrategy = CollectionMappingStrategy.ADDER_PREFERRED, @@ -15,10 +15,10 @@ interface BahnTimetableMapper { @Mapping(target = "created", ignore = true) @Mapping(target = "lastModified", ignore = true) fun mapToDB(dto: de.twomartens.timetable.bahnApi.model.dto.BahnTimetable, - dateTime: LocalDateTime): BahnTimetable { + hourAtDay: HourAtDay): BahnTimetable { return BahnTimetable( dto.eva, - dateTime, + hourAtDay, NonEmptyString(dto.station), dto.stops ) diff --git a/module-server/src/main/kotlin/de/twomartens/timetable/bahnApi/model/db/BahnTimetable.kt b/module-server/src/main/kotlin/de/twomartens/timetable/bahnApi/model/db/BahnTimetable.kt index 9cd0ef2..ad09995 100644 --- a/module-server/src/main/kotlin/de/twomartens/timetable/bahnApi/model/db/BahnTimetable.kt +++ b/module-server/src/main/kotlin/de/twomartens/timetable/bahnApi/model/db/BahnTimetable.kt @@ -2,6 +2,7 @@ package de.twomartens.timetable.bahnApi.model.db import de.twomartens.timetable.bahnApi.model.Eva import de.twomartens.timetable.bahnApi.model.dto.BahnStationStop +import de.twomartens.timetable.types.HourAtDay import de.twomartens.timetable.types.NonEmptyString import org.bson.types.ObjectId import org.springframework.data.annotation.CreatedDate @@ -11,13 +12,12 @@ import org.springframework.data.mongodb.core.index.CompoundIndex import org.springframework.data.mongodb.core.index.TextIndexed import org.springframework.data.mongodb.core.mapping.Document import java.time.Instant -import java.time.LocalDateTime @Document @CompoundIndex(def = "{'eva': 1, 'dateTime': 1}", unique = true) data class BahnTimetable( var eva: Eva, - var dateTime: LocalDateTime, + var hourAtDay: HourAtDay, @TextIndexed var station: NonEmptyString, var stops: List ) { diff --git a/module-server/src/main/kotlin/de/twomartens/timetable/bahnApi/service/BahnDatabaseService.kt b/module-server/src/main/kotlin/de/twomartens/timetable/bahnApi/service/BahnDatabaseService.kt index 2f567b6..2d2eebe 100644 --- a/module-server/src/main/kotlin/de/twomartens/timetable/bahnApi/service/BahnDatabaseService.kt +++ b/module-server/src/main/kotlin/de/twomartens/timetable/bahnApi/service/BahnDatabaseService.kt @@ -24,6 +24,6 @@ class BahnDatabaseService( } fun storeTimetable(timetable: BahnTimetable, hourAtDay: HourAtDay) { - bahnTimetableRepository.save(bahnTimetableMapper.mapToDB(timetable, hourAtDay.dateTime)) + bahnTimetableRepository.save(bahnTimetableMapper.mapToDB(timetable, hourAtDay)) } } \ No newline at end of file