Skip to content

Commit

Permalink
Merge branch 'dev' into feat/#768
Browse files Browse the repository at this point in the history
# Conflicts:
#	android/festago/presentation/src/main/java/com/festago/festago/presentation/ui/home/festivallist/FestivalListFragment.kt
#	android/festago/presentation/src/main/res/values/strings.xml
  • Loading branch information
SeongHoonC committed Apr 2, 2024
2 parents 8a9e6f5 + ca21e27 commit 03aeb2c
Show file tree
Hide file tree
Showing 249 changed files with 5,268 additions and 5,469 deletions.
7 changes: 7 additions & 0 deletions android/festago/data/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,13 @@ dependencies {
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.4")
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-jdk8:1.6.4")
testImplementation("org.jetbrains.kotlinx:kotlinx-coroutines-test:1.6.4")

// room
val room_version = "2.6.1"
implementation("androidx.room:room-runtime:$room_version")
annotationProcessor("androidx.room:room-compiler:$room_version")
kapt("androidx.room:room-compiler:$room_version")
implementation("androidx.room:room-ktx:$room_version")
}

fun getSecretKey(propertyKey: String): String {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package com.festago.festago.data.dao

import androidx.room.Dao
import androidx.room.Delete
import androidx.room.Query
import androidx.room.Upsert
import com.festago.festago.data.model.RecentSearchQueryEntity

@Dao
interface RecentSearchQueryDao {
@Query(value = "SELECT * FROM recentSearchQueries ORDER BY created_at DESC LIMIT :limit")
suspend fun getRecentSearchQueryEntities(limit: Int): List<RecentSearchQueryEntity>

@Upsert
suspend fun insertOrReplaceRecentSearchQuery(recentSearchQuery: RecentSearchQueryEntity)

@Delete
suspend fun deleteRecentSearchQuery(recentSearchQuery: RecentSearchQueryEntity)

@Query(value = "DELETE FROM recentSearchQueries")
suspend fun clearRecentSearchQueries()
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package com.festago.festago.data.database

import androidx.room.Database
import androidx.room.RoomDatabase
import com.festago.festago.data.dao.RecentSearchQueryDao
import com.festago.festago.data.model.RecentSearchQueryEntity

@Database(entities = [RecentSearchQueryEntity::class], version = 1)
abstract class FestagoDatabase : RoomDatabase() {
abstract fun recentSearchQueryDao(): RecentSearchQueryDao
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package com.festago.festago.data.di.singletonscope

import com.festago.festago.data.dao.RecentSearchQueryDao
import com.festago.festago.data.database.FestagoDatabase
import dagger.Module
import dagger.Provides
import dagger.hilt.InstallIn
import dagger.hilt.components.SingletonComponent

@Module
@InstallIn(SingletonComponent::class)
object DaosModule {

@Provides
fun providesRecentSearchQueryDao(database: FestagoDatabase): RecentSearchQueryDao =
database.recentSearchQueryDao()
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package com.festago.festago.data.di.singletonscope

import android.content.Context
import androidx.room.Room
import com.festago.festago.data.database.FestagoDatabase
import dagger.Module
import dagger.Provides
import dagger.hilt.InstallIn
import dagger.hilt.android.qualifiers.ApplicationContext
import dagger.hilt.components.SingletonComponent
import javax.inject.Singleton

@Module
@InstallIn(SingletonComponent::class)
object DatabaseModule {
@Provides
@Singleton
fun providesFestagoDatabase(
@ApplicationContext context: Context,
): FestagoDatabase = Room.databaseBuilder(
context,
FestagoDatabase::class.java,
"festago-database",
).build()
}
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
package com.festago.festago.data.di.singletonscope

import com.festago.festago.data.repository.DefaultRecentSearchRepository
import com.festago.festago.data.repository.FakeArtistRepository
import com.festago.festago.data.repository.FakeFestivalRepository
import com.festago.festago.data.repository.FakeSchoolRepository
import com.festago.festago.data.repository.FakeSearchRepository
import com.festago.festago.domain.repository.ArtistRepository
import com.festago.festago.domain.repository.FestivalRepository
import com.festago.festago.domain.repository.RecentSearchRepository
import com.festago.festago.domain.repository.SchoolRepository
import com.festago.festago.domain.repository.SearchRepository
import dagger.Binds
import dagger.Module
import dagger.hilt.InstallIn
Expand All @@ -27,4 +31,12 @@ interface RepositoryModule {
@Binds
@Singleton
fun bindsSchoolRepository(schoolRepository: FakeSchoolRepository): SchoolRepository

@Binds
@Singleton
fun bindsRecentSearchRepository(recentSearchRepository: DefaultRecentSearchRepository): RecentSearchRepository

@Binds
@Singleton
fun bindsSearchRepository(searchRepository: FakeSearchRepository): SearchRepository
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package com.festago.festago.data.dto.artist

import com.festago.festago.domain.model.search.ArtistSearch
import kotlinx.serialization.Serializable

@Serializable
data class ArtistSearchResponse(
val id: Long,
val name: String,
val profileImageUrl: String,
val todayStage: Int,
val upcomingStage: Int,
) {
fun toDomain() = ArtistSearch(
id = id,
name = name,
profileImageUrl = profileImageUrl,
todayStage = todayStage,
upcomingStage = upcomingStage,
)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package com.festago.festago.data.dto.school

import com.festago.festago.domain.model.search.SchoolSearch
import kotlinx.serialization.Serializable
import java.time.LocalDate

@Serializable
data class SchoolSearchResponse(
val id: Long,
val name: String,
val logoUrl: String,
val upcomingFestivalStartDate: String?,
) {
fun toDomain() = SchoolSearch(
id = id,
name = name,
logoUrl = logoUrl,
upcomingFestivalStartDate = upcomingFestivalStartDate?.let { LocalDate.parse(it) },
)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package com.festago.festago.data.model

import androidx.room.ColumnInfo
import androidx.room.Entity
import androidx.room.PrimaryKey
import com.festago.festago.domain.model.recentsearch.RecentSearchQuery

@Entity(
tableName = "recentSearchQueries",
)
data class RecentSearchQueryEntity(
@PrimaryKey
val query: String,
@ColumnInfo(name = "created_at")
val createdAt: Long,
) {
fun toDomain() = RecentSearchQuery(query = query, queriedDate = createdAt)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package com.festago.festago.data.repository

import com.festago.festago.data.dao.RecentSearchQueryDao
import com.festago.festago.data.model.RecentSearchQueryEntity
import com.festago.festago.domain.model.recentsearch.RecentSearchQuery
import com.festago.festago.domain.repository.RecentSearchRepository
import kotlinx.coroutines.flow.map
import javax.inject.Inject

class DefaultRecentSearchRepository @Inject constructor(
private val recentSearchQueryDao: RecentSearchQueryDao,
) : RecentSearchRepository {

override suspend fun insertOrReplaceRecentSearch(searchQuery: String) {
recentSearchQueryDao.insertOrReplaceRecentSearchQuery(
RecentSearchQueryEntity(
query = searchQuery,
createdAt = System.currentTimeMillis(),
),
)
}

override suspend fun deleteRecentSearch(searchQuery: String) {
recentSearchQueryDao.deleteRecentSearchQuery(
RecentSearchQueryEntity(
query = searchQuery,
createdAt = System.currentTimeMillis(),
),
)
}

override suspend fun getRecentSearchQueries(limit: Int): List<RecentSearchQuery> {
return recentSearchQueryDao.getRecentSearchQueryEntities(limit).map { recentSearchQueries ->
recentSearchQueries.toDomain()
}
}

override suspend fun clearRecentSearches() = recentSearchQueryDao.clearRecentSearchQueries()
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package com.festago.festago.data.repository

import com.festago.festago.data.service.SearchRetrofitService
import com.festago.festago.data.util.onSuccessOrCatch
import com.festago.festago.data.util.runCatchingResponse
import com.festago.festago.domain.model.festival.Festival
import com.festago.festago.domain.model.search.ArtistSearch
import com.festago.festago.domain.model.search.SchoolSearch
import com.festago.festago.domain.repository.SearchRepository
import javax.inject.Inject

class DefaultSearchRepository @Inject constructor(
private val searchRetrofitService: SearchRetrofitService,
) : SearchRepository {

override suspend fun searchFestivals(searchQuery: String): Result<List<Festival>> {
return runCatchingResponse { searchRetrofitService.searchFestivals(searchQuery) }.onSuccessOrCatch { festivalResponses ->
festivalResponses.map { it.toDomain() }
}
}

override suspend fun searchArtists(searchQuery: String): Result<List<ArtistSearch>> {
return runCatchingResponse {
searchRetrofitService.searchArtists(searchQuery)
}.onSuccessOrCatch { artistSearchResponses -> artistSearchResponses.map { it.toDomain() } }
}

override suspend fun searchSchools(searchQuery: String): Result<List<SchoolSearch>> {
return runCatchingResponse {
searchRetrofitService.searchSchools(searchQuery)
}.onSuccessOrCatch { schoolSearchResponses -> schoolSearchResponses.map { it.toDomain() } }
}
}
Loading

0 comments on commit 03aeb2c

Please sign in to comment.