Last change
on this file was baf4cc4, checked in by ppaunovski <paunovskipavel@…>, 3 months ago |
split group project and individual project into two separate folders
|
-
Property mode
set to
100644
|
File size:
1.6 KB
|
Line | |
---|
1 | package mk.ukim.finki.busngobackend.service
|
---|
2 |
|
---|
3 | import mk.ukim.finki.busngobackend.domain.entities.InstancaNaLinijaPostojkaNaLinija
|
---|
4 | import mk.ukim.finki.busngobackend.repository.InstancaNaLinijaPostojkaNaLinijaRepository
|
---|
5 | import mk.ukim.finki.busngobackend.repository.InstancaNaLinijaRepository
|
---|
6 | import mk.ukim.finki.busngobackend.repository.PostojkaNaLinijaRepository
|
---|
7 | import mk.ukim.finki.busngobackend.service.exceptions.NotFoundException
|
---|
8 | import org.springframework.data.repository.findByIdOrNull
|
---|
9 | import org.springframework.stereotype.Service
|
---|
10 | import java.sql.Timestamp
|
---|
11 |
|
---|
12 | @Service
|
---|
13 | class RouteInstanceOnStationService(
|
---|
14 | private val instancaNaLinijaPostojkaNaLinijaRepository: InstancaNaLinijaPostojkaNaLinijaRepository,
|
---|
15 | private val instancaNaLinijaRepository: InstancaNaLinijaRepository,
|
---|
16 | private val postojkaNaLinijaRepository: PostojkaNaLinijaRepository,
|
---|
17 | ) {
|
---|
18 | fun create(
|
---|
19 | routeInstanceId: Long,
|
---|
20 | lineStationId: Long,
|
---|
21 | timestamp: Timestamp,
|
---|
22 | ): InstancaNaLinijaPostojkaNaLinija {
|
---|
23 | val routeInstance =
|
---|
24 | instancaNaLinijaRepository.findByIdOrNull(routeInstanceId) ?: throw NotFoundException("Route instance not found")
|
---|
25 | val lineStation = postojkaNaLinijaRepository.findByIdOrNull(lineStationId) ?: throw NotFoundException("Line station not found")
|
---|
26 | return instancaNaLinijaPostojkaNaLinijaRepository.save(
|
---|
27 | InstancaNaLinijaPostojkaNaLinija(
|
---|
28 | instancaNaLinija = routeInstance,
|
---|
29 | postojkaNaLinija = lineStation,
|
---|
30 | timestamp = timestamp,
|
---|
31 | id = 0L,
|
---|
32 | ),
|
---|
33 | )
|
---|
34 | }
|
---|
35 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.