-
Notifications
You must be signed in to change notification settings - Fork 267
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 #557 from miga9/feature-staff
Add staff list page
- Loading branch information
Showing
46 changed files
with
749 additions
and
6 deletions.
There are no files selected for viewing
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
11 changes: 11 additions & 0 deletions
11
...Main/kotlin/io/github/droidkaigi/confsched2019/data/api/response/StaffItemResponseImpl.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,11 @@ | ||
package io.github.droidkaigi.confsched2019.data.api.response | ||
|
||
import kotlinx.serialization.Serializable | ||
|
||
@Serializable | ||
data class StaffItemResponseImpl( | ||
override val id: String?, | ||
override val name: String?, | ||
override val iconUrl: String?, | ||
override val profileUrl: String? | ||
) : StaffItemResponse |
8 changes: 8 additions & 0 deletions
8
...mmonMain/kotlin/io/github/droidkaigi/confsched2019/data/api/response/StaffResponseImpl.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,8 @@ | ||
package io.github.droidkaigi.confsched2019.data.api.response | ||
|
||
import kotlinx.serialization.Serializable | ||
|
||
@Serializable | ||
data class StaffResponseImpl( | ||
override val staffs: List<StaffItemResponseImpl> | ||
) : StaffResponse |
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
8 changes: 8 additions & 0 deletions
8
...mmonMain/kotlin/io/github/droidkaigi/confsched2019/data/api/response/StaffItemResponse.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,8 @@ | ||
package io.github.droidkaigi.confsched2019.data.api.response | ||
|
||
interface StaffItemResponse { | ||
val id: String? | ||
val name: String? | ||
val iconUrl: String? | ||
val profileUrl: String? | ||
} |
5 changes: 5 additions & 0 deletions
5
...c/commonMain/kotlin/io/github/droidkaigi/confsched2019/data/api/response/StaffResponse.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,5 @@ | ||
package io.github.droidkaigi.confsched2019.data.api.response | ||
|
||
interface StaffResponse { | ||
val staffs: List<StaffItemResponse> | ||
} |
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
19 changes: 19 additions & 0 deletions
19
data/db-room/src/main/java/io/github/droidkaigi/confsched2019/data/db/dao/StaffDao.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,19 @@ | ||
package io.github.droidkaigi.confsched2019.data.db.dao | ||
|
||
import androidx.room.Dao | ||
import androidx.room.Insert | ||
import androidx.room.OnConflictStrategy | ||
import androidx.room.Query | ||
import io.github.droidkaigi.confsched2019.data.db.entity.StaffEntityImpl | ||
|
||
@Dao | ||
abstract class StaffDao { | ||
@Query("SELECT * FROM staff") | ||
abstract suspend fun allStaffs(): List<StaffEntityImpl> | ||
|
||
@Insert(onConflict = OnConflictStrategy.REPLACE) | ||
abstract fun insert(staffs: List<StaffEntityImpl>) | ||
|
||
@Query("DELETE FROM staff") | ||
abstract fun deleteAll() | ||
} |
16 changes: 16 additions & 0 deletions
16
...b-room/src/main/java/io/github/droidkaigi/confsched2019/data/db/entity/StaffEntityImpl.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,16 @@ | ||
package io.github.droidkaigi.confsched2019.data.db.entity | ||
|
||
import androidx.room.ColumnInfo | ||
import androidx.room.Entity | ||
import androidx.room.PrimaryKey | ||
|
||
@Entity(tableName = "staff") | ||
class StaffEntityImpl( | ||
@PrimaryKey override var id: String, | ||
@ColumnInfo(name = "staff_name") | ||
override var name: String, | ||
@ColumnInfo(name = "staff_icon_url") | ||
override var iconUrl: String?, | ||
@ColumnInfo(name = "staff_profile_url") | ||
override var profileUrl: String? | ||
) : StaffEntity |
17 changes: 17 additions & 0 deletions
17
.../main/java/io/github/droidkaigi/confsched2019/data/db/entity/mapper/StaffDataMapperExt.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 io.github.droidkaigi.confsched2019.data.db.entity.mapper | ||
|
||
import io.github.droidkaigi.confsched2019.data.api.response.StaffItemResponse | ||
import io.github.droidkaigi.confsched2019.data.db.entity.StaffEntityImpl | ||
|
||
fun List<StaffItemResponse>.toStaffEntities(): List<StaffEntityImpl> = map { | ||
it.toStaffEntityImpl() | ||
} | ||
|
||
fun StaffItemResponse.toStaffEntityImpl(): StaffEntityImpl { | ||
return StaffEntityImpl( | ||
id = requireNotNull(id), | ||
name = requireNotNull(name), | ||
iconUrl = iconUrl, | ||
profileUrl = profileUrl | ||
) | ||
} |
9 changes: 9 additions & 0 deletions
9
data/db/src/commonMain/kotlin/io/github/droidkaigi/confsched2019/data/db/StaffDatabase.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,9 @@ | ||
package io.github.droidkaigi.confsched2019.data.db | ||
|
||
import io.github.droidkaigi.confsched2019.data.api.response.StaffResponse | ||
import io.github.droidkaigi.confsched2019.data.db.entity.StaffEntity | ||
|
||
interface StaffDatabase { | ||
suspend fun staffs(): List<StaffEntity> | ||
suspend fun save(apiResponse: StaffResponse) | ||
} |
8 changes: 8 additions & 0 deletions
8
...db/src/commonMain/kotlin/io/github/droidkaigi/confsched2019/data/db/entity/StaffEntity.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,8 @@ | ||
package io.github.droidkaigi.confsched2019.data.db.entity | ||
|
||
interface StaffEntity { | ||
var id: String | ||
var name: String | ||
var iconUrl: String? | ||
var profileUrl: String? | ||
} |
26 changes: 26 additions & 0 deletions
26
...l/src/main/java/io/github/droidkaigi/confsched2019/data/repository/DataStaffRepository.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,26 @@ | ||
package io.github.droidkaigi.confsched2019.data.repository | ||
|
||
import io.github.droidkaigi.confsched2019.data.api.DroidKaigiApi | ||
import io.github.droidkaigi.confsched2019.data.db.StaffDatabase | ||
import io.github.droidkaigi.confsched2019.data.db.entity.StaffEntity | ||
import io.github.droidkaigi.confsched2019.model.Staff | ||
import io.github.droidkaigi.confsched2019.model.StaffContents | ||
import javax.inject.Inject | ||
|
||
class DataStaffRepository @Inject constructor( | ||
private val api: DroidKaigiApi, | ||
private val staffDatabase: StaffDatabase | ||
) : StaffRepository { | ||
override suspend fun staffContents() = StaffContents(staffs()) | ||
|
||
override suspend fun refresh() { | ||
val response = api.getStaffs() | ||
staffDatabase.save(response) | ||
} | ||
|
||
private suspend fun staffs() = staffDatabase | ||
.staffs() | ||
.map { it.toStaff() } | ||
} | ||
|
||
private fun StaffEntity.toStaff(): Staff = Staff(id, name, iconUrl, profileUrl) |
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
8 changes: 8 additions & 0 deletions
8
...c/commonMain/kotlin/io/github/droidkaigi/confsched2019/data/repository/StaffRepository.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,8 @@ | ||
package io.github.droidkaigi.confsched2019.data.repository | ||
|
||
import io.github.droidkaigi.confsched2019.model.StaffContents | ||
|
||
interface StaffRepository { | ||
suspend fun staffContents(): StaffContents | ||
suspend fun refresh() | ||
} |
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
Oops, something went wrong.