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