Skip to content

Commit

Permalink
Merge branch 'dev' into feat/#811
Browse files Browse the repository at this point in the history
# Conflicts:
#	backend/src/test/java/com/festago/artist/application/integration/ArtistDetailV1QueryServiceIntegrationTest.java
  • Loading branch information
seokjin8678 committed Apr 3, 2024
2 parents 89e3993 + 81433dd commit 71e1a77
Show file tree
Hide file tree
Showing 212 changed files with 8,263 additions and 158 deletions.
28 changes: 15 additions & 13 deletions .github/workflows/cd-back-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ on:
push:
branches:
- dev
paths: 'backend/**'
paths:
- 'backend/**'
workflow_dispatch:

concurrency:
Expand Down Expand Up @@ -37,22 +38,23 @@ jobs:
- name: bootJar with gradle
run: ./gradlew bootJar

# 2023-11-23 기준 EC2 프리티어 사용으로 인해 DEV 환경을 PROD 환경에서 실행함
- name: deploy use scp
uses: appleboy/scp-action@master
- name: Docker Login
uses: docker/[email protected]
with:
host: ${{secrets.FESTAGO_PROD_IP}}
username: ${{secrets.FESTAGO_PROD_USERNAME}}
key: ${{secrets.FESTAGO_SSH_KEY}}
source: "./backend/build/libs/*.jar"
target: ${{ vars.FESTAGO_PROD_JAR_DIR }}
strip_components: 3
username: ${{ vars.DOCKER_HUB_DEV_USERNAME }}
password: ${{ secrets.DOCKER_HUB_DEV_LOGIN_TOKEN }}

- name: Build Docker images
run: docker build -t ${{ vars.DOCKER_DEV_TAG }} .

- name: Push Docker images
run: docker push ${{ vars.DOCKER_DEV_TAG }}

- name: run application use ssh
uses: appleboy/ssh-action@master
with:
host: ${{secrets.FESTAGO_PROD_IP}}
username: ${{secrets.FESTAGO_PROD_USERNAME}}
key: ${{secrets.FESTAGO_SSH_KEY}}
host: ${{ vars.FESTAGO_DEV_IP }}
username: ${{ vars.FESTAGO_DEV_USERNAME }}
key: ${{secrets.FESTAGO_DEV_SSH_KEY}}
script_stop: true
script: ${{ vars.FESTAGO_DEV_DEPLOY_COMMAND }}
4 changes: 2 additions & 2 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[submodule "backend/src/main/resources/festago-config"]
path = backend/src/main/resources/festago-config
[submodule "backend/src/main/resources/config"]
path = backend/src/main/resources/config
url = https://github.com/festago/festago-config.git
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 71e1a77

Please sign in to comment.