Skip to content

Commit

Permalink
[REFACTOR/#308] 딱 맞는 인턴 공고 파라미터 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
Hyobeen-Park committed Dec 18, 2024
1 parent 318970c commit ba7bf35
Show file tree
Hide file tree
Showing 7 changed files with 2 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ interface HomeDataSource {

suspend fun getRecommendIntern(
sortBy: String,
startYear: Int,
startMonth: Int
): BaseResponse<HomeRecommendInternResponseDto>

suspend fun getFilteringInfo(): BaseResponse<HomeFilteringInfoResponseDto>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,9 @@ class HomeDataSourceImpl @Inject constructor(

override suspend fun getRecommendIntern(
sortBy: String,
startYear: Int,
startMonth: Int
): BaseResponse<HomeRecommendInternResponseDto> =
homeService.getRecommendIntern(
sortBy = sortBy,
startYear = startYear,
startMonth = startMonth
)

override suspend fun getFilteringInfo(): BaseResponse<HomeFilteringInfoResponseDto> =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,10 @@ class HomeRepositoryImpl @Inject constructor(

override suspend fun getRecommendIntern(
sortBy: String,
startYear: Int,
startMonth: Int
): Result<HomeRecommendIntern> =
runCatching {
homeDataSource.getRecommendIntern(
sortBy = sortBy,
startYear = startYear,
startMonth = startMonth
).result.toHomeRecommendInternList()
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ interface HomeService {
@GET("api/v1/home")
suspend fun getRecommendIntern(
@Query("sortBy") sortBy: String,
@Query("startYear") startYear: Int,
@Query("startMonth") startMonth: Int,
): BaseResponse<HomeRecommendInternResponseDto>

@GET("api/v1/filters")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ interface HomeRepository {

suspend fun getRecommendIntern(
sortBy: String,
startYear: Int,
startMonth: Int
): Result<HomeRecommendIntern>

suspend fun getFilteringInfo(): Result<HomeFilteringInfo>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ fun HomeScreen(
navigateToCalendar: () -> Unit,
updateRecommendDialogVisibility: (Boolean) -> Unit,
getHomeUpcomingInternList: () -> Unit,
getRecommendInternsData: (Int, Int?, Int?) -> Unit,
getRecommendInternsData: (Int) -> Unit,
viewModel: HomeViewModel,
) {
val homeState by viewModel.homeState.collectAsStateWithLifecycle()
Expand Down Expand Up @@ -221,8 +221,6 @@ fun HomeScreen(
getHomeUpcomingInternList()
getRecommendInternsData(
homeState.sortBy.ordinal,
homeFilteringInfo.startYear,
homeFilteringInfo.startMonth
)
}
}
Expand All @@ -242,8 +240,6 @@ fun HomeScreen(
if (isScrapped) {
getRecommendInternsData(
homeState.sortBy.ordinal,
homeFilteringInfo.startYear,
homeFilteringInfo.startMonth
)
getHomeUpcomingInternList()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ package com.terning.feature.home

import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
import com.terning.core.designsystem.extension.currentMonth
import com.terning.core.designsystem.extension.currentYear
import com.terning.core.designsystem.state.UiState
import com.terning.core.designsystem.type.SortBy
import com.terning.domain.home.entity.ChangeFilteringRequestModel
Expand All @@ -17,7 +15,6 @@ import kotlinx.coroutines.flow.asSharedFlow
import kotlinx.coroutines.flow.asStateFlow
import kotlinx.coroutines.flow.update
import kotlinx.coroutines.launch
import java.util.Calendar
import javax.inject.Inject

@HiltViewModel
Expand All @@ -31,12 +28,10 @@ class HomeViewModel @Inject constructor(
private val _homeSideEffect = MutableSharedFlow<HomeSideEffect>()
val homeSideEffect get() = _homeSideEffect.asSharedFlow()

fun getRecommendInternsData(sortBy: Int, startYear: Int?, startMonth: Int?) {
fun getRecommendInternsData(sortBy: Int) {
viewModelScope.launch {
homeRepository.getRecommendIntern(
sortBy = SortBy.entries[sortBy].type,
startYear ?: Calendar.getInstance().currentYear,
startMonth ?: Calendar.getInstance().currentMonth,
).onSuccess { internList ->
_homeState.value = _homeState.value.copy(
homeRecommendInternState = UiState.Success(internList)
Expand Down Expand Up @@ -74,8 +69,6 @@ class HomeViewModel @Inject constructor(
if (filteringInfo.grade != null) {
getRecommendInternsData(
sortBy = _homeState.value.sortBy.ordinal,
startYear = filteringInfo.startYear,
startMonth = filteringInfo.startMonth,
)
getHomeUpcomingInternList()
}
Expand Down Expand Up @@ -158,8 +151,6 @@ class HomeViewModel @Inject constructor(
}
getRecommendInternsData(
_homeState.value.sortBy.ordinal,
startYear ?: Calendar.getInstance().currentYear,
startMonth ?: Calendar.getInstance().currentMonth,
)
}

Expand Down

0 comments on commit ba7bf35

Please sign in to comment.