-
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.
Merge pull request #121 from 2rabs/rt/add-fetch-participant-schedule-…
…by-id-usecase ✨ ID を元にスケジュールを取得するユースケースを追加
- Loading branch information
Showing
17 changed files
with
199 additions
and
12 deletions.
There are no files selected for viewing
13 changes: 13 additions & 0 deletions
13
core/data/src/commonMain/kotlin/club/nito/core/data/DefaultPlaceRepository.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,13 @@ | ||
package club.nito.core.data | ||
|
||
import club.nito.core.model.place.Place | ||
import club.nito.core.model.place.PlaceId | ||
import club.nito.core.network.place.PlaceRemoteDataSource | ||
|
||
public class DefaultPlaceRepository( | ||
private val remoteDataSource: PlaceRemoteDataSource, | ||
) : PlaceRepository { | ||
override suspend fun fetchPlaceList(vararg ids: PlaceId): List<Place> { | ||
return remoteDataSource.fetchPlaceList(ids.toList()) | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
core/data/src/commonMain/kotlin/club/nito/core/data/PlaceRepository.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,15 @@ | ||
package club.nito.core.data | ||
|
||
import club.nito.core.model.place.Place | ||
import club.nito.core.model.place.PlaceId | ||
|
||
/** | ||
* 場所に関するリポジトリ | ||
*/ | ||
public sealed interface PlaceRepository { | ||
/** | ||
* 場所を取得する | ||
* @param ids 取得する場所のID | ||
*/ | ||
public suspend fun fetchPlaceList(vararg ids: PlaceId): List<Place> | ||
} |
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
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
5 changes: 3 additions & 2 deletions
5
core/domain/src/commonMain/kotlin/club/nito/core/domain/model/ParticipantSchedule.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,15 +1,16 @@ | ||
package club.nito.core.domain.model | ||
|
||
import club.nito.core.model.UserProfile | ||
import club.nito.core.model.place.Place | ||
import club.nito.core.model.schedule.ScheduleId | ||
import kotlinx.datetime.Instant | ||
|
||
public data class ParticipantSchedule( | ||
val id: ScheduleId, | ||
val scheduledAt: Instant, | ||
val metAt: Instant, | ||
val venueId: String, | ||
val meetId: String, | ||
val venue: Place, | ||
val meet: Place, | ||
val description: String, | ||
val participants: List<UserProfile>, | ||
) |
17 changes: 17 additions & 0 deletions
17
core/model/src/commonMain/kotlin/club/nito/core/model/place/Place.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,17 @@ | ||
package club.nito.core.model.place | ||
|
||
/** | ||
* 場所 | ||
* @param id ID | ||
* @param name 名前 | ||
* @param description 説明文 | ||
* @param mapUrl 地図URL | ||
* @param imageUrl 画像URL | ||
*/ | ||
public data class Place( | ||
val id: PlaceId, | ||
val name: String, | ||
val description: String, | ||
val mapUrl: String, | ||
val imageUrl: String, | ||
) |
6 changes: 6 additions & 0 deletions
6
core/model/src/commonMain/kotlin/club/nito/core/model/place/PlaceId.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,6 @@ | ||
package club.nito.core.model.place | ||
|
||
/** | ||
* 場所ID | ||
*/ | ||
public typealias PlaceId = String |
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
14 changes: 14 additions & 0 deletions
14
core/network/src/commonMain/kotlin/club/nito/core/network/place/FakePlaceRemoteDataSource.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,14 @@ | ||
package club.nito.core.network.place | ||
|
||
import club.nito.core.model.place.Place | ||
import club.nito.core.model.place.PlaceId | ||
import club.nito.core.network.place.model.NetworkPlace | ||
import club.nito.core.network.place.model.createFakeNetworkPlace | ||
|
||
public data object FakePlaceRemoteDataSource : PlaceRemoteDataSource { | ||
override suspend fun fetchPlaceList(idList: List<PlaceId>): List<Place> = idList.map { id -> | ||
createFakeNetworkPlace( | ||
id = id, | ||
).let(NetworkPlace::toPlace) | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
core/network/src/commonMain/kotlin/club/nito/core/network/place/PlaceRemoteDataSource.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,15 @@ | ||
package club.nito.core.network.place | ||
|
||
import club.nito.core.model.place.Place | ||
import club.nito.core.model.place.PlaceId | ||
|
||
/** | ||
* 場所リモートデータソース | ||
*/ | ||
public sealed interface PlaceRemoteDataSource { | ||
/** | ||
* リモートから場所を取得する | ||
* @param idList 取得する場所のID | ||
*/ | ||
public suspend fun fetchPlaceList(idList: List<PlaceId>): List<Place> | ||
} |
32 changes: 32 additions & 0 deletions
32
...twork/src/commonMain/kotlin/club/nito/core/network/place/SupabasePlaceRemoteDataSource.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,32 @@ | ||
package club.nito.core.network.place | ||
|
||
import club.nito.core.model.place.Place | ||
import club.nito.core.model.place.PlaceId | ||
import club.nito.core.network.NetworkService | ||
import club.nito.core.network.place.model.NetworkPlace | ||
import io.github.jan.supabase.SupabaseClient | ||
import io.github.jan.supabase.postgrest.postgrest | ||
|
||
private enum class Column(val columnName: String) { | ||
ID(columnName = "id"), | ||
DELETED_AT(columnName = "deleted_at"), | ||
} | ||
|
||
public class SupabasePlaceRemoteDataSource( | ||
private val networkService: NetworkService, | ||
private val client: SupabaseClient, | ||
) : PlaceRemoteDataSource { | ||
private val postgrest = client.postgrest["places"] | ||
|
||
override suspend fun fetchPlaceList(idList: List<PlaceId>): List<Place> = networkService { | ||
postgrest | ||
.select { | ||
filter { | ||
isIn(Column.ID.columnName, idList) | ||
exact(Column.DELETED_AT.columnName, null) | ||
} | ||
} | ||
.decodeList<NetworkPlace>() | ||
.map(NetworkPlace::toPlace) | ||
} | ||
} |
Oops, something went wrong.