diff --git a/build-logic/src/main/kotlin/droidknights.android.feature.gradle.kts b/build-logic/src/main/kotlin/droidknights.android.feature.gradle.kts index a13fafce..60c880a7 100644 --- a/build-logic/src/main/kotlin/droidknights.android.feature.gradle.kts +++ b/build-logic/src/main/kotlin/droidknights.android.feature.gradle.kts @@ -8,6 +8,7 @@ plugins { configureHiltAndroid() dependencies { + implementation(project(":core:model")) implementation(project(":core:designsystem")) implementation(project(":core:domain")) implementation(project(":core:navigation")) diff --git a/core/data/build.gradle.kts b/core/data/build.gradle.kts index db62ecb6..3f03faae 100644 --- a/core/data/build.gradle.kts +++ b/core/data/build.gradle.kts @@ -9,8 +9,11 @@ android { } dependencies { + implementation(project(":core:model")) + implementation(libs.retrofit.core) implementation(libs.retrofit.kotlin.serialization) implementation(libs.okhttp.logging) implementation(libs.kotlinx.serialization.json) + implementation(libs.kotlinx.datetime) } diff --git a/core/data/src/main/assets/sessions.json b/core/data/src/main/assets/sessions.json new file mode 100644 index 00000000..5359c96a --- /dev/null +++ b/core/data/src/main/assets/sessions.json @@ -0,0 +1,34 @@ +[ + { + "title": "Keynote", + "content": [], + "speakers": [], + "level": "기타", + "tags": [ + "키노트" + ], + "room": null, + "startTime": "2023-09-12T13:00:00.000", + "endTime": "2023-09-12T13:20:00.000" + }, + { + "title": "Jetpack Compose로 Android UI 개발하기", + "content": [ + "Jetpack Compose는 네이티브 UI를 빌드하기 위한 Android의 최신 권장 도구 키트입니다." + ], + "speakers": [ + { + "name": "김컴포즈", + "imageUrl": "https://developer.android.com/static/courses/android-basics-compose/images/hero-assets/unit-logo.svg" + } + ], + "level": "고급", + "tags": [ + "Jetpack", + "UI" + ], + "room": "Track1", + "startTime": "2023-09-12T13:25:00.000", + "endTime": "2023-09-12T13:55:00.000" + } +] diff --git a/core/data/src/main/java/com/droidknights/app2023/core/data/api/GithubRawApi.kt b/core/data/src/main/java/com/droidknights/app2023/core/data/api/GithubRawApi.kt index c3666ab5..e70867ba 100644 --- a/core/data/src/main/java/com/droidknights/app2023/core/data/api/GithubRawApi.kt +++ b/core/data/src/main/java/com/droidknights/app2023/core/data/api/GithubRawApi.kt @@ -1,5 +1,6 @@ package com.droidknights.app2023.core.data.api +import com.droidknights.app2023.core.data.api.model.SessionResponse import com.droidknights.app2023.core.data.api.model.SponsorResponse import retrofit2.http.GET @@ -7,4 +8,7 @@ internal interface GithubRawApi { @GET("/droidknights/DroidKnights2023_App/main/data/src/main/assets/sponsors.json") suspend fun getSponsors(): List + + @GET("/droidknights/DroidKnights2023_App/main/data/src/main/assets/sessions.json") + suspend fun getSessions(): List } diff --git a/core/data/src/main/java/com/droidknights/app2023/core/data/api/fake/AssetsGithubRawApi.kt b/core/data/src/main/java/com/droidknights/app2023/core/data/api/fake/AssetsGithubRawApi.kt index aa804ecc..9a3b9267 100644 --- a/core/data/src/main/java/com/droidknights/app2023/core/data/api/fake/AssetsGithubRawApi.kt +++ b/core/data/src/main/java/com/droidknights/app2023/core/data/api/fake/AssetsGithubRawApi.kt @@ -2,17 +2,28 @@ package com.droidknights.app2023.core.data.api.fake import android.content.Context import com.droidknights.app2023.core.data.api.GithubRawApi +import com.droidknights.app2023.core.data.api.model.SessionResponse import com.droidknights.app2023.core.data.api.model.SponsorResponse +import kotlinx.serialization.ExperimentalSerializationApi import kotlinx.serialization.json.Json import kotlinx.serialization.json.decodeFromStream +@OptIn(ExperimentalSerializationApi::class) internal class AssetsGithubRawApi( context: Context, - private val json: Json = Json { ignoreUnknownKeys = true }, + private val json: Json = Json { + ignoreUnknownKeys = true + coerceInputValues = true + }, ) : GithubRawApi { - private val assets = context.assets.open("sponsors.json") - + private val sponsors = context.assets.open("sponsors.json") + private val sessions = context.assets.open("sessions.json") + override suspend fun getSponsors(): List { - return json.decodeFromStream(assets) + return json.decodeFromStream(sponsors) + } + + override suspend fun getSessions(): List { + return json.decodeFromStream(sessions) } } diff --git a/core/data/src/main/java/com/droidknights/app2023/core/data/api/model/SessionResponse.kt b/core/data/src/main/java/com/droidknights/app2023/core/data/api/model/SessionResponse.kt new file mode 100644 index 00000000..641755d5 --- /dev/null +++ b/core/data/src/main/java/com/droidknights/app2023/core/data/api/model/SessionResponse.kt @@ -0,0 +1,20 @@ +package com.droidknights.app2023.core.data.api.model + +import com.droidknights.app2023.core.model.Level +import com.droidknights.app2023.core.model.Room +import com.droidknights.app2023.core.model.Speaker +import com.droidknights.app2023.core.model.Tag +import kotlinx.datetime.LocalDateTime +import kotlinx.serialization.Serializable + +@Serializable +internal data class SessionResponse( + val title: String, + val content: List, + val speakers: List, + val level: Level = Level.ETC, + val tags: List = emptyList(), + val room: Room = Room.ETC, + val startTime: LocalDateTime, + val endTime: LocalDateTime, +) diff --git a/core/data/src/main/java/com/droidknights/app2023/core/data/mapper/ContributorMapper.kt b/core/data/src/main/java/com/droidknights/app2023/core/data/mapper/ContributorMapper.kt index 4d70b468..d6172b77 100644 --- a/core/data/src/main/java/com/droidknights/app2023/core/data/mapper/ContributorMapper.kt +++ b/core/data/src/main/java/com/droidknights/app2023/core/data/mapper/ContributorMapper.kt @@ -1,10 +1,10 @@ package com.droidknights.app2023.core.data.mapper -import com.droidknights.app2023.core.data.model.ContributorEntity import com.droidknights.app2023.core.data.api.model.ContributorResponse +import com.droidknights.app2023.core.model.Contributor -internal fun ContributorResponse.toData(): ContributorEntity = - ContributorEntity( +internal fun ContributorResponse.toData(): Contributor = + Contributor( name = this.name, imageUrl = this.imageUrl ) diff --git a/core/data/src/main/java/com/droidknights/app2023/core/data/mapper/SessionMapper.kt b/core/data/src/main/java/com/droidknights/app2023/core/data/mapper/SessionMapper.kt new file mode 100644 index 00000000..a00f3ab9 --- /dev/null +++ b/core/data/src/main/java/com/droidknights/app2023/core/data/mapper/SessionMapper.kt @@ -0,0 +1,15 @@ +package com.droidknights.app2023.core.data.mapper + +import com.droidknights.app2023.core.data.api.model.SessionResponse +import com.droidknights.app2023.core.model.Session + +internal fun SessionResponse.toData(): Session = Session( + title = this.title, + content = this.content, + speakers = this.speakers, + level = this.level, + tags = this.tags, + room = this.room, + startTime = this.startTime, + endTime = this.endTime +) diff --git a/core/data/src/main/java/com/droidknights/app2023/core/data/mapper/SponsorMapper.kt b/core/data/src/main/java/com/droidknights/app2023/core/data/mapper/SponsorMapper.kt index 9a6b46c1..ad7c2fbd 100644 --- a/core/data/src/main/java/com/droidknights/app2023/core/data/mapper/SponsorMapper.kt +++ b/core/data/src/main/java/com/droidknights/app2023/core/data/mapper/SponsorMapper.kt @@ -1,14 +1,14 @@ package com.droidknights.app2023.core.data.mapper import com.droidknights.app2023.core.data.api.model.SponsorResponse -import com.droidknights.app2023.core.data.model.SponsorEntity +import com.droidknights.app2023.core.model.Sponsor -internal fun SponsorResponse.toData(): SponsorEntity = SponsorEntity( +internal fun SponsorResponse.toData(): Sponsor = Sponsor( name = name, imageUrl = imageUrl, homepage = homepage, grade = when (grade) { - SponsorResponse.Grade.PLATINUM -> SponsorEntity.Grade.PLATINUM - SponsorResponse.Grade.GOLD -> SponsorEntity.Grade.GOLD + SponsorResponse.Grade.PLATINUM -> Sponsor.Grade.PLATINUM + SponsorResponse.Grade.GOLD -> Sponsor.Grade.GOLD } ) diff --git a/core/data/src/main/java/com/droidknights/app2023/core/data/model/ContributorEntity.kt b/core/data/src/main/java/com/droidknights/app2023/core/data/model/ContributorEntity.kt deleted file mode 100644 index cb0eb9ca..00000000 --- a/core/data/src/main/java/com/droidknights/app2023/core/data/model/ContributorEntity.kt +++ /dev/null @@ -1,6 +0,0 @@ -package com.droidknights.app2023.core.data.model - -data class ContributorEntity( - val name: String, - val imageUrl: String, -) diff --git a/core/data/src/main/java/com/droidknights/app2023/core/data/model/SponsorEntity.kt b/core/data/src/main/java/com/droidknights/app2023/core/data/model/SponsorEntity.kt deleted file mode 100644 index 690da57b..00000000 --- a/core/data/src/main/java/com/droidknights/app2023/core/data/model/SponsorEntity.kt +++ /dev/null @@ -1,10 +0,0 @@ -package com.droidknights.app2023.core.data.model - -data class SponsorEntity( - val name: String, - val imageUrl: String, - val homepage: String, - val grade: Grade, -) { - enum class Grade { PLATINUM, GOLD, } -} diff --git a/core/data/src/main/java/com/droidknights/app2023/core/data/repository/ContributorRepository.kt b/core/data/src/main/java/com/droidknights/app2023/core/data/repository/ContributorRepository.kt index c384ba8c..91e7ba75 100644 --- a/core/data/src/main/java/com/droidknights/app2023/core/data/repository/ContributorRepository.kt +++ b/core/data/src/main/java/com/droidknights/app2023/core/data/repository/ContributorRepository.kt @@ -1,11 +1,11 @@ package com.droidknights.app2023.core.data.repository -import com.droidknights.app2023.core.data.model.ContributorEntity +import com.droidknights.app2023.core.model.Contributor interface ContributorRepository { suspend fun getContributors( owner: String, name: String, - ): List + ): List } diff --git a/core/data/src/main/java/com/droidknights/app2023/core/data/repository/DefaultContributorRepository.kt b/core/data/src/main/java/com/droidknights/app2023/core/data/repository/DefaultContributorRepository.kt index a96437b4..2c98f8b3 100644 --- a/core/data/src/main/java/com/droidknights/app2023/core/data/repository/DefaultContributorRepository.kt +++ b/core/data/src/main/java/com/droidknights/app2023/core/data/repository/DefaultContributorRepository.kt @@ -1,8 +1,8 @@ package com.droidknights.app2023.core.data.repository -import com.droidknights.app2023.core.data.model.ContributorEntity import com.droidknights.app2023.core.data.api.GithubApi import com.droidknights.app2023.core.data.mapper.toData +import com.droidknights.app2023.core.model.Contributor import javax.inject.Inject internal class DefaultContributorRepository @Inject constructor( @@ -12,7 +12,7 @@ internal class DefaultContributorRepository @Inject constructor( override suspend fun getContributors( owner: String, name: String, - ): List { + ): List { return githubApi.getContributors(owner, name) .map { it.toData() } } diff --git a/core/data/src/main/java/com/droidknights/app2023/core/data/repository/DefaultSessionRepository.kt b/core/data/src/main/java/com/droidknights/app2023/core/data/repository/DefaultSessionRepository.kt new file mode 100644 index 00000000..a0315053 --- /dev/null +++ b/core/data/src/main/java/com/droidknights/app2023/core/data/repository/DefaultSessionRepository.kt @@ -0,0 +1,15 @@ +package com.droidknights.app2023.core.data.repository + +import com.droidknights.app2023.core.data.api.GithubRawApi +import com.droidknights.app2023.core.data.mapper.toData +import com.droidknights.app2023.core.model.Session +import javax.inject.Inject + +internal class DefaultSessionRepository @Inject constructor( + private val githubRawApi: GithubRawApi, +) : SessionRepository { + + override suspend fun getSessions(): List { + return githubRawApi.getSessions().map { it.toData() } + } +} diff --git a/core/data/src/main/java/com/droidknights/app2023/core/data/repository/DefaultSponsorRepository.kt b/core/data/src/main/java/com/droidknights/app2023/core/data/repository/DefaultSponsorRepository.kt index 7f870db8..38945143 100644 --- a/core/data/src/main/java/com/droidknights/app2023/core/data/repository/DefaultSponsorRepository.kt +++ b/core/data/src/main/java/com/droidknights/app2023/core/data/repository/DefaultSponsorRepository.kt @@ -2,14 +2,14 @@ package com.droidknights.app2023.core.data.repository import com.droidknights.app2023.core.data.api.GithubRawApi import com.droidknights.app2023.core.data.mapper.toData -import com.droidknights.app2023.core.data.model.SponsorEntity +import com.droidknights.app2023.core.model.Sponsor import javax.inject.Inject internal class DefaultSponsorRepository @Inject constructor( private val githubRawApi: GithubRawApi, ) : SponsorRepository { - - override suspend fun getSponsors(): List { + + override suspend fun getSponsors(): List { return githubRawApi.getSponsors().map { it.toData() } } } diff --git a/core/data/src/main/java/com/droidknights/app2023/core/data/repository/SessionRepository.kt b/core/data/src/main/java/com/droidknights/app2023/core/data/repository/SessionRepository.kt new file mode 100644 index 00000000..b2b8008e --- /dev/null +++ b/core/data/src/main/java/com/droidknights/app2023/core/data/repository/SessionRepository.kt @@ -0,0 +1,8 @@ +package com.droidknights.app2023.core.data.repository + +import com.droidknights.app2023.core.model.Session + +interface SessionRepository { + + suspend fun getSessions(): List +} diff --git a/core/data/src/main/java/com/droidknights/app2023/core/data/repository/SponsorRepository.kt b/core/data/src/main/java/com/droidknights/app2023/core/data/repository/SponsorRepository.kt index 36c771aa..cd60eca3 100644 --- a/core/data/src/main/java/com/droidknights/app2023/core/data/repository/SponsorRepository.kt +++ b/core/data/src/main/java/com/droidknights/app2023/core/data/repository/SponsorRepository.kt @@ -1,8 +1,8 @@ package com.droidknights.app2023.core.data.repository -import com.droidknights.app2023.core.data.model.SponsorEntity +import com.droidknights.app2023.core.model.Sponsor interface SponsorRepository { - - suspend fun getSponsors(): List + + suspend fun getSponsors(): List } diff --git a/core/data/src/test/java/com/droidknights/app2023/core/data/api/fake/FakeGithubRawApi.kt b/core/data/src/test/java/com/droidknights/app2023/core/data/api/fake/FakeGithubRawApi.kt index 3bae236c..63b1c7da 100644 --- a/core/data/src/test/java/com/droidknights/app2023/core/data/api/fake/FakeGithubRawApi.kt +++ b/core/data/src/test/java/com/droidknights/app2023/core/data/api/fake/FakeGithubRawApi.kt @@ -1,17 +1,28 @@ package com.droidknights.app2023.core.data.api.fake import com.droidknights.app2023.core.data.api.GithubRawApi +import com.droidknights.app2023.core.data.api.model.SessionResponse import com.droidknights.app2023.core.data.api.model.SponsorResponse +import kotlinx.serialization.ExperimentalSerializationApi import kotlinx.serialization.json.Json import kotlinx.serialization.json.decodeFromStream import java.io.File +@OptIn(ExperimentalSerializationApi::class) internal class FakeGithubRawApi( - private val json: Json = Json { ignoreUnknownKeys = true }, + private val json: Json = Json { + ignoreUnknownKeys = true + coerceInputValues = true + }, ) : GithubRawApi { - private val assets = File("src/main/assets/sponsors.json") - + private val sponsors = File("src/main/assets/sponsors.json") + private val sessions = File("src/main/assets/sessions.json") + override suspend fun getSponsors(): List { - return json.decodeFromStream(assets.inputStream()) + return json.decodeFromStream(sponsors.inputStream()) + } + + override suspend fun getSessions(): List { + return json.decodeFromStream(sessions.inputStream()) } } diff --git a/core/data/src/test/java/com/droidknights/app2023/core/data/repository/DefaultContributorRepositoryTest.kt b/core/data/src/test/java/com/droidknights/app2023/core/data/repository/DefaultContributorRepositoryTest.kt index 7a5a944f..2e1e3576 100644 --- a/core/data/src/test/java/com/droidknights/app2023/core/data/repository/DefaultContributorRepositoryTest.kt +++ b/core/data/src/test/java/com/droidknights/app2023/core/data/repository/DefaultContributorRepositoryTest.kt @@ -2,7 +2,7 @@ package com.droidknights.app2023.core.data.repository import com.droidknights.app2023.core.data.api.fake.FakeGithubApi import com.droidknights.app2023.core.data.api.model.ContributorResponse -import com.droidknights.app2023.core.data.model.ContributorEntity +import com.droidknights.app2023.core.model.Contributor import io.kotest.core.spec.style.BehaviorSpec import io.kotest.matchers.shouldBe @@ -18,7 +18,7 @@ internal class DefaultContributorRepositoryTest : BehaviorSpec() { val expected = contributors When("기여자를 조회한다") { - val contributors: List = repository.getContributors( + val contributors: List = repository.getContributors( owner = "droidknights", name = "app2023" ) diff --git a/core/data/src/test/java/com/droidknights/app2023/core/data/repository/DefaultSessionRepositoryTest.kt b/core/data/src/test/java/com/droidknights/app2023/core/data/repository/DefaultSessionRepositoryTest.kt new file mode 100644 index 00000000..b7ee2249 --- /dev/null +++ b/core/data/src/test/java/com/droidknights/app2023/core/data/repository/DefaultSessionRepositoryTest.kt @@ -0,0 +1,54 @@ +package com.droidknights.app2023.core.data.repository + +import com.droidknights.app2023.core.data.api.fake.FakeGithubRawApi +import com.droidknights.app2023.core.model.Level +import com.droidknights.app2023.core.model.Room +import com.droidknights.app2023.core.model.Session +import com.droidknights.app2023.core.model.Speaker +import com.droidknights.app2023.core.model.Tag +import io.kotest.core.spec.style.StringSpec +import io.kotest.matchers.shouldBe +import kotlinx.datetime.LocalDateTime + +internal class DefaultSessionRepositoryTest : StringSpec() { + + init { + val repository: SessionRepository = DefaultSessionRepository( + githubRawApi = FakeGithubRawApi() + ) + "역직렬화 테스트" { + val expected = listOf( + Session( + title = "Keynote", + content = listOf(), + speakers = listOf(), + level = Level.ETC, + tags = listOf(Tag("키노트")), + room = Room.ETC, + startTime = LocalDateTime(2023, 9, 12, 13, 0), + endTime = LocalDateTime(2023, 9, 12, 13, 20), + ), + Session( + title = "Jetpack Compose로 Android UI 개발하기", + content = listOf("Jetpack Compose는 네이티브 UI를 빌드하기 위한 Android의 최신 권장 도구 키트입니다."), + speakers = listOf( + Speaker( + name = "김컴포즈", + imageUrl = "https://developer.android.com/static/courses/android-basics-compose/images/hero-assets/unit-logo.svg", + ) + ), + level = Level.ADVANCED, + tags = listOf( + Tag("Jetpack"), + Tag("UI"), + ), + room = Room.TRACK1, + startTime = LocalDateTime(2023, 9, 12, 13, 25), + endTime = LocalDateTime(2023, 9, 12, 13, 55), + ), + ) + val actual = repository.getSessions() + actual shouldBe expected + } + } +} diff --git a/core/data/src/test/java/com/droidknights/app2023/core/data/repository/DefaultSponsorRepositoryTest.kt b/core/data/src/test/java/com/droidknights/app2023/core/data/repository/DefaultSponsorRepositoryTest.kt index 8098301d..706d20bc 100644 --- a/core/data/src/test/java/com/droidknights/app2023/core/data/repository/DefaultSponsorRepositoryTest.kt +++ b/core/data/src/test/java/com/droidknights/app2023/core/data/repository/DefaultSponsorRepositoryTest.kt @@ -1,13 +1,13 @@ package com.droidknights.app2023.core.data.repository import com.droidknights.app2023.core.data.api.fake.FakeGithubRawApi -import com.droidknights.app2023.core.data.model.SponsorEntity +import com.droidknights.app2023.core.model.Sponsor import io.kotest.core.spec.style.StringSpec import io.kotest.matchers.shouldBe import kotlinx.serialization.json.Json internal class DefaultSponsorRepositoryTest : StringSpec() { - + init { val repository: SponsorRepository = DefaultSponsorRepository( githubRawApi = FakeGithubRawApi( @@ -15,11 +15,11 @@ internal class DefaultSponsorRepositoryTest : StringSpec() { ) ) "역직렬화 테스트" { - val expected = SponsorEntity( + val expected = Sponsor( name = "헤이딜러", imageUrl = "https://raw.githubusercontent.com/droidknights/DroidKnights2020_App/master/androidapp/app/src/main/res/drawable-xxxhdpi/ic_sponsor_heydealer.png", homepage = "https://heydealer.co.kr/", - grade = SponsorEntity.Grade.GOLD, + grade = Sponsor.Grade.GOLD, ) val actual = repository.getSponsors().first() actual shouldBe expected diff --git a/core/domain/build.gradle.kts b/core/domain/build.gradle.kts index 58c1ad1e..b323e82c 100644 --- a/core/domain/build.gradle.kts +++ b/core/domain/build.gradle.kts @@ -8,6 +8,7 @@ android { dependencies { implementation(project(":core:data")) + implementation(project(":core:model")) implementation(libs.inject) } diff --git a/core/domain/src/main/java/com/droidknights/app2023/core/domain/mapper/ContributorMapper.kt b/core/domain/src/main/java/com/droidknights/app2023/core/domain/mapper/ContributorMapper.kt deleted file mode 100644 index 4d56c4b0..00000000 --- a/core/domain/src/main/java/com/droidknights/app2023/core/domain/mapper/ContributorMapper.kt +++ /dev/null @@ -1,10 +0,0 @@ -package com.droidknights.app2023.core.domain.mapper - -import com.droidknights.app2023.core.data.model.ContributorEntity -import com.droidknights.app2023.core.domain.model.Contributor - -internal fun ContributorEntity.toDomain(): Contributor = - Contributor( - name = this.name, - imageUrl = this.imageUrl - ) diff --git a/core/domain/src/main/java/com/droidknights/app2023/core/domain/mapper/SponsorMapper.kt b/core/domain/src/main/java/com/droidknights/app2023/core/domain/mapper/SponsorMapper.kt deleted file mode 100644 index 0ea562fd..00000000 --- a/core/domain/src/main/java/com/droidknights/app2023/core/domain/mapper/SponsorMapper.kt +++ /dev/null @@ -1,14 +0,0 @@ -package com.droidknights.app2023.core.domain.mapper - -import com.droidknights.app2023.core.data.model.SponsorEntity -import com.droidknights.app2023.core.domain.model.Sponsor - -internal fun SponsorEntity.toDomain(): Sponsor = Sponsor( - name = name, - imageUrl = imageUrl, - homepage = homepage, - grade = when (grade) { - SponsorEntity.Grade.PLATINUM -> Sponsor.Grade.PLATINUM - SponsorEntity.Grade.GOLD -> Sponsor.Grade.GOLD - } -) diff --git a/core/domain/src/main/java/com/droidknights/app2023/core/domain/usecase/GetContributorsUseCase.kt b/core/domain/src/main/java/com/droidknights/app2023/core/domain/usecase/GetContributorsUseCase.kt index f7409d75..9f8ae91a 100644 --- a/core/domain/src/main/java/com/droidknights/app2023/core/domain/usecase/GetContributorsUseCase.kt +++ b/core/domain/src/main/java/com/droidknights/app2023/core/domain/usecase/GetContributorsUseCase.kt @@ -1,9 +1,7 @@ package com.droidknights.app2023.core.domain.usecase -import com.droidknights.app2023.core.data.model.ContributorEntity import com.droidknights.app2023.core.data.repository.ContributorRepository -import com.droidknights.app2023.core.domain.mapper.toDomain -import com.droidknights.app2023.core.domain.model.Contributor +import com.droidknights.app2023.core.model.Contributor import javax.inject.Inject class GetContributorsUseCase @Inject constructor( @@ -13,7 +11,7 @@ class GetContributorsUseCase @Inject constructor( return repository.getContributors( owner = OWNER, name = NAME, - ).map(ContributorEntity::toDomain) + ) } companion object { diff --git a/core/domain/src/main/java/com/droidknights/app2023/core/domain/usecase/GetSponsorsUseCase.kt b/core/domain/src/main/java/com/droidknights/app2023/core/domain/usecase/GetSponsorsUseCase.kt index 00f895cb..1e16615e 100644 --- a/core/domain/src/main/java/com/droidknights/app2023/core/domain/usecase/GetSponsorsUseCase.kt +++ b/core/domain/src/main/java/com/droidknights/app2023/core/domain/usecase/GetSponsorsUseCase.kt @@ -1,15 +1,14 @@ package com.droidknights.app2023.core.domain.usecase import com.droidknights.app2023.core.data.repository.SponsorRepository -import com.droidknights.app2023.core.domain.mapper.toDomain -import com.droidknights.app2023.core.domain.model.Sponsor +import com.droidknights.app2023.core.model.Sponsor import javax.inject.Inject class GetSponsorsUseCase @Inject constructor( private val sponsorRepository: SponsorRepository, ) { - + suspend operator fun invoke(): List { - return sponsorRepository.getSponsors().map { it.toDomain() } + return sponsorRepository.getSponsors() } } diff --git a/core/domain/src/test/java/com/droidknights/app2023/core/domain/usecase/GetContributorsUseCaseTest.kt b/core/domain/src/test/java/com/droidknights/app2023/core/domain/usecase/GetContributorsUseCaseTest.kt index b71f5f12..6d34c728 100644 --- a/core/domain/src/test/java/com/droidknights/app2023/core/domain/usecase/GetContributorsUseCaseTest.kt +++ b/core/domain/src/test/java/com/droidknights/app2023/core/domain/usecase/GetContributorsUseCaseTest.kt @@ -1,7 +1,7 @@ package com.droidknights.app2023.core.domain.usecase import com.droidknights.app2023.core.data.model.ContributorEntity -import com.droidknights.app2023.core.domain.model.Contributor +import com.droidknights.app2023.core.model.Contributor import io.kotest.core.spec.style.BehaviorSpec import io.kotest.matchers.shouldBe diff --git a/core/model/.gitignore b/core/model/.gitignore new file mode 100644 index 00000000..42afabfd --- /dev/null +++ b/core/model/.gitignore @@ -0,0 +1 @@ +/build \ No newline at end of file diff --git a/core/model/build.gradle.kts b/core/model/build.gradle.kts new file mode 100644 index 00000000..ff929e72 --- /dev/null +++ b/core/model/build.gradle.kts @@ -0,0 +1,9 @@ +plugins { + id("droidknights.kotlin.library") + id("kotlinx-serialization") +} + +dependencies { + implementation(libs.kotlinx.serialization.json) + implementation(libs.kotlinx.datetime) +} diff --git a/core/domain/src/main/java/com/droidknights/app2023/core/domain/model/Contributor.kt b/core/model/src/main/java/com/droidknights/app2023/core/model/Contributor.kt similarity index 59% rename from core/domain/src/main/java/com/droidknights/app2023/core/domain/model/Contributor.kt rename to core/model/src/main/java/com/droidknights/app2023/core/model/Contributor.kt index 2c3a440b..5018e81e 100644 --- a/core/domain/src/main/java/com/droidknights/app2023/core/domain/model/Contributor.kt +++ b/core/model/src/main/java/com/droidknights/app2023/core/model/Contributor.kt @@ -1,4 +1,4 @@ -package com.droidknights.app2023.core.domain.model +package com.droidknights.app2023.core.model data class Contributor( val name: String, diff --git a/core/model/src/main/java/com/droidknights/app2023/core/model/Session.kt b/core/model/src/main/java/com/droidknights/app2023/core/model/Session.kt new file mode 100644 index 00000000..594c6f92 --- /dev/null +++ b/core/model/src/main/java/com/droidknights/app2023/core/model/Session.kt @@ -0,0 +1,50 @@ +package com.droidknights.app2023.core.model + +import kotlinx.datetime.LocalDateTime +import kotlinx.serialization.SerialName +import kotlinx.serialization.Serializable + +@Serializable +data class Session( + val title: String, + val content: List, + val speakers: List, + val level: Level, + val tags: List, + val room: Room, + val startTime: LocalDateTime, + val endTime: LocalDateTime, +) + +@Serializable +enum class Level { + @SerialName("기타") + ETC, + + @SerialName("초급") + BASIC, + + @SerialName("중급") + INTERMEDIATE, + + @SerialName("고급") + ADVANCED +} + +@Serializable +@JvmInline +value class Tag(val name: String) + +@Serializable +enum class Room { + ETC, + + @SerialName("Track1") + TRACK1, + + @SerialName("Track2") + TRACK2, + + @SerialName("Track3") + TRACK3 +} diff --git a/core/model/src/main/java/com/droidknights/app2023/core/model/Speaker.kt b/core/model/src/main/java/com/droidknights/app2023/core/model/Speaker.kt new file mode 100644 index 00000000..80b0c2ef --- /dev/null +++ b/core/model/src/main/java/com/droidknights/app2023/core/model/Speaker.kt @@ -0,0 +1,9 @@ +package com.droidknights.app2023.core.model + +import kotlinx.serialization.Serializable + +@Serializable +data class Speaker( + val name: String, + val imageUrl: String, +) diff --git a/core/domain/src/main/java/com/droidknights/app2023/core/domain/model/Sponsor.kt b/core/model/src/main/java/com/droidknights/app2023/core/model/Sponsor.kt similarity index 76% rename from core/domain/src/main/java/com/droidknights/app2023/core/domain/model/Sponsor.kt rename to core/model/src/main/java/com/droidknights/app2023/core/model/Sponsor.kt index c3568309..911afecc 100644 --- a/core/domain/src/main/java/com/droidknights/app2023/core/domain/model/Sponsor.kt +++ b/core/model/src/main/java/com/droidknights/app2023/core/model/Sponsor.kt @@ -1,4 +1,4 @@ -package com.droidknights.app2023.core.domain.model +package com.droidknights.app2023.core.model data class Sponsor( val name: String, diff --git a/feature/contributor/src/androidTest/java/com/droidknights/app2023/feature/contributor/ContributorScreenTest.kt b/feature/contributor/src/androidTest/java/com/droidknights/app2023/feature/contributor/ContributorScreenTest.kt index 64b62811..d5d1ff6a 100644 --- a/feature/contributor/src/androidTest/java/com/droidknights/app2023/feature/contributor/ContributorScreenTest.kt +++ b/feature/contributor/src/androidTest/java/com/droidknights/app2023/feature/contributor/ContributorScreenTest.kt @@ -5,7 +5,7 @@ import androidx.compose.runtime.MutableState import androidx.compose.runtime.mutableStateOf import androidx.compose.ui.test.junit4.createAndroidComposeRule import androidx.compose.ui.test.onNodeWithText -import com.droidknights.app2023.core.domain.model.Contributor +import com.droidknights.app2023.core.model.Contributor import org.junit.Before import org.junit.Rule import org.junit.Test diff --git a/feature/contributor/src/main/java/com/droidknights/app2023/feature/contributor/ContributorScreen.kt b/feature/contributor/src/main/java/com/droidknights/app2023/feature/contributor/ContributorScreen.kt index 89a6b2b5..ca86d95c 100644 --- a/feature/contributor/src/main/java/com/droidknights/app2023/feature/contributor/ContributorScreen.kt +++ b/feature/contributor/src/main/java/com/droidknights/app2023/feature/contributor/ContributorScreen.kt @@ -24,7 +24,7 @@ import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.unit.dp import androidx.hilt.navigation.compose.hiltViewModel import androidx.lifecycle.compose.collectAsStateWithLifecycle -import com.droidknights.app2023.core.domain.model.Contributor +import com.droidknights.app2023.core.model.Contributor @Composable fun ContributorRoute( @@ -133,8 +133,14 @@ private fun ContributorScreenPreview() { ContributorScreen( uiState = ContributorsUiState.Contributors( listOf( - Contributor("Contributor1", "https://avatars.githubusercontent.com/u/25101514"), - Contributor("Contributor2", "https://avatars.githubusercontent.com/u/25101514"), + Contributor( + "Contributor1", + "https://avatars.githubusercontent.com/u/25101514" + ), + Contributor( + "Contributor2", + "https://avatars.githubusercontent.com/u/25101514" + ), ) ) ) diff --git a/feature/contributor/src/main/java/com/droidknights/app2023/feature/contributor/ContributorsUiState.kt b/feature/contributor/src/main/java/com/droidknights/app2023/feature/contributor/ContributorsUiState.kt index 45886b2d..c6da3690 100644 --- a/feature/contributor/src/main/java/com/droidknights/app2023/feature/contributor/ContributorsUiState.kt +++ b/feature/contributor/src/main/java/com/droidknights/app2023/feature/contributor/ContributorsUiState.kt @@ -1,6 +1,6 @@ package com.droidknights.app2023.feature.contributor -import com.droidknights.app2023.core.domain.model.Contributor +import com.droidknights.app2023.core.model.Contributor sealed interface ContributorsUiState { object Loading : ContributorsUiState diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 2f843d00..646378f6 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -15,6 +15,7 @@ okhttp = "4.11.0" retrofit = "2.9.0" retrofitKotlinxSerializationJson = "1.0.0" kotlinxSerializationJson = "1.5.1" +kotlinxDatetime = "0.2.1" junit4 = "4.13.2" kotlin = "1.8.21" @@ -60,6 +61,7 @@ okhttp-logging = { group = "com.squareup.okhttp3", name = "logging-interceptor", retrofit-core = { group = "com.squareup.retrofit2", name = "retrofit", version.ref = "retrofit" } retrofit-kotlin-serialization = { group = "com.jakewharton.retrofit", name = "retrofit2-kotlinx-serialization-converter", version.ref = "retrofitKotlinxSerializationJson" } kotlinx-serialization-json = { group = "org.jetbrains.kotlinx", name = "kotlinx-serialization-json", version.ref = "kotlinxSerializationJson" } +kotlinx-datetime = { group = "org.jetbrains.kotlinx", name = "kotlinx-datetime", version.ref = "kotlinxDatetime" } junit4 = { group = "junit", name = "junit", version.ref = "junit4" } androidx-test-ext = { group = "androidx.test.ext", name = "junit-ktx", version.ref = "androidxTestExt" } diff --git a/settings.gradle.kts b/settings.gradle.kts index 23192496..234b89a6 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -23,6 +23,7 @@ include( ":core:data", ":core:domain", ":core:navigation", + ":core:model", ":feature:main", ":feature:home",