Skip to content

Commit

Permalink
[feat/#23] 좌석 선택 뷰 repository 와 주입 정의
Browse files Browse the repository at this point in the history
  • Loading branch information
imtaejugkim committed Nov 28, 2024
1 parent 47e0053 commit 43deceb
Show file tree
Hide file tree
Showing 10 changed files with 71 additions and 39 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import com.sopt.korailtalk.data.remote.model.request.SeatSelectingRequestDto
import com.sopt.korailtalk.data.remote.model.response.LeftSeatsResponseDto


interface LeftSeatsRemoteDataSource {
interface SeatsRemoteDataSource {
suspend fun getLeftSeats(userId: Long, timetableId: Long): ApiResponse<LeftSeatsResponseDto>
suspend fun selectSeat(seatSelectingRequestDto: SeatSelectingRequestDto): ApiResponse<Unit>
}
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
package com.sopt.korailtalk.data.remote.datasourceimpl

import com.sopt.korailtalk.data.remote.datasource.LeftSeatsRemoteDataSource
import com.sopt.korailtalk.data.remote.model.base.ApiResponse
import com.sopt.korailtalk.data.remote.datasource.SeatsRemoteDataSource
import com.sopt.korailtalk.data.remote.model.request.SeatSelectingRequestDto
import com.sopt.korailtalk.data.remote.model.response.LeftSeatsResponseDto
import com.sopt.korailtalk.data.remote.service.SeatsService
import javax.inject.Inject

class LeftSeatsRemoteDataSourceImpl @Inject constructor(
class SeatsRemoteDataSourceImpl @Inject constructor(
private val seatsService: SeatsService
) : LeftSeatsRemoteDataSource {
) : SeatsRemoteDataSource {
override suspend fun getLeftSeats(userId: Long, timetableId: Long) =
seatsService.getSeats(userId, timetableId)

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package com.sopt.korailtalk.data.repositoryimpl

import com.sopt.korailtalk.data.remote.datasource.LeftSeatsRemoteDataSource
import javax.inject.Inject

class SeatsRepositoryImpl @Inject constructor(
private val seatsRemoteDataSource: LeftSeatsRemoteDataSource
) : PaymentRepository {
override suspend fun getLpoint(userId: Long, pointPassword: Int): Result<LPoint> {
return runCatching {
paymentRemoteDataSource.getLpoint(userId = userId, pointPassword = pointPassword)
.handleApiResponse().getOrThrow().toDomain()
}
}

override suspend fun buyTicket(ticketBuying: TicketBuying): Result<Unit> {
return runCatching {
paymentRemoteDataSource.buyTicket(ticketBuyingRequestDto = ticketBuying.toData())
}
}
}
8 changes: 8 additions & 0 deletions app/src/main/java/com/sopt/korailtalk/di/DataSourceModule.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ package com.sopt.korailtalk.di
import com.sopt.korailtalk.data.local.datasource.ExampleLocalDataSource
import com.sopt.korailtalk.data.local.datasourceimpl.ExampleLocalDataSourceImpl
import com.sopt.korailtalk.data.remote.datasource.ExampleRemoteDataSource
import com.sopt.korailtalk.data.remote.datasource.SeatsRemoteDataSource
import com.sopt.korailtalk.data.remote.datasourceimpl.ExampleRemoteDataSourceImpl
import com.sopt.korailtalk.data.remote.datasourceimpl.SeatsRemoteDataSourceImpl
import dagger.Binds
import dagger.Module
import dagger.hilt.InstallIn
Expand All @@ -24,4 +26,10 @@ abstract class DataSourceModule {
abstract fun bindExampleRemoteDataSource(
exampleRemoteDataSourceImpl: ExampleRemoteDataSourceImpl
): ExampleRemoteDataSource

@Binds
@Singleton
abstract fun bindSeatsRemoteDataSource(
seatsRemoteDataSourceImpl: SeatsRemoteDataSourceImpl
): SeatsRemoteDataSource
}
8 changes: 8 additions & 0 deletions app/src/main/java/com/sopt/korailtalk/di/RepositoryModule.kt
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package com.sopt.korailtalk.di

import com.sopt.korailtalk.data.repositoryimpl.ExampleRepositoryImpl
import com.sopt.korailtalk.data.repositoryimpl.SeatsRepositoryImpl
import com.sopt.korailtalk.domain.repository.ExampleRepository
import com.sopt.korailtalk.domain.repository.SeatsRepository
import dagger.Binds
import dagger.Module
import dagger.hilt.InstallIn
Expand All @@ -16,4 +18,10 @@ abstract class RepositoryModule {
abstract fun bindExampleRepository(
exampleRepositoryImpl: ExampleRepositoryImpl
): ExampleRepository

@Binds
@Singleton
abstract fun bindSeatsRepository(
seatsRepositoryImpl: SeatsRepositoryImpl
): SeatsRepository
}
8 changes: 7 additions & 1 deletion app/src/main/java/com/sopt/korailtalk/di/ServiceModule.kt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.sopt.korailtalk.di

import com.sopt.korailtalk.data.remote.service.ExampleService
import com.sopt.korailtalk.data.remote.service.SeatsService
import com.sopt.korailtalk.di.qualifier.KorailTalk
import dagger.Module
import dagger.Provides
Expand All @@ -16,4 +17,9 @@ object ServiceModule {
@Singleton
fun provideExampleService(@KorailTalk retrofit: Retrofit): ExampleService =
retrofit.create(ExampleService::class.java)
}

@Provides
@Singleton
fun provideSeatsService(@KorailTalk retrofit: Retrofit): SeatsService =
retrofit.create(SeatsService::class.java)
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.sopt.korailtalk.domain.model

data class SeatSelectingRequestDto(
data class SeatSelecting(
val isAuto: Boolean,
val timetableId: Long,
val coachId: Long,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package com.sopt.korailtalk.domain.repository

import com.sopt.korailtalk.domain.model.LeftSeats
import com.sopt.korailtalk.domain.model.SeatSelecting

interface SeatsRepository {
suspend fun getLeftSeats(userId: Long, timetableId: Long): Result<LeftSeats>
suspend fun selectSeat(seatSelecting: SeatSelecting): Result<Unit>
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.tooling.preview.Preview
import com.sopt.korailtalk.presentation.ui.seatmap.SeatMapScreenPreview
import com.sopt.korailtalk.presentation.ui.traincheck.TrainCheckScreenPreview
import com.sopt.korailtalk.ui.theme.KorailTalkTheme
import com.sopt.korailtalk.ui.theme.COLLAVORATIONANDROIDKORAILTALKTheme
import dagger.hilt.android.AndroidEntryPoint
Expand All @@ -22,7 +24,6 @@ import dagger.hilt.android.AndroidEntryPoint
class MainActivity : ComponentActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
enableEdgeToEdge()
setContent {
COLLAVORATIONANDROIDKORAILTALKTheme {
Scaffold(modifier = Modifier.fillMaxSize()) { innerPadding ->
Expand All @@ -42,36 +43,7 @@ fun Greeting(name: String, modifier: Modifier = Modifier) {
modifier = Modifier.fillMaxSize(),
contentAlignment = Alignment.Center
) {
Column {
Text(
text = "$name!",
style = KorailTalkTheme.typography.head1.copy(
color = KorailTalkTheme.colors.transparentBlue50
),
modifier = modifier
)
Text(
text = "$name!",
style = KorailTalkTheme.typography.title1.copy(
color = KorailTalkTheme.colors.blue01
),
modifier = modifier
)
Text(
text = "$name!",
style = KorailTalkTheme.typography.body3.copy(
color = KorailTalkTheme.colors.purple01
),
modifier = modifier
)
Text(
text = "$name!",
style = KorailTalkTheme.typography.caption1.copy(
color = KorailTalkTheme.colors.grey600
),
modifier = modifier
)
}
TrainCheckScreenPreview()

}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package com.sopt.korailtalk.presentation.ui.seatmap

import com.sopt.korailtalk.domain.model.LeftSeats

sealed class LeftSeatsState {
data object Idle: LeftSeatsState()
data object Loading: LeftSeatsState()
data class Success(val data: LeftSeats): LeftSeatsState()
data class Failure(val message: String): LeftSeatsState()
}

0 comments on commit 43deceb

Please sign in to comment.