Skip to content

Commit

Permalink
Merge pull request #18 from f-lab-edu/feature/17
Browse files Browse the repository at this point in the history
[#17] 상세화면 (DetailScreen) 구현
  • Loading branch information
ksw4015 authored Oct 26, 2024
2 parents 68f0c1b + 4a3a69a commit 3101fa9
Show file tree
Hide file tree
Showing 34 changed files with 1,045 additions and 16 deletions.
1 change: 1 addition & 0 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ plugins {
alias(libs.plugins.kotlin.android)
alias(libs.plugins.dagger.hilt.android)
alias(libs.plugins.kotlin.ksp)
alias(libs.plugins.kotlin.parcelize)
}

val properties = Properties().apply {
Expand Down
1 change: 1 addition & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@

<activity android:name=".presentation.main.MainActivity"/>
<activity android:name=".presentation.more.MoreActivity"/>
<activity android:name=".presentation.detail.DetailActivity"/>
</application>

</manifest>
13 changes: 13 additions & 0 deletions app/src/main/java/kr/ksw/visitkorea/data/di/DataModule.kt
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,15 @@ import dagger.hilt.InstallIn
import dagger.hilt.components.SingletonComponent
import kr.ksw.visitkorea.data.local.databases.AreaCodeDatabase
import kr.ksw.visitkorea.data.remote.api.AreaCodeApi
import kr.ksw.visitkorea.data.remote.api.DetailApi
import kr.ksw.visitkorea.data.remote.api.LocationBasedListApi
import kr.ksw.visitkorea.data.remote.api.RetrofitInterceptor
import kr.ksw.visitkorea.data.remote.api.SearchFestivalApi
import kr.ksw.visitkorea.data.remote.api.SearchKeywordApi
import kr.ksw.visitkorea.data.repository.AreaCodeRepository
import kr.ksw.visitkorea.data.repository.AreaCodeRepositoryImpl
import kr.ksw.visitkorea.data.repository.DetailRepository
import kr.ksw.visitkorea.data.repository.DetailRepositoryImpl
import kr.ksw.visitkorea.data.repository.LocationBasedListRepository
import kr.ksw.visitkorea.data.repository.LocationBasedListRepositoryImpl
import kr.ksw.visitkorea.data.repository.SearchFestivalRepository
Expand Down Expand Up @@ -98,4 +101,14 @@ object DataModule {
fun provideSearchKeywordRepository(searchKeywordApi: SearchKeywordApi): SearchKeywordRepository {
return SearchKeywordRepositoryImpl(searchKeywordApi)
}

@Provides
@Singleton
fun provideDetailApi(retrofit: Retrofit): DetailApi = retrofit.create(DetailApi::class.java)

@Provides
@Singleton
fun provideDetailRepository(detailApi: DetailApi): DetailRepository {
return DetailRepositoryImpl(detailApi)
}
}
44 changes: 44 additions & 0 deletions app/src/main/java/kr/ksw/visitkorea/data/remote/api/DetailApi.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
package kr.ksw.visitkorea.data.remote.api

import kr.ksw.visitkorea.data.remote.dto.DetailCommonDTO
import kr.ksw.visitkorea.data.remote.dto.DetailImageDTO
import kr.ksw.visitkorea.data.remote.dto.DetailIntroDTO
import kr.ksw.visitkorea.data.remote.model.ApiResponse
import retrofit2.http.GET
import retrofit2.http.Query

interface DetailApi {
@GET("detailCommon1")
suspend fun getDetailCommon(
@Query("numOfRows") numOfRows: Int = 10,
@Query("pageNo") pageNo: Int = 1,
@Query("defaultYN") defaultYN: String = "Y",
@Query("overviewYN") overviewYN: String = "Y",
@Query("contentId") contentId: String
): ApiResponse<DetailCommonDTO>

@GET("detailIntro1")
suspend fun getDetailIntro(
@Query("numOfRows") numOfRows: Int = 10,
@Query("pageNo") pageNo: Int = 1,
@Query("contentId") contentId: String,
@Query("contentTypeId") contentTypeId: String
): ApiResponse<DetailIntroDTO>
/*
@GET("detailInfo1")
suspend fun getDetailInfo(
@Query("numOfRows") numOfRows: Int = 10,
@Query("pageNo") pageNo: Int = 1,
@Query("contentId") contentId: Int,
@Query("contentTypeId") contentTypeId: Int
)
*/
@GET("detailImage1")
suspend fun getDetailImage(
@Query("numOfRows") numOfRows: Int = 10,
@Query("pageNo") pageNo: Int = 1,
@Query("subImageYN") subImageYN: String = "Y",
@Query("imageYN") imageYN: String = "Y",
@Query("contentId") contentId: String,
): ApiResponse<DetailImageDTO>
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package kr.ksw.visitkorea.data.remote.dto

data class DetailCommonDTO(
val homepage: String,
val overview: String
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package kr.ksw.visitkorea.data.remote.dto

import com.google.gson.annotations.SerializedName

data class DetailImageDTO(
@SerializedName("originimgurl")
val originImgUrl: String,
@SerializedName("smallimageurl")
val smallImageUrl: String
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
package kr.ksw.visitkorea.data.remote.dto

import com.google.gson.annotations.SerializedName

data class DetailIntroDTO(
// TouristSpot
val parking: String?,
@SerializedName("restdate")
val restDate: String?,
@SerializedName("usetime")
val useTime: String?,
// Culture Center
@SerializedName("parkingculture")
val parkingCulture: String?,
@SerializedName("restdateculture")
val restDateCulture: String?,
@SerializedName("usefee")
val useFee: String?,
@SerializedName("usetimeculture")
val useTimeCulture: String?,
// Festival
@SerializedName("eventplace")
val eventPlace: String?,
@SerializedName("playtime")
val playTime: String?,
@SerializedName("usetimefestival")
val useTimeFestival: String?,
// Leisure Sports
@SerializedName("parkingleports")
val parkingLeports: String?,
@SerializedName("restdateleports")
val restDateLeports: String?,
@SerializedName("usefeeleports")
val useFeeLeports: String?,
@SerializedName("usetimeleports")
val useTimeLeports: String?,
// Restaurant
@SerializedName("parkingfood")
val parkingFood: String?,
@SerializedName("restdatefood")
val restDateFood: String?,
@SerializedName("opentimefood")
val openTimeFood: String?,
@SerializedName("firstmenu")
val firstMenu: String?,
// Hotel
@SerializedName("checkintime")
val checkInTime: String?,
@SerializedName("checkouttime")
val checkOutTime: String?,
@SerializedName("subfacility")
val subFacility: String?,
@SerializedName("reservationurl")
val reservationUrl: String?
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package kr.ksw.visitkorea.data.repository

import kr.ksw.visitkorea.data.remote.dto.DetailCommonDTO
import kr.ksw.visitkorea.data.remote.dto.DetailImageDTO
import kr.ksw.visitkorea.data.remote.dto.DetailIntroDTO

interface DetailRepository {
suspend fun getDetailCommon(
contentId: String
): Result<DetailCommonDTO>

suspend fun getDetailIntro(
contentId: String,
contentTypeId: String
): Result<DetailIntroDTO>

suspend fun getDetailImage(
contentId: String,
imageYN: String
): Result<List<DetailImageDTO>>
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package kr.ksw.visitkorea.data.repository

import kr.ksw.visitkorea.data.mapper.toItems
import kr.ksw.visitkorea.data.remote.api.DetailApi
import kr.ksw.visitkorea.data.remote.dto.DetailCommonDTO
import kr.ksw.visitkorea.data.remote.dto.DetailImageDTO
import kr.ksw.visitkorea.data.remote.dto.DetailIntroDTO
import javax.inject.Inject

class DetailRepositoryImpl @Inject constructor(
private val detailApi: DetailApi
): DetailRepository {
override suspend fun getDetailCommon(
contentId: String)
: Result<DetailCommonDTO> = runCatching {
detailApi.getDetailCommon(
contentId = contentId
).toItems().first()
}

override suspend fun getDetailIntro(
contentId: String,
contentTypeId: String
): Result<DetailIntroDTO> = runCatching {
detailApi.getDetailIntro(
contentId = contentId,
contentTypeId = contentTypeId
).toItems().first()
}

override suspend fun getDetailImage(
contentId: String,
imageYN: String,
): Result<List<DetailImageDTO>> = runCatching {
detailApi.getDetailImage(
contentId = contentId
).toItems()
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package kr.ksw.visitkorea.domain.common

const val TYPE_TOURIST_SPOT = "12"
const val TYPE_CULTURE = "14"
const val TYPE_LEiSURE = "28"
const val TYPE_RESTAURANT = "39"
const val TYPE_FESTIVAL = "15"
31 changes: 31 additions & 0 deletions app/src/main/java/kr/ksw/visitkorea/domain/di/DetailModule.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package kr.ksw.visitkorea.domain.di

import dagger.Binds
import dagger.Module
import dagger.hilt.InstallIn
import dagger.hilt.android.components.ActivityRetainedComponent
import kr.ksw.visitkorea.domain.usecase.detail.GetDetailCommonUseCase
import kr.ksw.visitkorea.domain.usecase.detail.GetDetailCommonUseCaseImpl
import kr.ksw.visitkorea.domain.usecase.detail.GetDetailImageUseCase
import kr.ksw.visitkorea.domain.usecase.detail.GetDetailImageUseCaseUseCaseImpl
import kr.ksw.visitkorea.domain.usecase.detail.GetDetailIntroUseCase
import kr.ksw.visitkorea.domain.usecase.detail.GetDetailIntroUseCaseImpl

@Module
@InstallIn(ActivityRetainedComponent::class)
abstract class DetailModule {
@Binds
abstract fun bindGetDetailCommonUseCase(
getDetailCommonUseCase: GetDetailCommonUseCaseImpl
): GetDetailCommonUseCase

@Binds
abstract fun bindGetDetailIntroUseCase(
getDetailIntroUseCase: GetDetailIntroUseCaseImpl
): GetDetailIntroUseCase

@Binds
abstract fun bindGetDetailImageUseCase(
getDetailImageUseCase: GetDetailImageUseCaseUseCaseImpl
): GetDetailImageUseCase
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package kr.ksw.visitkorea.domain.usecase.detail

import kr.ksw.visitkorea.data.remote.dto.DetailCommonDTO

interface GetDetailCommonUseCase {
suspend operator fun invoke(
contentId: String
): Result<DetailCommonDTO>
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package kr.ksw.visitkorea.domain.usecase.detail

import kr.ksw.visitkorea.data.remote.dto.DetailCommonDTO
import kr.ksw.visitkorea.data.repository.DetailRepository
import javax.inject.Inject

class GetDetailCommonUseCaseImpl @Inject constructor(
private val detailRepository: DetailRepository
): GetDetailCommonUseCase {
override suspend fun invoke(
contentId: String
): Result<DetailCommonDTO> {
return detailRepository.getDetailCommon(contentId)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package kr.ksw.visitkorea.domain.usecase.detail

import kr.ksw.visitkorea.data.remote.dto.DetailImageDTO

interface GetDetailImageUseCase {
suspend operator fun invoke(
contentId: String,
imageYN: String
): Result<List<DetailImageDTO>>
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package kr.ksw.visitkorea.domain.usecase.detail

import kr.ksw.visitkorea.data.remote.dto.DetailImageDTO
import kr.ksw.visitkorea.data.repository.DetailRepository
import javax.inject.Inject

class GetDetailImageUseCaseUseCaseImpl @Inject constructor(
private val detailRepository: DetailRepository
): GetDetailImageUseCase {
override suspend fun invoke(
contentId: String,
imageYN: String
): Result<List<DetailImageDTO>> {
return detailRepository.getDetailImage(
contentId = contentId,
imageYN = imageYN
)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package kr.ksw.visitkorea.domain.usecase.detail

import kr.ksw.visitkorea.domain.usecase.model.CommonDetail

interface GetDetailIntroUseCase {
suspend operator fun invoke(
contentId: String,
contentTypeId: String
): Result<CommonDetail>
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package kr.ksw.visitkorea.domain.usecase.detail

import kr.ksw.visitkorea.data.repository.DetailRepository
import kr.ksw.visitkorea.domain.usecase.mapper.toCommonDetail
import kr.ksw.visitkorea.domain.usecase.model.CommonDetail
import javax.inject.Inject

class GetDetailIntroUseCaseImpl @Inject constructor(
private val detailRepository: DetailRepository
): GetDetailIntroUseCase {
override suspend fun invoke(
contentId: String,
contentTypeId: String
): Result<CommonDetail> = runCatching {
detailRepository.getDetailIntro(
contentId,
contentTypeId
).getOrThrow().toCommonDetail(contentTypeId)
}
}
Loading

0 comments on commit 3101fa9

Please sign in to comment.