mirror of
https://github.com/2martens/tsw-timetable.git
synced 2026-10-17 16:06:51 +02:00
Use HourAtDay
This commit is contained in:
+3
-3
@@ -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
|
||||
)
|
||||
|
||||
+2
-2
@@ -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<BahnStationStop>
|
||||
) {
|
||||
|
||||
+1
-1
@@ -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))
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user