diff --git a/src/main/kotlin/eu/fosil/okupamicoche/OkupaMiCocheApplication.kt b/src/main/kotlin/eu/fosil/okupamicoche/OkupaMiCocheApplication.kt index 7ebdc9a..b84ddfa 100644 --- a/src/main/kotlin/eu/fosil/okupamicoche/OkupaMiCocheApplication.kt +++ b/src/main/kotlin/eu/fosil/okupamicoche/OkupaMiCocheApplication.kt @@ -1,7 +1,6 @@ package eu.fosil.okupamicoche import org.springframework.boot.autoconfigure.SpringBootApplication -import org.springframework.boot.autoconfigure.domain.EntityScan import org.springframework.boot.runApplication import org.springframework.data.jpa.repository.config.EnableJpaRepositories @@ -12,5 +11,5 @@ import org.springframework.data.jpa.repository.config.EnableJpaRepositories class OkupaMiCocheApplication fun main(args: Array) { - runApplication(*args) + runApplication(*args) } diff --git a/src/main/kotlin/eu/fosil/okupamicoche/dto/CreateUserDto.kt b/src/main/kotlin/eu/fosil/okupamicoche/dto/CreateUserDto.kt index 9f92250..37fb9f1 100644 --- a/src/main/kotlin/eu/fosil/okupamicoche/dto/CreateUserDto.kt +++ b/src/main/kotlin/eu/fosil/okupamicoche/dto/CreateUserDto.kt @@ -3,27 +3,27 @@ package eu.fosil.okupamicoche.dto import eu.fosil.okupamicoche.entities.User class CreateUserDto( - private val id: String, - private val username: String, - private val matrixId: String, - private val name: String, - private val email: String? + private val id: String, + private val username: String, + private val matrixId: String, + private val name: String, + private val email: String? ) { constructor(user: User) : this( - user.id, - user.username, - user.matrixId, - user.name, - user.email + user.id, + user.username, + user.matrixId, + user.name, + user.email ) fun toUser(): User { return User( - id = id, - username = username, - matrixId = matrixId, - name = name, - email = email + id = id, + username = username, + matrixId = matrixId, + name = name, + email = email ) } } \ No newline at end of file diff --git a/src/main/kotlin/eu/fosil/okupamicoche/dto/TravelDto.kt b/src/main/kotlin/eu/fosil/okupamicoche/dto/TravelDto.kt index 8882c7a..e6d8467 100644 --- a/src/main/kotlin/eu/fosil/okupamicoche/dto/TravelDto.kt +++ b/src/main/kotlin/eu/fosil/okupamicoche/dto/TravelDto.kt @@ -1,5 +1,6 @@ package eu.fosil.okupamicoche.dto +import com.fasterxml.jackson.annotation.JsonFormat import eu.fosil.okupamicoche.entities.Travel import eu.fosil.okupamicoche.entities.TravelId import eu.fosil.okupamicoche.entities.UserIdNotFoundException @@ -9,44 +10,45 @@ import org.springframework.data.repository.findByIdOrNull import java.time.LocalDateTime class TravelDto( - // Los campos deben ser públicos para que aparezcan en el JSON - val id: TravelId? = null, - var driverInfo: UserInfoDto? = null, - val travelersInfo: List = emptyList(), - val departureDate: LocalDateTime = LocalDateTime.MIN, - val origin: String = "", - val destination: String = "", - val places: Int = 0, - var description: String? = null, - val matrixRoomId: String = "" + // Los campos deben ser públicos para que aparezcan en el JSON + val id: TravelId? = null, + var driverInfo: UserInfoDto? = null, + val travelersInfo: List = emptyList(), + @JsonFormat(shape = JsonFormat.Shape.STRING) + val departureDate: LocalDateTime = LocalDateTime.MIN, + val origin: String = "", + val destination: String = "", + val places: Int = 0, + var description: String? = null, + val matrixRoomId: String = "" ) { constructor(travel: Travel) : this( - travel.id, - UserInfoDto(travel.driver), - travel.travelers.map { traveler -> UserInfoDto(traveler) }, - travel.departureDate, - travel.origin, - travel.destination, - travel.places, - travel.description, - travel.matrixRoomId + travel.id, + UserInfoDto(travel.driver), + travel.travelers.map { traveler -> UserInfoDto(traveler) }, + travel.departureDate, + travel.origin, + travel.destination, + travel.places, + travel.description, + travel.matrixRoomId ) fun toTravel(userRepository: UserRepository): Travel { driverInfo?.let { driverInfo -> val driver = userRepository.findByIdOrNull(driverInfo.id) ?: throw UserIdNotFoundException() val travelers = travelersInfo.mapNotNull { t -> userRepository.findByIdOrNull(t.id) } - .toMutableList() + .toMutableList() return Travel( - id, - driver, - travelers, - departureDate, - origin, - destination, - places, - description, - matrixRoomId + id, + driver, + travelers, + departureDate, + origin, + destination, + places, + description, + matrixRoomId ) } throw UserNotSpecifiedException() diff --git a/src/main/kotlin/eu/fosil/okupamicoche/dto/UserDto.kt b/src/main/kotlin/eu/fosil/okupamicoche/dto/UserDto.kt index 59f6db7..e8a2e7e 100644 --- a/src/main/kotlin/eu/fosil/okupamicoche/dto/UserDto.kt +++ b/src/main/kotlin/eu/fosil/okupamicoche/dto/UserDto.kt @@ -5,34 +5,34 @@ import eu.fosil.okupamicoche.entities.UserId import eu.fosil.okupamicoche.repositories.UserRepository class UserDto( - // Los campos deben ser públicos para que aparezcan en el JSON - val id: UserId, - val username: String, - val matrixId: String, - val name: String, - val email: String?, - val travelsAsDriver: List = emptyList(), - val travelsAsTraveler: List = emptyList() + // Los campos deben ser públicos para que aparezcan en el JSON + val id: UserId, + val username: String, + val matrixId: String, + val name: String, + val email: String?, + val travelsAsDriver: List = emptyList(), + val travelsAsTraveler: List = emptyList() ) { constructor(user: User) : this( - user.id, - user.username, - user.matrixId, - user.name, - user.email, - user.travelsAsDriver.map { t -> TravelDto(t) }, - user.travelsAsTraveler.map { t -> TravelDto(t) } + user.id, + user.username, + user.matrixId, + user.name, + user.email, + user.travelsAsDriver.map { t -> TravelDto(t) }, + user.travelsAsTraveler.map { t -> TravelDto(t) } ) fun toUser(userRepository: UserRepository): User { return User( - id, - username, - matrixId, - name, - email, - travelsAsDriver.map { t -> t.toTravel(userRepository) }, - travelsAsTraveler.map { t -> t.toTravel(userRepository) } + id, + username, + matrixId, + name, + email, + travelsAsDriver.map { t -> t.toTravel(userRepository) }, + travelsAsTraveler.map { t -> t.toTravel(userRepository) } ) } } \ No newline at end of file diff --git a/src/main/kotlin/eu/fosil/okupamicoche/dto/UserInfoDto.kt b/src/main/kotlin/eu/fosil/okupamicoche/dto/UserInfoDto.kt index 4e8b569..dac195e 100644 --- a/src/main/kotlin/eu/fosil/okupamicoche/dto/UserInfoDto.kt +++ b/src/main/kotlin/eu/fosil/okupamicoche/dto/UserInfoDto.kt @@ -4,25 +4,25 @@ import eu.fosil.okupamicoche.entities.User import eu.fosil.okupamicoche.entities.UserId class UserInfoDto( - // Los campos deben ser públicos para que aparezcan en el JSON - val id: UserId, - val username: String, - val matrixId: String, - val name: String + // Los campos deben ser públicos para que aparezcan en el JSON + val id: UserId, + val username: String, + val matrixId: String, + val name: String ) { constructor(user: User) : this( - user.id, - user.username, - user.matrixId, - user.name + user.id, + user.username, + user.matrixId, + user.name ) fun toUser(): User { return User( - id, - username, - matrixId, - name + id, + username, + matrixId, + name ) } } \ No newline at end of file diff --git a/src/main/kotlin/eu/fosil/okupamicoche/entities/Travel.kt b/src/main/kotlin/eu/fosil/okupamicoche/entities/Travel.kt index 73e1c5a..4f78527 100644 --- a/src/main/kotlin/eu/fosil/okupamicoche/entities/Travel.kt +++ b/src/main/kotlin/eu/fosil/okupamicoche/entities/Travel.kt @@ -9,19 +9,19 @@ typealias TravelId = Long @Entity class Travel( - @Id @GeneratedValue var id: TravelId? = null, - @ManyToOne - @LazyCollection(LazyCollectionOption.FALSE) - var driver: User, - @ManyToMany - @LazyCollection(LazyCollectionOption.FALSE) - var travelers: MutableList, - var departureDate: LocalDateTime, - var origin: String, - var destination: String, - var places: Int, - var description: String? = null, - var matrixRoomId: String + @Id @GeneratedValue var id: TravelId? = null, + @ManyToOne + @LazyCollection(LazyCollectionOption.FALSE) + var driver: User, + @ManyToMany + @LazyCollection(LazyCollectionOption.FALSE) + var travelers: MutableList, + var departureDate: LocalDateTime, + var origin: String, + var destination: String, + var places: Int, + var description: String? = null, + var matrixRoomId: String ) { fun users(): Set { val allUsers = mutableSetOf(driver) diff --git a/src/main/kotlin/eu/fosil/okupamicoche/entities/User.kt b/src/main/kotlin/eu/fosil/okupamicoche/entities/User.kt index 43b8e0a..411a819 100644 --- a/src/main/kotlin/eu/fosil/okupamicoche/entities/User.kt +++ b/src/main/kotlin/eu/fosil/okupamicoche/entities/User.kt @@ -2,7 +2,10 @@ package eu.fosil.okupamicoche.entities import org.hibernate.annotations.LazyCollection import org.hibernate.annotations.LazyCollectionOption -import javax.persistence.* +import javax.persistence.Entity +import javax.persistence.Id +import javax.persistence.ManyToMany +import javax.persistence.OneToMany typealias UserId = String @@ -16,6 +19,6 @@ class User( @OneToMany @LazyCollection(LazyCollectionOption.FALSE) var travelsAsDriver: List = emptyList(), - @ManyToMany@LazyCollection(LazyCollectionOption.FALSE) + @ManyToMany @LazyCollection(LazyCollectionOption.FALSE) var travelsAsTraveler: List = emptyList() ) \ No newline at end of file diff --git a/src/main/kotlin/eu/fosil/okupamicoche/entities/UserKeycloak.kt b/src/main/kotlin/eu/fosil/okupamicoche/entities/UserKeycloak.kt index 0cc4778..d745589 100644 --- a/src/main/kotlin/eu/fosil/okupamicoche/entities/UserKeycloak.kt +++ b/src/main/kotlin/eu/fosil/okupamicoche/entities/UserKeycloak.kt @@ -1,31 +1,31 @@ package eu.fosil.okupamicoche.entities class UserKeycloak( - val id: UserId, - val username: String, - val admin: Boolean, - val name: String, - val email: String + val id: UserId, + val username: String, + val admin: Boolean, + val name: String, + val email: String ) { constructor(claims: Map) : this( - claims["sub"].toString(), - claims["preferred_username"].toString(), - try { - claims["admin"] as Boolean - } catch (e: Exception) { - false - }, - claims["name"].toString(), - claims["email"].toString() + claims["sub"].toString(), + claims["preferred_username"].toString(), + try { + claims["admin"] as Boolean + } catch (e: Exception) { + false + }, + claims["name"].toString(), + claims["email"].toString() ) fun toUser(): User { return User( - id, - username, - "@$username:synapse", - name, - email + id, + username, + "@$username:synapse", + name, + email ) } } \ No newline at end of file diff --git a/src/main/kotlin/eu/fosil/okupamicoche/repositories/TravelRepository.kt b/src/main/kotlin/eu/fosil/okupamicoche/repositories/TravelRepository.kt index d5f65f9..297b332 100644 --- a/src/main/kotlin/eu/fosil/okupamicoche/repositories/TravelRepository.kt +++ b/src/main/kotlin/eu/fosil/okupamicoche/repositories/TravelRepository.kt @@ -12,15 +12,17 @@ import org.springframework.data.repository.query.Param interface TravelRepository : PagingAndSortingRepository { @Query("SELECT t FROM Travel t WHERE t.driver.id = :userId") fun findUserTravelsAsDriver(@Param("userId") userId: UserId): List + @Query("SELECT count(t) FROM Travel t WHERE t.driver.id = :userId") fun countUserTravelsAsDriver(@Param("userId") userId: UserId): Long @Query("SELECT t FROM Travel t JOIN t.travelers u WHERE u.id = :userId") fun findUserTravelsAsTraveler(@Param("userId") userId: UserId): List + @Query("SELECT count(t) FROM Travel t JOIN t.travelers u WHERE u.id = :userId") fun countUserTravelsAsTraveler(@Param("userId") userId: UserId): Long fun findByOriginContainingOrDestinationContainingAllIgnoreCase( - filter: String, filter2: String, pageable: Pageable + filter: String, filter2: String, pageable: Pageable ): Page } \ No newline at end of file diff --git a/src/main/kotlin/eu/fosil/okupamicoche/spring/controller/PrivateTravelRestController.kt b/src/main/kotlin/eu/fosil/okupamicoche/spring/controller/PrivateTravelRestController.kt index 8596c98..97b36f5 100644 --- a/src/main/kotlin/eu/fosil/okupamicoche/spring/controller/PrivateTravelRestController.kt +++ b/src/main/kotlin/eu/fosil/okupamicoche/spring/controller/PrivateTravelRestController.kt @@ -12,16 +12,19 @@ import eu.fosil.okupamicoche.usecases.travel.* import mu.KotlinLogging import org.springframework.data.repository.findByIdOrNull import org.springframework.validation.annotation.Validated -import org.springframework.web.bind.annotation.* +import org.springframework.web.bind.annotation.RequestBody +import org.springframework.web.bind.annotation.RequestMapping +import org.springframework.web.bind.annotation.RequestParam +import org.springframework.web.bind.annotation.RestController import java.security.Principal @RestController @RequestMapping("/api/travel") class PrivateTravelRestController( - private val authService: AuthService, - private val userRepository: UserRepository, - private val travelRepository: TravelRepository, - private val useCaseService: UseCaseService + private val authService: AuthService, + private val userRepository: UserRepository, + private val travelRepository: TravelRepository, + private val useCaseService: UseCaseService ) : ApiRestController { private val logger = KotlinLogging.logger {} @@ -29,7 +32,7 @@ class PrivateTravelRestController( suspend fun createTravel(@RequestBody @Validated travel: TravelDto, principal: Principal): ApiResponse { return response { val driver = userRepository.findByIdOrNull(authService.currentUser(principal).id) - ?: throw UserIdNotFoundException("Current user not found.") + ?: throw UserIdNotFoundException("Current user not found.") if (travel.id != null && (travelRepository.findByIdOrNull(travel.id) != null)) throw CannotDuplicateIdException("Travel id already exists.") travel.driverInfo = UserInfoDto(driver) @@ -91,21 +94,21 @@ class PrivateTravelRestController( @RequestMapping("/addtraveler") suspend fun addTraveler( - @RequestParam @Validated travelId: TravelId, - @RequestParam @Validated userId: UserId, - principal: Principal + @RequestParam @Validated travelId: TravelId, + @RequestParam @Validated userId: UserId, + principal: Principal ): ApiResponse { return response { - throwErrorIfCannotEditTravel(travelId,principal) + throwErrorIfCannotEditTravel(travelId, principal) AddTraveler(userRepository, travelRepository).addTraveler(travelId, userId) } } @RequestMapping("/removetraveler") suspend fun removeTraveler( - @RequestParam @Validated travelId: TravelId, - @RequestParam @Validated userId: UserId, - principal: Principal + @RequestParam @Validated travelId: TravelId, + @RequestParam @Validated userId: UserId, + principal: Principal ): ApiResponse { return response { throwErrorIfCannotEditTravel(travelId, principal) @@ -114,9 +117,9 @@ class PrivateTravelRestController( } private fun throwErrorIfCannotEditTravel( - travelId: TravelId?, - principal: Principal, - message: String = "Only admins and travel driver can modify this travel." + travelId: TravelId?, + principal: Principal, + message: String = "Only admins and travel driver can modify this travel." ) { if (!authService.canEditTravel(travelId, principal)) throw InsufficientPermissions(message) diff --git a/src/main/kotlin/eu/fosil/okupamicoche/spring/controller/PrivateUserRestController.kt b/src/main/kotlin/eu/fosil/okupamicoche/spring/controller/PrivateUserRestController.kt index 82db2e5..a0b409f 100644 --- a/src/main/kotlin/eu/fosil/okupamicoche/spring/controller/PrivateUserRestController.kt +++ b/src/main/kotlin/eu/fosil/okupamicoche/spring/controller/PrivateUserRestController.kt @@ -18,8 +18,8 @@ import java.security.Principal @RestController @RequestMapping("/api/user") class PrivateUserRestController( - private val authService: AuthService, - private val userRepository: UserRepository + private val authService: AuthService, + private val userRepository: UserRepository ) : ApiRestController { @RequestMapping("/user") @@ -39,8 +39,8 @@ class PrivateUserRestController( @RequestMapping("/create") suspend fun createUser( - @RequestBody @Validated createUserDto: CreateUserDto, - principal: Principal + @RequestBody @Validated createUserDto: CreateUserDto, + principal: Principal ): ApiResponse { return response { if (!authService.isAdmin(principal)) @@ -80,9 +80,9 @@ class PrivateUserRestController( } private fun throwErrorIfCannotEditUser( - userId: UserId?, - principal: Principal, - message: String = "Only admins and travel driver can modify this user." + userId: UserId?, + principal: Principal, + message: String = "Only admins and travel driver can modify this user." ) { if (!authService.canEditUser(userId, principal)) throw InsufficientPermissions(message) diff --git a/src/main/kotlin/eu/fosil/okupamicoche/spring/controller/PublicRestController.kt b/src/main/kotlin/eu/fosil/okupamicoche/spring/controller/PublicRestController.kt index feb9e99..aec68ef 100644 --- a/src/main/kotlin/eu/fosil/okupamicoche/spring/controller/PublicRestController.kt +++ b/src/main/kotlin/eu/fosil/okupamicoche/spring/controller/PublicRestController.kt @@ -1,14 +1,13 @@ package eu.fosil.okupamicoche.spring.controller -import eu.fosil.okupamicoche.dto.TravelDto import eu.fosil.okupamicoche.dto.ListDto +import eu.fosil.okupamicoche.dto.TravelDto import eu.fosil.okupamicoche.entities.ApiResponse import eu.fosil.okupamicoche.entities.TravelId import eu.fosil.okupamicoche.repositories.TravelRepository import eu.fosil.okupamicoche.usecases.travel.ListTravels import org.springframework.data.repository.findByIdOrNull import org.springframework.validation.annotation.Validated -import org.springframework.web.bind.annotation.CrossOrigin import org.springframework.web.bind.annotation.RequestMapping import org.springframework.web.bind.annotation.RequestParam import org.springframework.web.bind.annotation.RestController @@ -19,17 +18,17 @@ class PublicRestController(private val travelRepository: TravelRepository) : Api @RequestMapping("/list") suspend fun listTravels( - @RequestParam @Validated filter: String?, - @RequestParam @Validated sortColumn: String?, - @RequestParam @Validated sortAscending: Boolean?, - @RequestParam @Validated pageIndex: Int?, - @RequestParam @Validated pageSize: Int?, + @RequestParam @Validated filter: String?, + @RequestParam @Validated sortColumn: String?, + @RequestParam @Validated sortAscending: Boolean?, + @RequestParam @Validated pageIndex: Int?, + @RequestParam @Validated pageSize: Int?, ): ApiResponse> { return response { val travels = - ListTravels(travelRepository).listTravels( - filter, sortColumn, sortAscending, pageIndex, pageSize - ).map { t -> TravelDto(t) } + ListTravels(travelRepository).listTravels( + filter, sortColumn, sortAscending, pageIndex, pageSize + ).map { t -> TravelDto(t) } ListDto(travelRepository.count(), travels) } } diff --git a/src/main/kotlin/eu/fosil/okupamicoche/spring/services/AuthService.kt b/src/main/kotlin/eu/fosil/okupamicoche/spring/services/AuthService.kt index 8d38bfe..6e30873 100644 --- a/src/main/kotlin/eu/fosil/okupamicoche/spring/services/AuthService.kt +++ b/src/main/kotlin/eu/fosil/okupamicoche/spring/services/AuthService.kt @@ -13,7 +13,7 @@ import java.security.Principal @Service class AuthService( - private val travelRepository: TravelRepository + private val travelRepository: TravelRepository ) { private val logger = KotlinLogging.logger {} diff --git a/src/main/kotlin/eu/fosil/okupamicoche/spring/services/MatrixService.kt b/src/main/kotlin/eu/fosil/okupamicoche/spring/services/MatrixService.kt index 2cf3304..f6fbc1c 100644 --- a/src/main/kotlin/eu/fosil/okupamicoche/spring/services/MatrixService.kt +++ b/src/main/kotlin/eu/fosil/okupamicoche/spring/services/MatrixService.kt @@ -18,10 +18,10 @@ class MatrixService(private val matrixClient: MatrixClient) : MatrixApi { logger.debug { "Creating room name=$name alias=$alias" } val usersToInviteId = usersToInvite.stream().map { user -> MatrixId.UserId(user.matrixId) } val roomId = matrixClient.roomsApi.createRoom( - name = name, - roomAliasId = MatrixId.RoomAliasId("#$alias:synapse"), - invite = usersToInviteId.collect(Collectors.toSet()), - topic = topic + name = name, + roomAliasId = MatrixId.RoomAliasId("#$alias:synapse"), + invite = usersToInviteId.collect(Collectors.toSet()), + topic = topic ) return roomId.full } diff --git a/src/main/kotlin/eu/fosil/okupamicoche/spring/services/UseCaseService.kt b/src/main/kotlin/eu/fosil/okupamicoche/spring/services/UseCaseService.kt index 54e3a48..bfe0949 100644 --- a/src/main/kotlin/eu/fosil/okupamicoche/spring/services/UseCaseService.kt +++ b/src/main/kotlin/eu/fosil/okupamicoche/spring/services/UseCaseService.kt @@ -8,9 +8,9 @@ import org.springframework.stereotype.Service @Service class UseCaseService( - private val travelRepository: TravelRepository, - private val matrixService: MatrixService - ): UseCaseFactory { + private val travelRepository: TravelRepository, + private val matrixService: MatrixService +) : UseCaseFactory { override fun getCreateTravel(): CreateTravel { return CreateTravel(travelRepository, getCreateRoomForTravel()) } diff --git a/src/main/kotlin/eu/fosil/okupamicoche/usecases/travel/AddTraveler.kt b/src/main/kotlin/eu/fosil/okupamicoche/usecases/travel/AddTraveler.kt index 54add30..35a4fc1 100644 --- a/src/main/kotlin/eu/fosil/okupamicoche/usecases/travel/AddTraveler.kt +++ b/src/main/kotlin/eu/fosil/okupamicoche/usecases/travel/AddTraveler.kt @@ -7,8 +7,8 @@ import eu.fosil.okupamicoche.repositories.UserRepository import org.springframework.data.repository.findByIdOrNull class AddTraveler( - private val userRepository: UserRepository, - private val travelRepository: TravelRepository + private val userRepository: UserRepository, + private val travelRepository: TravelRepository ) { fun addTraveler(travelId: TravelId, userId: UserId) { val user = userRepository.findByIdOrNull(userId) diff --git a/src/main/kotlin/eu/fosil/okupamicoche/usecases/travel/ListTravels.kt b/src/main/kotlin/eu/fosil/okupamicoche/usecases/travel/ListTravels.kt index c98472e..5ed92b1 100644 --- a/src/main/kotlin/eu/fosil/okupamicoche/usecases/travel/ListTravels.kt +++ b/src/main/kotlin/eu/fosil/okupamicoche/usecases/travel/ListTravels.kt @@ -11,28 +11,28 @@ class ListTravels(private val travelRepository: TravelRepository) { } fun listTravels( - filter: String?, - sortColumn: String?, - sortAscending: Boolean?, - pageIndex: Int?, - pageSize: Int? + filter: String?, + sortColumn: String?, + sortAscending: Boolean?, + pageIndex: Int?, + pageSize: Int? ): List { val sort = if (sortColumn == null) { Sort.unsorted() } else { Sort.by( - if (sortAscending != false) Sort.Direction.ASC else Sort.Direction.DESC, - sortColumn + if (sortAscending != false) Sort.Direction.ASC else Sort.Direction.DESC, + sortColumn ) } return travelRepository.findByOriginContainingOrDestinationContainingAllIgnoreCase( - filter ?: "", - filter ?: "", - PageRequest.of( - pageIndex ?: 0, - pageSize ?: 10, - sort - ) + filter ?: "", + filter ?: "", + PageRequest.of( + pageIndex ?: 0, + pageSize ?: 10, + sort + ) ).toList() } } \ No newline at end of file diff --git a/src/main/kotlin/eu/fosil/okupamicoche/usecases/travel/ListUserTravels.kt b/src/main/kotlin/eu/fosil/okupamicoche/usecases/travel/ListUserTravels.kt index 6b85382..1982bc1 100644 --- a/src/main/kotlin/eu/fosil/okupamicoche/usecases/travel/ListUserTravels.kt +++ b/src/main/kotlin/eu/fosil/okupamicoche/usecases/travel/ListUserTravels.kt @@ -7,8 +7,8 @@ import eu.fosil.okupamicoche.repositories.TravelRepository class ListUserTravels(private val travelRepository: TravelRepository) { fun listUserTravels(idUser: UserId): List { return listOf( - travelRepository.findUserTravelsAsDriver(idUser), - travelRepository.findUserTravelsAsTraveler(idUser) + travelRepository.findUserTravelsAsDriver(idUser), + travelRepository.findUserTravelsAsTraveler(idUser) ).flatten() } diff --git a/src/main/kotlin/eu/fosil/okupamicoche/usecases/travel/RemoveTraveler.kt b/src/main/kotlin/eu/fosil/okupamicoche/usecases/travel/RemoveTraveler.kt index a161fe8..139353c 100644 --- a/src/main/kotlin/eu/fosil/okupamicoche/usecases/travel/RemoveTraveler.kt +++ b/src/main/kotlin/eu/fosil/okupamicoche/usecases/travel/RemoveTraveler.kt @@ -7,8 +7,8 @@ import eu.fosil.okupamicoche.repositories.UserRepository import org.springframework.data.repository.findByIdOrNull class RemoveTraveler( - private val userRepository: UserRepository, - private val travelRepository: TravelRepository + private val userRepository: UserRepository, + private val travelRepository: TravelRepository ) { fun removeTraveler(travelId: TravelId, userId: UserId) { val user = userRepository.findByIdOrNull(userId) diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index fa412f9..1bd3450 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -14,6 +14,9 @@ spring: resourceserver: jwt: issuer-uri: http://localhost:8080/auth/realms/okupamicoche + jackson: + serialization: + write-dates-as-timestamps: false logging: level: