-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b96e34c
commit eed89d6
Showing
5 changed files
with
137 additions
and
6 deletions.
There are no files selected for viewing
52 changes: 51 additions & 1 deletion
52
src/main/kotlin/com/trip/safe/travel/domain/TravelInfoRepository.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,55 @@ | ||
package com.trip.safe.travel.domain | ||
|
||
import com.trip.safe.travel.presentation.dto.response.MyTravelInfoElement | ||
import com.trip.safe.travel.presentation.dto.response.TravelInfoElement | ||
import org.springframework.data.r2dbc.repository.Query | ||
import org.springframework.data.repository.kotlin.CoroutineCrudRepository | ||
import reactor.core.publisher.Flux | ||
|
||
interface TravelInfoRepository : CoroutineCrudRepository<TravelInfo, Long> | ||
interface TravelInfoRepository : CoroutineCrudRepository<TravelInfo, Long> { | ||
|
||
@Query( | ||
""" | ||
SELECT | ||
ti.id, | ||
ti.title, | ||
ti.content, | ||
ti.created_date, | ||
u.account_id | ||
FROM travel_info AS ti | ||
INNER JOIN user AS u | ||
ON ti.user_id = u.id | ||
WHERE ti.travel_destination_id = :travelDestinationId AND ti.is_deleted = false | ||
ORDER BY ti.created_date DESC | ||
LIMIT :limit | ||
OFFSET :offset | ||
""" | ||
) | ||
suspend fun findAllByTravelDestinationId( | ||
travelDestinationId: Long, | ||
limit: Int, | ||
offset: Long, | ||
): Flux<TravelInfoElement> | ||
|
||
@Query( | ||
""" | ||
SELECT | ||
ti.id, | ||
ti.title, | ||
ti.content, | ||
ti.created_date | ||
FROM travel_info AS ti | ||
INNER JOIN user AS u | ||
ON ti.user_id = u.id | ||
WHERE ti.user_id = :userId AND ti.is_deleted = false | ||
ORDER BY ti.created_date DESC | ||
LIMIT :limit | ||
OFFSET :offset | ||
""" | ||
) | ||
suspend fun findAllByUserId( | ||
userId: Long, | ||
limit: Int, | ||
offset: Long, | ||
): Flux<MyTravelInfoElement> | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
src/main/kotlin/com/trip/safe/travel/presentation/dto/response/MyTravelInfoListResponse.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package com.trip.safe.travel.presentation.dto.response | ||
|
||
import java.time.LocalDate | ||
|
||
data class MyTravelInfoListResponse( | ||
val myTravelInfoList: List<MyTravelInfoElement>, | ||
) | ||
|
||
data class MyTravelInfoElement( | ||
val id: Long, | ||
val title: String, | ||
val content: String, | ||
val createdDate: LocalDate, | ||
) | ||
|
||
fun MyTravelInfoElement.toMyTravelInfoElement() = MyTravelInfoElement( | ||
id = this.id, | ||
title = this.title, | ||
content = this.content, | ||
createdDate = this.createdDate, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters