From d3a8e0abc80e83dde3ea9a0694ad86886be8a134 Mon Sep 17 00:00:00 2001 From: Jim Martens Date: Sun, 24 Sep 2023 09:05:33 +0200 Subject: [PATCH] Added BahnDatabaseService to store stations --- .../bahnApi/service/BahnDatabaseService.kt | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 module-server/src/main/kotlin/de/twomartens/timetable/bahnApi/service/BahnDatabaseService.kt 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 new file mode 100644 index 0000000..7d033b0 --- /dev/null +++ b/module-server/src/main/kotlin/de/twomartens/timetable/bahnApi/service/BahnDatabaseService.kt @@ -0,0 +1,19 @@ +package de.twomartens.timetable.bahnApi.service + +import de.twomartens.timetable.bahnApi.mapper.BahnStationMapper +import de.twomartens.timetable.bahnApi.model.dto.BahnStation +import de.twomartens.timetable.bahnApi.repository.BahnStationRepository +import org.mapstruct.factory.Mappers +import org.springframework.stereotype.Service + +@Service +class BahnDatabaseService( + private val bahnStationRepository: BahnStationRepository +) { + private val bahnStationMapper = Mappers.getMapper(BahnStationMapper::class.java) + + fun storeStations(stations: List) { + bahnStationRepository.saveAll(stations + .map { bahnStationMapper.mapToDB(it) }) + } +} \ No newline at end of file