Skip to content

Commit

Permalink
👍 participants 構造変更に伴う対応
Browse files Browse the repository at this point in the history
  • Loading branch information
tatsutakein committed Dec 6, 2023
1 parent 6508515 commit b771955
Show file tree
Hide file tree
Showing 5 changed files with 63 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ package club.nito.core.model.participant
* 参加情報
* @param scheduleId スケジュールID
* @param userId 参加ユーザーID
* @param comment コメント
* @param status 参加状況
*/
public data class Participant(
val scheduleId: String,
val userId: String,
val comment: String,
val status: ParticipantStatus,
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package club.nito.core.model.participant

/**
* 参加状況
*/
public enum class ParticipantStatus {
/**
* 未定
*/
PENDING,

/**
* 出席
*/
ATTENDANCE,

/**
* 欠席
*/
ABSENCE,
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ public class SupabaseParticipantRemoteDataSource(
filter {
and {
eq("schedule_id", scheduleId)
exact("deleted_at", null)
}
}
}
Expand All @@ -35,7 +34,6 @@ public class SupabaseParticipantRemoteDataSource(
filter {
and {
isIn("schedule_id", scheduleIds)
exact("deleted_at", null)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,21 @@ import kotlinx.serialization.Serializable
internal data class NetworkParticipant(
val scheduleId: String,
val userId: String,
val comment: String,
val status: NetworkParticipantStatus,
) {
fun toParticipant() = Participant(
scheduleId = scheduleId,
userId = userId,
comment = comment,
status = status.toParticipantStatus(),
)
}

internal fun createFakeNetworkParticipant(
scheduleId: String = "bbe00d24-d840-460d-a127-f23f9e472cc6",
userId: String = "bbe00d24-d840-460d-a127-f23f9e472cc6",
comment: String = "コメント",
status: NetworkParticipantStatus = NetworkParticipantStatus.ATTENDANCE,
) = NetworkParticipant(
scheduleId = scheduleId,
userId = userId,
comment = comment,
status = status,
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package club.nito.core.network.participation.model

import club.nito.core.model.participant.ParticipantStatus
import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable

/**
* 参加状況
*/
@Serializable
internal enum class NetworkParticipantStatus {
/**
* 未定
*/
@SerialName(value = "pending")
PENDING,

/**
* 出席
*/
@SerialName(value = "attendance")
ATTENDANCE,

/**
* 欠席
*/
@SerialName(value = "absence")
ABSENCE;

fun toParticipantStatus(): ParticipantStatus =
when (this) {
PENDING -> ParticipantStatus.PENDING
ATTENDANCE -> ParticipantStatus.ATTENDANCE
ABSENCE -> ParticipantStatus.ABSENCE
}
}

0 comments on commit b771955

Please sign in to comment.