Skip to content

Commit

Permalink
[MERGE] #177 -> develop
Browse files Browse the repository at this point in the history
[CHORE/#177] 홈 뷰 패키지 구조 수정
  • Loading branch information
Hyobeen-Park authored Aug 26, 2024
2 parents 5762ac1 + a4ddeef commit 6778e36
Show file tree
Hide file tree
Showing 18 changed files with 119 additions and 110 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.terning.data.dto.response

import com.terning.domain.entity.response.HomeFilteringInfoModel
import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable

Expand All @@ -14,12 +13,4 @@ data class HomeFilteringInfoResponseDto(
val startYear: Int?,
@SerialName("startMonth")
val startMonth: Int?,
) {
fun toHomeFilteringInfoModel(): HomeFilteringInfoModel =
HomeFilteringInfoModel(
grade = this.grade,
workingPeriod = this.workingPeriod,
startYear = this.startYear,
startMonth = this.startMonth,
)
}
)
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.terning.data.dto.response

import com.terning.domain.entity.response.HomeRecommendInternModel
import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable

Expand All @@ -24,17 +23,4 @@ data class HomeRecommendInternResponseDto(
val companyImage: String,
@SerialName("isScrapped")
val isScrapped: Boolean,
) {
fun toRecommendInternEntity(): HomeRecommendInternModel =
HomeRecommendInternModel(
scrapId = this.scrapId,
internshipAnnouncementId = this.internshipAnnouncementId,
title = this.title,
dDay = this.dDay,
deadline = deadline,
workingPeriod = this.workingPeriod,
startYearMonth = this.startYearMonth,
companyImage = this.companyImage,
isScrapped = this.isScrapped,
)
}
)
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.terning.data.dto.response

import com.terning.domain.entity.response.HomeTodayInternModel
import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable

Expand All @@ -25,17 +24,4 @@ data class HomeTodayInternResponseDto(
@SerialName("startYearMonth")
val startYearMonth: String,

) {
fun toHomeTodayInternList(): HomeTodayInternModel =
HomeTodayInternModel(
scrapId = this.scrapId,
internshipAnnouncementId = this.internshipAnnouncementId,
companyImage = this.companyImage,
title = this.title,
dDay = this.dDay,
deadline = this.deadline,
workingPeriod = this.workingPeriod,
startYearMonth = this.startYearMonth,
color = this.color,
)
}
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package com.terning.data.mapper.home

import com.terning.data.dto.response.HomeFilteringInfoResponseDto
import com.terning.domain.entity.home.HomeFilteringInfo

fun HomeFilteringInfoResponseDto.toHomeFilteringInfo(): HomeFilteringInfo =
HomeFilteringInfo(
grade = this.grade,
workingPeriod = this.workingPeriod,
startYear = this.startYear,
startMonth = this.startMonth,
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package com.terning.data.mapper.home

import com.terning.data.dto.response.HomeRecommendInternResponseDto
import com.terning.domain.entity.home.HomeRecommendIntern

fun HomeRecommendInternResponseDto.toHomeRecommendInternList(): HomeRecommendIntern =
HomeRecommendIntern(
scrapId = this.scrapId,
internshipAnnouncementId = this.internshipAnnouncementId,
title = this.title,
dDay = this.dDay,
deadline = deadline,
workingPeriod = this.workingPeriod,
startYearMonth = this.startYearMonth,
companyImage = this.companyImage,
isScrapped = this.isScrapped,
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package com.terning.data.mapper.home

import com.terning.data.dto.response.HomeTodayInternResponseDto
import com.terning.domain.entity.home.HomeTodayIntern

fun HomeTodayInternResponseDto.toHomeTodayInternList(): HomeTodayIntern =
HomeTodayIntern(
scrapId = this.scrapId,
internshipAnnouncementId = this.internshipAnnouncementId,
companyImage = this.companyImage,
title = this.title,
dDay = this.dDay,
deadline = this.deadline,
workingPeriod = this.workingPeriod,
startYearMonth = this.startYearMonth,
color = this.color,
)
Original file line number Diff line number Diff line change
Expand Up @@ -2,41 +2,44 @@ package com.terning.data.repositoryimpl

import com.terning.data.datasource.HomeDataSource
import com.terning.data.dto.request.toChangeFilterRequestDto
import com.terning.data.mapper.home.toHomeFilteringInfo
import com.terning.data.mapper.home.toHomeRecommendInternList
import com.terning.data.mapper.home.toHomeTodayInternList
import com.terning.domain.entity.home.HomeFilteringInfo
import com.terning.domain.entity.home.HomeRecommendIntern
import com.terning.domain.entity.home.HomeTodayIntern
import com.terning.domain.entity.request.ChangeFilteringRequestModel
import com.terning.domain.entity.response.HomeFilteringInfoModel
import com.terning.domain.entity.response.HomeRecommendInternModel
import com.terning.domain.entity.response.HomeTodayInternModel
import com.terning.domain.repository.HomeRepository
import javax.inject.Inject

class HomeRepositoryImpl @Inject constructor(
private val homeDataSource: HomeDataSource,
) : HomeRepository {
override suspend fun getHomeTodayInternList(): Result<List<HomeTodayInternModel>> =
override suspend fun getHomeTodayInternList(): Result<List<HomeTodayIntern>> =
runCatching {
homeDataSource.getTodayIntern().result.map {
it.toHomeTodayInternList()
homeDataSource.getTodayIntern().result.map { homeTodayInternResponseDto ->
homeTodayInternResponseDto.toHomeTodayInternList()
}
}

override suspend fun getRecommendIntern(
sortBy: String,
startYear: Int,
startMonth: Int
): Result<List<HomeRecommendInternModel>> =
): Result<List<HomeRecommendIntern>> =
runCatching {
homeDataSource.getRecommendIntern(
sortBy = sortBy,
startYear = startYear,
startMonth = startMonth
).result.map {
it.toRecommendInternEntity()
).result.map { homeRecommendInternResponseDto ->
homeRecommendInternResponseDto.toHomeRecommendInternList()
}
}

override suspend fun getFilteringInfo(): Result<HomeFilteringInfoModel> =
override suspend fun getFilteringInfo(): Result<HomeFilteringInfo> =
runCatching {
homeDataSource.getFilteringInfo().result.toHomeFilteringInfoModel()
homeDataSource.getFilteringInfo().result.toHomeFilteringInfo()
}

override suspend fun putFilteringInfo(putFilteringRequest: ChangeFilteringRequestModel): Result<Unit> =
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.terning.domain.entity.response
package com.terning.domain.entity.home

data class HomeFilteringInfoModel(
data class HomeFilteringInfo(
val grade: Int?,
val workingPeriod: Int?,
val startYear: Int?,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.terning.domain.entity.response
package com.terning.domain.entity.home

data class HomeRecommendInternModel(
data class HomeRecommendIntern(
val scrapId: Long?,
val internshipAnnouncementId: Long,
val title: String,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.terning.domain.entity.response
package com.terning.domain.entity.home

data class HomeTodayInternModel(
data class HomeTodayIntern(
val scrapId: Long,
val internshipAnnouncementId: Long,
val companyImage: String,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
package com.terning.domain.repository

import com.terning.domain.entity.home.HomeFilteringInfo
import com.terning.domain.entity.home.HomeRecommendIntern
import com.terning.domain.entity.home.HomeTodayIntern
import com.terning.domain.entity.request.ChangeFilteringRequestModel
import com.terning.domain.entity.response.HomeFilteringInfoModel
import com.terning.domain.entity.response.HomeRecommendInternModel
import com.terning.domain.entity.response.HomeTodayInternModel

interface HomeRepository {
suspend fun getHomeTodayInternList(): Result<List<HomeTodayInternModel>>
suspend fun getHomeTodayInternList(): Result<List<HomeTodayIntern>>

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

suspend fun getFilteringInfo(): Result<HomeFilteringInfoModel>
suspend fun getFilteringInfo(): Result<HomeFilteringInfo>

suspend fun putFilteringInfo(
putFilteringRequest: ChangeFilteringRequestModel,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,15 @@ import com.terning.core.designsystem.component.topappbar.BackButtonTopAppBar
import com.terning.core.designsystem.theme.TerningTheme
import com.terning.core.extension.toast
import com.terning.core.state.UiState
import com.terning.domain.entity.home.HomeFilteringInfo
import com.terning.domain.entity.request.ChangeFilteringRequestModel
import com.terning.domain.entity.response.HomeFilteringInfoModel
import com.terning.feature.R
import com.terning.feature.home.changefilter.component.ChangeFilteringRadioGroup
import com.terning.feature.home.changefilter.component.FilteringMainTitleText
import com.terning.feature.home.changefilter.component.FilteringSubTitleText
import com.terning.feature.home.changefilter.navigation.navigateChangeFilter
import com.terning.feature.home.home.HomeSideEffect
import com.terning.feature.home.home.HomeViewModel
import com.terning.feature.home.home.navigation.navigateHome

const val MIN_INDEX = 0
const val MAX_WORKING_INDEX = 2
Expand All @@ -53,7 +52,7 @@ fun ChangeFilterRoute(

when (filteringState) {
is UiState.Success -> ChangeFilterScreen(
(filteringState as UiState.Success<HomeFilteringInfoModel>).data,
(filteringState as UiState.Success<HomeFilteringInfo>).data,
navController,
viewModel,
)
Expand All @@ -75,7 +74,7 @@ fun ChangeFilterRoute(

@Composable
fun ChangeFilterScreen(
filterData: HomeFilteringInfoModel,
filterData: HomeFilteringInfo,
navController: NavController,
viewModel: HomeViewModel,
) {
Expand Down
32 changes: 16 additions & 16 deletions feature/src/main/java/com/terning/feature/home/home/HomeRoute.kt
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,9 @@ import com.terning.core.designsystem.theme.White
import com.terning.core.extension.noRippleClickable
import com.terning.core.extension.toast
import com.terning.core.state.UiState
import com.terning.domain.entity.response.HomeFilteringInfoModel
import com.terning.domain.entity.response.HomeRecommendInternModel
import com.terning.domain.entity.response.HomeTodayInternModel
import com.terning.domain.entity.home.HomeFilteringInfo
import com.terning.domain.entity.home.HomeRecommendIntern
import com.terning.domain.entity.home.HomeTodayIntern
import com.terning.feature.R
import com.terning.feature.home.changefilter.navigation.navigateChangeFilter
import com.terning.feature.home.home.component.HomeFilteringEmptyIntern
Expand Down Expand Up @@ -102,7 +102,7 @@ fun HomeRoute(
val homeUserState by viewModel.homeUserState.collectAsStateWithLifecycle()
val homeDialogState by viewModel.homeDialogState.collectAsStateWithLifecycle()

val homeTodayInternList: MutableState<List<HomeTodayInternModel>> = remember {
val homeTodayInternList: MutableState<List<HomeTodayIntern>> = remember {
mutableStateOf(emptyList())
}

Expand All @@ -120,7 +120,7 @@ fun HomeRoute(
LaunchedEffect(homeFilteringState, currentSortBy.value) {
when (homeFilteringState) {
is UiState.Success ->
with((homeFilteringState as UiState.Success<HomeFilteringInfoModel>).data) {
with((homeFilteringState as UiState.Success<HomeFilteringInfo>).data) {
viewModel.getRecommendInternsData(
currentSortBy.value,
startYear ?: viewModel.currentYear,
Expand All @@ -143,7 +143,7 @@ fun HomeRoute(
when (homeTodayState) {
is UiState.Success -> {
homeTodayInternList.value =
(homeTodayState as UiState.Success<List<HomeTodayInternModel>>).data
(homeTodayState as UiState.Success<List<HomeTodayIntern>>).data
}

is UiState.Loading -> {}
Expand All @@ -154,15 +154,15 @@ fun HomeRoute(

val homeRecommendInternList = when (homeRecommendInternState) {
is UiState.Success -> {
(homeRecommendInternState as UiState.Success<List<HomeRecommendInternModel>>).data
(homeRecommendInternState as UiState.Success<List<HomeRecommendIntern>>).data
}

else -> emptyList()
}

val homeFilteringInfo = when (homeFilteringState) {
is UiState.Success -> (homeFilteringState as UiState.Success<HomeFilteringInfoModel>).data
else -> HomeFilteringInfoModel(null, null, viewModel.currentYear, viewModel.currentMonth)
is UiState.Success -> (homeFilteringState as UiState.Success<HomeFilteringInfo>).data
else -> HomeFilteringInfo(null, null, viewModel.currentYear, viewModel.currentMonth)
}

val homeUserName = when (homeUserState) {
Expand All @@ -187,9 +187,9 @@ fun HomeRoute(
fun HomeScreen(
currentSortBy: MutableState<Int>,
homeUserName: String,
homeFilteringInfo: HomeFilteringInfoModel,
homeTodayInternList: List<HomeTodayInternModel>,
recommendInternList: List<HomeRecommendInternModel>,
homeFilteringInfo: HomeFilteringInfo,
homeTodayInternList: List<HomeTodayIntern>,
recommendInternList: List<HomeRecommendIntern>,
homeDialogState: HomeDialogState,
onChangeFilterClick: () -> Unit,
viewModel: HomeViewModel = hiltViewModel(),
Expand Down Expand Up @@ -372,7 +372,7 @@ fun HomeScreen(
viewModel.updateScrapped(false)
}
},
homeRecommendInternModel = this,
homeRecommendIntern = this,
)
}
}
Expand All @@ -385,7 +385,7 @@ fun HomeScreen(
@Composable
private fun RecommendInternItem(
navController: NavHostController,
intern: HomeRecommendInternModel,
intern: HomeRecommendIntern,
onScrapButtonClicked: (Long) -> Unit,
) {
InternItemWithShadow(
Expand Down Expand Up @@ -425,7 +425,7 @@ private fun ShowMainTitleWithName(userName: String) {

@Composable
private fun ShowTodayIntern(
homeTodayInternList: List<HomeTodayInternModel>,
homeTodayInternList: List<HomeTodayIntern>,
homeDialogState: HomeDialogState,
navigateToDetail: (Long) -> Unit,
) {
Expand Down Expand Up @@ -463,7 +463,7 @@ private fun ShowRecommendTitle() {

@Composable
private fun ShowInternFilter(
homeFilteringInfo: HomeFilteringInfoModel,
homeFilteringInfo: HomeFilteringInfo,
onChangeFilterClick: () -> Unit,
) {
if (homeFilteringInfo.grade == null) {
Expand Down
Loading

0 comments on commit 6778e36

Please sign in to comment.