Skip to content

Commit 7c8d52b

Browse files
authored
Merge pull request #1505 from BCSDLab/feature/1496-add-missing-ui
[Feature] 홈화면 추가 UI 구현
2 parents fdfcd74 + e351c4d commit 7c8d52b

18 files changed

Lines changed: 253 additions & 13 deletions

File tree

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
package `in`.koreatech.koin.data.api
2+
3+
import `in`.koreatech.koin.data.response.weather.WeatherResponse
4+
import retrofit2.http.GET
5+
6+
interface WeatherApi {
7+
@GET("weather")
8+
suspend fun getWeather(): WeatherResponse
9+
}

data/src/main/java/in/koreatech/koin/data/di/network/NoAuthNetworkModule.kt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import `in`.koreatech.koin.data.api.StoreApi
2323
import `in`.koreatech.koin.data.api.TimetableApi
2424
import `in`.koreatech.koin.data.api.UserApi
2525
import `in`.koreatech.koin.data.api.VersionApi
26+
import `in`.koreatech.koin.data.api.WeatherApi
2627
import java.util.concurrent.TimeUnit
2728
import javax.inject.Singleton
2829
import okhttp3.Interceptor
@@ -185,4 +186,12 @@ object NoAuthNetworkModule {
185186
): OrderShopApi {
186187
return retrofit.create(OrderShopApi::class.java)
187188
}
189+
190+
@Provides
191+
@Singleton
192+
fun provideWeatherApi(
193+
@NoAuth retrofit: Retrofit
194+
): WeatherApi {
195+
return retrofit.create(WeatherApi::class.java)
196+
}
188197
}

data/src/main/java/in/koreatech/koin/data/di/repository/BindsRepositoryModule.kt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,12 @@ import dagger.hilt.components.SingletonComponent
77
import `in`.koreatech.koin.data.repository.BusRepositoryImpl
88
import `in`.koreatech.koin.data.repository.CallvanRepositoryImpl
99
import `in`.koreatech.koin.data.repository.TimetableRepositoryImpl
10+
import `in`.koreatech.koin.data.repository.WeatherRepositoryImpl
1011
import `in`.koreatech.koin.data.repository.firebase.messaging.FirebaseMessagingRepositoryImpl
1112
import `in`.koreatech.koin.domain.repository.BusRepository
1213
import `in`.koreatech.koin.domain.repository.CallvanRepository
1314
import `in`.koreatech.koin.domain.repository.TimetableRepository
15+
import `in`.koreatech.koin.domain.repository.WeatherRepository
1416
import `in`.koreatech.koin.domain.repository.firebase.messaging.FirebaseMessagingRepository
1517
import javax.inject.Singleton
1618

@@ -34,4 +36,8 @@ abstract class BindsRepositoryModule {
3436
@Binds
3537
@Singleton
3638
abstract fun bindsCallvanRepository(callvanRepositoryImpl: CallvanRepositoryImpl): CallvanRepository
39+
40+
@Binds
41+
@Singleton
42+
abstract fun bindsWeatherRepository(weatherRepositoryImpl: WeatherRepositoryImpl): WeatherRepository
3743
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
package `in`.koreatech.koin.data.mapper
2+
3+
import `in`.koreatech.koin.data.response.weather.WeatherResponse
4+
import `in`.koreatech.koin.domain.model.weather.Weather
5+
6+
fun WeatherResponse.toWeather() = Weather(
7+
temperature = temperature,
8+
weather = weather,
9+
weatherId = weatherId,
10+
weatherIconUrl = weatherIconUrl
11+
)
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
package `in`.koreatech.koin.data.repository
2+
3+
import `in`.koreatech.koin.data.mapper.toWeather
4+
import `in`.koreatech.koin.data.source.remote.WeatherRemoteDataSource
5+
import `in`.koreatech.koin.data.util.mapHttpFailure
6+
import `in`.koreatech.koin.data.util.suspendRunCatching
7+
import `in`.koreatech.koin.domain.error.weather.KoinWeatherException
8+
import `in`.koreatech.koin.domain.model.weather.Weather
9+
import `in`.koreatech.koin.domain.repository.WeatherRepository
10+
import javax.inject.Inject
11+
12+
class WeatherRepositoryImpl @Inject constructor(
13+
private val weatherRemoteDataSource: WeatherRemoteDataSource
14+
) : WeatherRepository {
15+
override suspend fun getWeather(): Result<Weather> {
16+
return suspendRunCatching {
17+
weatherRemoteDataSource.getWeather().toWeather()
18+
}.mapHttpFailure {
19+
on(500, "EXTERNAL_API_ERROR") throws KoinWeatherException.ExternalApiErrorException()
20+
}
21+
}
22+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
package `in`.koreatech.koin.data.response.weather
2+
3+
import com.google.gson.annotations.SerializedName
4+
5+
data class WeatherResponse(
6+
@SerializedName("temperature") val temperature: Int,
7+
@SerializedName("weather") val weather: String,
8+
@SerializedName("weather_id") val weatherId: Int,
9+
@SerializedName("weather_icon_url") val weatherIconUrl: String
10+
)
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
package `in`.koreatech.koin.data.source.remote
2+
3+
import `in`.koreatech.koin.data.api.WeatherApi
4+
import `in`.koreatech.koin.data.response.weather.WeatherResponse
5+
import javax.inject.Inject
6+
7+
class WeatherRemoteDataSource @Inject constructor(
8+
private val weatherApi: WeatherApi
9+
) {
10+
suspend fun getWeather(): WeatherResponse = weatherApi.getWeather()
11+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
package `in`.koreatech.koin.domain.error.weather
2+
3+
import `in`.koreatech.koin.domain.error.KoinErrorException
4+
5+
sealed class KoinWeatherException : KoinErrorException() {
6+
/*
7+
* Exceptions for 500
8+
*/
9+
class ExternalApiErrorException : KoinWeatherException()
10+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
package `in`.koreatech.koin.domain.model.weather
2+
3+
data class Weather(
4+
val temperature: Int,
5+
val weather: String,
6+
val weatherId: Int,
7+
val weatherIconUrl: String
8+
)
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
package `in`.koreatech.koin.domain.repository
2+
3+
import `in`.koreatech.koin.domain.model.weather.Weather
4+
5+
interface WeatherRepository {
6+
suspend fun getWeather(): Result<Weather>
7+
}

0 commit comments

Comments
 (0)