-
Notifications
You must be signed in to change notification settings - Fork 1
[FEAT] 대시보드 api 연동 #28
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Empty file removed
0
app/src/main/java/com/sampoom/android/feature/dashboard/data/local/database/.gitkeep
Empty file.
Empty file.
Empty file.
9 changes: 9 additions & 0 deletions
9
app/src/main/java/com/sampoom/android/feature/dashboard/data/mapper/DashboardMappers.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| package com.sampoom.android.feature.dashboard.data.mapper | ||
|
|
||
| import com.sampoom.android.feature.dashboard.data.remote.dto.DashboardResponseDto | ||
| import com.sampoom.android.feature.dashboard.data.remote.dto.WeeklySummaryResponseDto | ||
| import com.sampoom.android.feature.dashboard.domain.model.Dashboard | ||
| import com.sampoom.android.feature.dashboard.domain.model.WeeklySummary | ||
|
|
||
| fun DashboardResponseDto.toModel(): Dashboard = Dashboard(totalParts, outOfStockParts, lowStockParts, totalQuantity) | ||
| fun WeeklySummaryResponseDto.toModel(): WeeklySummary = WeeklySummary(inStockParts, outStockParts, weekPeriod) |
Empty file removed
0
app/src/main/java/com/sampoom/android/feature/dashboard/data/remote/api/.gitkeep
Empty file.
17 changes: 17 additions & 0 deletions
17
app/src/main/java/com/sampoom/android/feature/dashboard/data/remote/api/DashboardApi.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| package com.sampoom.android.feature.dashboard.data.remote.api | ||
|
|
||
| import com.sampoom.android.core.model.ApiResponse | ||
| import com.sampoom.android.feature.dashboard.data.remote.dto.DashboardResponseDto | ||
| import com.sampoom.android.feature.dashboard.data.remote.dto.WeeklySummaryResponseDto | ||
| import retrofit2.http.GET | ||
| import retrofit2.http.Path | ||
|
|
||
| interface DashboardApi { | ||
| // 대시보드 조회 | ||
| @GET("agency/{agencyId}/dashboard") | ||
| suspend fun getDashboard(@Path("agencyId") agencyId: Long): ApiResponse<DashboardResponseDto> | ||
|
|
||
| // 주간 히스토리 조회 | ||
| @GET("agency/{agencyId}/weekly-summary") | ||
| suspend fun getWeeklySummary(@Path("agencyId") agencyId: Long): ApiResponse<WeeklySummaryResponseDto> | ||
| } |
Empty file removed
0
app/src/main/java/com/sampoom/android/feature/dashboard/data/remote/dto/.gitkeep
Empty file.
8 changes: 8 additions & 0 deletions
8
...c/main/java/com/sampoom/android/feature/dashboard/data/remote/dto/DashboardResponseDto.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| package com.sampoom.android.feature.dashboard.data.remote.dto | ||
|
|
||
| data class DashboardResponseDto( | ||
| val totalParts: Long, | ||
| val outOfStockParts: Long, | ||
| val lowStockParts: Long, | ||
| val totalQuantity: Long | ||
| ) |
7 changes: 7 additions & 0 deletions
7
...in/java/com/sampoom/android/feature/dashboard/data/remote/dto/WeeklySummaryResponseDto.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| package com.sampoom.android.feature.dashboard.data.remote.dto | ||
|
|
||
| data class WeeklySummaryResponseDto( | ||
| val inStockParts: Long, | ||
| val outStockParts: Long, | ||
| val weekPeriod: String | ||
| ) |
Empty file removed
0
app/src/main/java/com/sampoom/android/feature/dashboard/data/repository/.gitkeep
Empty file.
30 changes: 30 additions & 0 deletions
30
...ain/java/com/sampoom/android/feature/dashboard/data/repository/DashboardRepositoryImpl.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| package com.sampoom.android.feature.dashboard.data.repository | ||
|
|
||
| import com.sampoom.android.core.preferences.AuthPreferences | ||
| import com.sampoom.android.feature.dashboard.data.mapper.toModel | ||
| import com.sampoom.android.feature.dashboard.data.remote.api.DashboardApi | ||
| import com.sampoom.android.feature.dashboard.domain.model.Dashboard | ||
| import com.sampoom.android.feature.dashboard.domain.model.WeeklySummary | ||
| import com.sampoom.android.feature.dashboard.domain.repository.DashboardRepository | ||
| import javax.inject.Inject | ||
|
|
||
| class DashboardRepositoryImpl @Inject constructor( | ||
| private val api: DashboardApi, | ||
| private val authPreferences: AuthPreferences | ||
| ) : DashboardRepository { | ||
| override suspend fun getDashboard(): Result<Dashboard> { | ||
| return runCatching { | ||
| val agencyId = authPreferences.getStoredUser()?.agencyId ?: throw Exception() | ||
| val dto = api.getDashboard(agencyId) | ||
| dto.data.toModel() | ||
| } | ||
| } | ||
|
|
||
| override suspend fun getWeeklySummary(): Result<WeeklySummary> { | ||
| return runCatching { | ||
| val agencyId = authPreferences.getStoredUser()?.agencyId ?: throw Exception() | ||
| val dto = api.getWeeklySummary(agencyId) | ||
| dto.data.toModel() | ||
| } | ||
| } | ||
Sangyoon98 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| } | ||
Empty file.
26 changes: 26 additions & 0 deletions
26
app/src/main/java/com/sampoom/android/feature/dashboard/di/DashboardModules.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| package com.sampoom.android.feature.dashboard.di | ||
|
|
||
| import com.sampoom.android.feature.dashboard.data.remote.api.DashboardApi | ||
| import com.sampoom.android.feature.dashboard.data.repository.DashboardRepositoryImpl | ||
| import com.sampoom.android.feature.dashboard.domain.repository.DashboardRepository | ||
| import dagger.Binds | ||
| import dagger.Module | ||
| import dagger.Provides | ||
| import dagger.hilt.InstallIn | ||
| import dagger.hilt.components.SingletonComponent | ||
| import retrofit2.Retrofit | ||
| import javax.inject.Singleton | ||
|
|
||
| @Module | ||
| @InstallIn(SingletonComponent::class) | ||
| abstract class DashboardBinModule { | ||
| @Binds @Singleton | ||
| abstract fun bindDashboardRepository(impl: DashboardRepositoryImpl): DashboardRepository | ||
| } | ||
|
|
||
| @Module | ||
| @InstallIn(SingletonComponent::class) | ||
| object DashboardModule { | ||
| @Provides @Singleton | ||
| fun provideDashboardApi(retrofit: Retrofit): DashboardApi = retrofit.create(DashboardApi::class.java) | ||
| } |
Empty file.
8 changes: 8 additions & 0 deletions
8
app/src/main/java/com/sampoom/android/feature/dashboard/domain/model/Dashboard.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| package com.sampoom.android.feature.dashboard.domain.model | ||
|
|
||
| data class Dashboard( | ||
| val totalParts: Long, | ||
| val outOfStockParts: Long, | ||
| val lowStockParts: Long, | ||
| val totalQuantity: Long | ||
| ) |
7 changes: 7 additions & 0 deletions
7
app/src/main/java/com/sampoom/android/feature/dashboard/domain/model/WeeklySummary.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| package com.sampoom.android.feature.dashboard.domain.model | ||
|
|
||
| data class WeeklySummary( | ||
| val inStockParts: Long, | ||
| val outStockParts: Long, | ||
| val weekPeriod: String | ||
| ) |
Empty file removed
0
app/src/main/java/com/sampoom/android/feature/dashboard/domain/repository/.gitkeep
Empty file.
9 changes: 9 additions & 0 deletions
9
.../main/java/com/sampoom/android/feature/dashboard/domain/repository/DashboardRepository.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| package com.sampoom.android.feature.dashboard.domain.repository | ||
|
|
||
| import com.sampoom.android.feature.dashboard.domain.model.Dashboard | ||
| import com.sampoom.android.feature.dashboard.domain.model.WeeklySummary | ||
|
|
||
| interface DashboardRepository { | ||
| suspend fun getDashboard(): Result<Dashboard> | ||
| suspend fun getWeeklySummary(): Result<WeeklySummary> | ||
| } |
Empty file removed
0
app/src/main/java/com/sampoom/android/feature/dashboard/domain/usecase/.gitkeep
Empty file.
11 changes: 11 additions & 0 deletions
11
...src/main/java/com/sampoom/android/feature/dashboard/domain/usecase/GetDashboardUseCase.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| package com.sampoom.android.feature.dashboard.domain.usecase | ||
|
|
||
| import com.sampoom.android.feature.dashboard.domain.model.Dashboard | ||
| import com.sampoom.android.feature.dashboard.domain.repository.DashboardRepository | ||
| import javax.inject.Inject | ||
|
|
||
| class GetDashboardUseCase @Inject constructor( | ||
| private val repository: DashboardRepository | ||
| ) { | ||
| suspend operator fun invoke(): Result<Dashboard> = repository.getDashboard() | ||
| } |
11 changes: 11 additions & 0 deletions
11
...rc/main/java/com/sampoom/android/feature/dashboard/domain/usecase/WeeklySummaryUseCase.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| package com.sampoom.android.feature.dashboard.domain.usecase | ||
|
|
||
| import com.sampoom.android.feature.dashboard.domain.model.WeeklySummary | ||
| import com.sampoom.android.feature.dashboard.domain.repository.DashboardRepository | ||
| import javax.inject.Inject | ||
|
|
||
| class WeeklySummaryUseCase @Inject constructor( | ||
| private val repository: DashboardRepository | ||
| ) { | ||
| suspend operator fun invoke(): Result<WeeklySummary> = repository.getWeeklySummary() | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 6 additions & 0 deletions
6
app/src/main/java/com/sampoom/android/feature/dashboard/ui/DashboardUiState.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,9 +1,15 @@ | ||
| package com.sampoom.android.feature.dashboard.ui | ||
|
|
||
| import com.sampoom.android.feature.dashboard.domain.model.Dashboard | ||
| import com.sampoom.android.feature.dashboard.domain.model.WeeklySummary | ||
| import com.sampoom.android.feature.order.domain.model.Order | ||
|
|
||
| data class DashboardUiState( | ||
| val orderList: List<Order> = emptyList(), | ||
| val dashboard: Dashboard? = null, | ||
| val weeklySummary: WeeklySummary? = null, | ||
| val dashboardLoading: Boolean = false, | ||
| val dashboardError: String? = null, | ||
| val weeklySummaryLoading: Boolean = false, | ||
| val weeklySummaryError: String? = null, | ||
| ) |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.