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