From 783674c6d934c60d566012df052095f7ea8214b0 Mon Sep 17 00:00:00 2001 From: arinming Date: Mon, 15 Jul 2024 23:44:20 +0900 Subject: [PATCH 01/14] =?UTF-8?q?[FEAT/#79]=20SearchService,=20DTO=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dto/response/SearchViewsResponseDto.kt | 30 +++++++++++++++++++ .../com/terning/data/service/SearchService.kt | 12 ++++++++ 2 files changed, 42 insertions(+) create mode 100644 data/src/main/java/com/terning/data/dto/response/SearchViewsResponseDto.kt create mode 100644 data/src/main/java/com/terning/data/service/SearchService.kt diff --git a/data/src/main/java/com/terning/data/dto/response/SearchViewsResponseDto.kt b/data/src/main/java/com/terning/data/dto/response/SearchViewsResponseDto.kt new file mode 100644 index 000000000..55f247fac --- /dev/null +++ b/data/src/main/java/com/terning/data/dto/response/SearchViewsResponseDto.kt @@ -0,0 +1,30 @@ +package com.terning.data.dto.response + +import kotlinx.serialization.SerialName +import kotlinx.serialization.Serializable + +@Serializable +data class SearchViewsResponseDto( + @SerialName("status") + val status: Int, + @SerialName("message") + val message: String, + @SerialName("result") + val result: Result +) { + @Serializable + data class Result( + @SerialName("accountments") + val accountments: List + ) + + @Serializable + data class SearchViewsData( + @SerialName("internshipAnnouncementId") + val internshipAnnouncementId: Long, + @SerialName("companyImage") + val companyImage: String, + @SerialName("title") + val title: String + ) +} diff --git a/data/src/main/java/com/terning/data/service/SearchService.kt b/data/src/main/java/com/terning/data/service/SearchService.kt new file mode 100644 index 000000000..3d588cb2d --- /dev/null +++ b/data/src/main/java/com/terning/data/service/SearchService.kt @@ -0,0 +1,12 @@ +package com.terning.data.service + +import com.terning.data.dto.response.SearchViewsResponseDto +import retrofit2.http.GET +import retrofit2.http.Query + +interface SearchService { + @GET("api/v1/search/views") + suspend fun getSearchViewsList( + @Query("page") page: Int, + ): SearchViewsResponseDto +} \ No newline at end of file From a6ebc71ee34601e799544be804ca924da1098795 Mon Sep 17 00:00:00 2001 From: arinming Date: Mon, 15 Jul 2024 23:59:48 +0900 Subject: [PATCH 02/14] =?UTF-8?q?[FEAT/#79]=20=EC=A1=B0=ED=9A=8C=EC=88=98?= =?UTF-8?q?=20=EB=A7=8E=EC=9D=80=20=EA=B3=B5=EA=B3=A0=20data=20=EB=AA=A8?= =?UTF-8?q?=EB=93=88=20=EC=84=A4=EA=B3=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../data/datasource/SearchViewsDataSource.kt | 7 +++++++ .../datasourceimpl/SearchViewsDataSourceImpl.kt | 13 +++++++++++++ .../data/dto/response/SearchViewsResponseDto.kt | 15 ++++++++++++--- .../repositoryimpl/SearchViewsRepositoryImpl.kt | 15 +++++++++++++++ .../com/terning/data/service/SearchService.kt | 5 +---- .../entity/response/SearchViewsResponseModel.kt | 7 +++++++ .../domain/repository/SearchViewsRepository.kt | 7 +++++++ 7 files changed, 62 insertions(+), 7 deletions(-) create mode 100644 data/src/main/java/com/terning/data/datasource/SearchViewsDataSource.kt create mode 100644 data/src/main/java/com/terning/data/datasourceimpl/SearchViewsDataSourceImpl.kt create mode 100644 data/src/main/java/com/terning/data/repositoryimpl/SearchViewsRepositoryImpl.kt create mode 100644 domain/src/main/java/com/terning/domain/entity/response/SearchViewsResponseModel.kt create mode 100644 domain/src/main/java/com/terning/domain/repository/SearchViewsRepository.kt diff --git a/data/src/main/java/com/terning/data/datasource/SearchViewsDataSource.kt b/data/src/main/java/com/terning/data/datasource/SearchViewsDataSource.kt new file mode 100644 index 000000000..727cf9671 --- /dev/null +++ b/data/src/main/java/com/terning/data/datasource/SearchViewsDataSource.kt @@ -0,0 +1,7 @@ +package com.terning.data.datasource + +import com.terning.data.dto.response.SearchViewsResponseDto + +interface SearchViewsDataSource { + suspend fun getSearchViews(): SearchViewsResponseDto +} \ No newline at end of file diff --git a/data/src/main/java/com/terning/data/datasourceimpl/SearchViewsDataSourceImpl.kt b/data/src/main/java/com/terning/data/datasourceimpl/SearchViewsDataSourceImpl.kt new file mode 100644 index 000000000..075e657bf --- /dev/null +++ b/data/src/main/java/com/terning/data/datasourceimpl/SearchViewsDataSourceImpl.kt @@ -0,0 +1,13 @@ +package com.terning.data.datasourceimpl + +import com.terning.data.datasource.SearchViewsDataSource +import com.terning.data.dto.response.SearchViewsResponseDto +import com.terning.data.service.SearchService +import javax.inject.Inject + +class SearchViewsDataSourceImpl @Inject constructor( + private val searchService: SearchService +): SearchViewsDataSource { + override suspend fun getSearchViews(): SearchViewsResponseDto = + searchService.getSearchViewsList() +} \ No newline at end of file diff --git a/data/src/main/java/com/terning/data/dto/response/SearchViewsResponseDto.kt b/data/src/main/java/com/terning/data/dto/response/SearchViewsResponseDto.kt index 55f247fac..38ee2544f 100644 --- a/data/src/main/java/com/terning/data/dto/response/SearchViewsResponseDto.kt +++ b/data/src/main/java/com/terning/data/dto/response/SearchViewsResponseDto.kt @@ -1,5 +1,6 @@ package com.terning.data.dto.response +import com.terning.domain.entity.response.SearchViewsResponseModel import kotlinx.serialization.SerialName import kotlinx.serialization.Serializable @@ -10,12 +11,12 @@ data class SearchViewsResponseDto( @SerialName("message") val message: String, @SerialName("result") - val result: Result + val result: Result, ) { @Serializable data class Result( @SerialName("accountments") - val accountments: List + val accountments: List, ) @Serializable @@ -25,6 +26,14 @@ data class SearchViewsResponseDto( @SerialName("companyImage") val companyImage: String, @SerialName("title") - val title: String + val title: String, ) + + fun toMockEntity(): List = result.accountments.map { + SearchViewsResponseModel( + title = it.title, + companyImage = it.companyImage, + announcementId = it.internshipAnnouncementId + ) + } } diff --git a/data/src/main/java/com/terning/data/repositoryimpl/SearchViewsRepositoryImpl.kt b/data/src/main/java/com/terning/data/repositoryimpl/SearchViewsRepositoryImpl.kt new file mode 100644 index 000000000..73e5b99a5 --- /dev/null +++ b/data/src/main/java/com/terning/data/repositoryimpl/SearchViewsRepositoryImpl.kt @@ -0,0 +1,15 @@ +package com.terning.data.repositoryimpl + +import com.terning.data.datasource.SearchViewsDataSource +import com.terning.domain.entity.response.SearchViewsResponseModel +import com.terning.domain.repository.SearchViewsRepository +import javax.inject.Inject + +class SearchViewsRepositoryImpl @Inject constructor( + private val searchViewsDataSource: SearchViewsDataSource, +) : SearchViewsRepository { + override suspend fun getSearchViewsList(): Result> = + runCatching { + searchViewsDataSource.getSearchViews().toMockEntity() + } +} \ No newline at end of file diff --git a/data/src/main/java/com/terning/data/service/SearchService.kt b/data/src/main/java/com/terning/data/service/SearchService.kt index 3d588cb2d..bfdddc887 100644 --- a/data/src/main/java/com/terning/data/service/SearchService.kt +++ b/data/src/main/java/com/terning/data/service/SearchService.kt @@ -2,11 +2,8 @@ package com.terning.data.service import com.terning.data.dto.response.SearchViewsResponseDto import retrofit2.http.GET -import retrofit2.http.Query interface SearchService { @GET("api/v1/search/views") - suspend fun getSearchViewsList( - @Query("page") page: Int, - ): SearchViewsResponseDto + suspend fun getSearchViewsList(): SearchViewsResponseDto } \ No newline at end of file diff --git a/domain/src/main/java/com/terning/domain/entity/response/SearchViewsResponseModel.kt b/domain/src/main/java/com/terning/domain/entity/response/SearchViewsResponseModel.kt new file mode 100644 index 000000000..0877ecf4a --- /dev/null +++ b/domain/src/main/java/com/terning/domain/entity/response/SearchViewsResponseModel.kt @@ -0,0 +1,7 @@ +package com.terning.domain.entity.response + +data class SearchViewsResponseModel( + val title: String, + val companyImage: String, + val announcementId: Long, +) \ No newline at end of file diff --git a/domain/src/main/java/com/terning/domain/repository/SearchViewsRepository.kt b/domain/src/main/java/com/terning/domain/repository/SearchViewsRepository.kt new file mode 100644 index 000000000..3e64e61a0 --- /dev/null +++ b/domain/src/main/java/com/terning/domain/repository/SearchViewsRepository.kt @@ -0,0 +1,7 @@ +package com.terning.domain.repository + +import com.terning.domain.entity.response.SearchViewsResponseModel + +interface SearchViewsRepository { + suspend fun getSearchViewsList(): Result> +} \ No newline at end of file From a759a73d38f4f8fca7ee1ecdc160d0f2dfa31768 Mon Sep 17 00:00:00 2001 From: arinming Date: Tue, 16 Jul 2024 00:10:29 +0900 Subject: [PATCH 03/14] =?UTF-8?q?[FEAT/#79]=20=EC=A1=B0=ED=9A=8C=EC=88=98?= =?UTF-8?q?=20=EB=A7=8E=EC=9D=80=20=EA=B3=B5=EA=B3=A0=20ViewModel=20?= =?UTF-8?q?=EC=84=A4=EA=B3=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/terning/point/di/RepositoryModule.kt | 6 +++ .../feature/search/search/SearchViewModel.kt | 49 +++++++++++++++++++ .../search/search/SearchViewsSideEffect.kt | 7 +++ .../feature/search/search/SearchViewsState.kt | 8 +++ 4 files changed, 70 insertions(+) create mode 100644 feature/src/main/java/com/terning/feature/search/search/SearchViewModel.kt create mode 100644 feature/src/main/java/com/terning/feature/search/search/SearchViewsSideEffect.kt create mode 100644 feature/src/main/java/com/terning/feature/search/search/SearchViewsState.kt diff --git a/app/src/main/java/com/terning/point/di/RepositoryModule.kt b/app/src/main/java/com/terning/point/di/RepositoryModule.kt index 9de02a07a..c70b1bcd4 100644 --- a/app/src/main/java/com/terning/point/di/RepositoryModule.kt +++ b/app/src/main/java/com/terning/point/di/RepositoryModule.kt @@ -1,7 +1,9 @@ package com.terning.point.di import com.terning.data.repositoryimpl.MockRepositoryImpl +import com.terning.data.repositoryimpl.SearchViewsRepositoryImpl import com.terning.domain.repository.MockRepository +import com.terning.domain.repository.SearchViewsRepository import dagger.Binds import dagger.Module import dagger.hilt.InstallIn @@ -15,4 +17,8 @@ abstract class RepositoryModule { @Binds @Singleton abstract fun bindMockRepository(mockRepositoryImpl: MockRepositoryImpl): MockRepository + + @Binds + @Singleton + abstract fun bindSearchViewsRepository(searchViewsRepositoryImpl: SearchViewsRepositoryImpl): SearchViewsRepository } \ No newline at end of file diff --git a/feature/src/main/java/com/terning/feature/search/search/SearchViewModel.kt b/feature/src/main/java/com/terning/feature/search/search/SearchViewModel.kt new file mode 100644 index 000000000..e1b1ddf10 --- /dev/null +++ b/feature/src/main/java/com/terning/feature/search/search/SearchViewModel.kt @@ -0,0 +1,49 @@ +package com.terning.feature.search.search + +import androidx.lifecycle.ViewModel +import androidx.lifecycle.viewModelScope +import com.terning.core.state.UiState +import com.terning.domain.entity.response.SearchViewsResponseModel +import com.terning.domain.repository.SearchViewsRepository +import com.terning.feature.R +import dagger.hilt.android.lifecycle.HiltViewModel +import kotlinx.coroutines.flow.MutableSharedFlow +import kotlinx.coroutines.flow.MutableStateFlow +import kotlinx.coroutines.flow.StateFlow +import kotlinx.coroutines.flow.asStateFlow +import kotlinx.coroutines.launch +import javax.inject.Inject + +@HiltViewModel +class SearchViewModel @Inject constructor( + private val searchViewsRepository: SearchViewsRepository, +) : ViewModel() { + private val _state: MutableStateFlow = MutableStateFlow(SearchViewsState()) + val state: StateFlow = _state.asStateFlow() + + private val _sideEffect: MutableSharedFlow = MutableSharedFlow() + + init { + getSearchViews() + } + + private fun getSearchViews() { + viewModelScope.launch { + searchViewsRepository.getSearchViewsList().onSuccess { response -> + val searchViewsList = response.map { entity -> + SearchViewsResponseModel( + title = entity.title, + companyImage = entity.companyImage, + announcementId = entity.announcementId + ) + } + _state.value = _state.value.copy( + searchViewsList = UiState.Success(searchViewsList) + ) + _sideEffect.emit(SearchViewsSideEffect.Toast(R.string.server_success)) + }.onFailure { + _sideEffect.emit(SearchViewsSideEffect.Toast(R.string.server_failure)) + } + } + } +} \ No newline at end of file diff --git a/feature/src/main/java/com/terning/feature/search/search/SearchViewsSideEffect.kt b/feature/src/main/java/com/terning/feature/search/search/SearchViewsSideEffect.kt new file mode 100644 index 000000000..208b1fad3 --- /dev/null +++ b/feature/src/main/java/com/terning/feature/search/search/SearchViewsSideEffect.kt @@ -0,0 +1,7 @@ +package com.terning.feature.search.search + +import androidx.annotation.StringRes + +sealed class SearchViewsSideEffect { + data class Toast(@StringRes val message: Int) : SearchViewsSideEffect() +} \ No newline at end of file diff --git a/feature/src/main/java/com/terning/feature/search/search/SearchViewsState.kt b/feature/src/main/java/com/terning/feature/search/search/SearchViewsState.kt new file mode 100644 index 000000000..93e2a9b5a --- /dev/null +++ b/feature/src/main/java/com/terning/feature/search/search/SearchViewsState.kt @@ -0,0 +1,8 @@ +package com.terning.feature.search.search + +import com.terning.core.state.UiState +import com.terning.domain.entity.response.SearchViewsResponseModel + +data class SearchViewsState( + var searchViewsList: UiState> = UiState.Loading, +) \ No newline at end of file From 9eeedf7e17fd008a80dd0e76039071b9b84223f7 Mon Sep 17 00:00:00 2001 From: arinming Date: Tue, 16 Jul 2024 00:50:24 +0900 Subject: [PATCH 04/14] =?UTF-8?q?[FEAT/#79]=20=EC=A1=B0=ED=9A=8C=EC=88=98?= =?UTF-8?q?=20=EB=A7=8E=EC=9D=80=20=EA=B3=B5=EA=B3=A0=20=EB=B7=B0=EB=AA=A8?= =?UTF-8?q?=EB=8D=B8=20=ED=98=B8=EC=B6=9C=20=EB=A1=9C=EC=A7=81=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/terning/point/di/DataSourceModule.kt | 7 ++++ .../com/terning/point/di/ServiceModule.kt | 5 +++ .../feature/search/search/SearchRoute.kt | 42 +++++++++++++++++-- .../feature/search/search/SearchViewModel.kt | 4 +- 4 files changed, 54 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/com/terning/point/di/DataSourceModule.kt b/app/src/main/java/com/terning/point/di/DataSourceModule.kt index c1541df6a..612d0d0ef 100644 --- a/app/src/main/java/com/terning/point/di/DataSourceModule.kt +++ b/app/src/main/java/com/terning/point/di/DataSourceModule.kt @@ -1,7 +1,9 @@ package com.terning.point.di import com.terning.data.datasource.MockDataSource +import com.terning.data.datasource.SearchViewsDataSource import com.terning.data.datasourceimpl.MockDataSourceImpl +import com.terning.data.datasourceimpl.SearchViewsDataSourceImpl import dagger.Binds import dagger.Module import dagger.hilt.InstallIn @@ -15,4 +17,9 @@ abstract class DataSourceModule { @Binds @Singleton abstract fun bindMockDataSource(mockDataSourceImpl: MockDataSourceImpl): MockDataSource + + @Binds + @Singleton + abstract fun bindSearchViewsDataSource(searchViewsDataSourceImpl: SearchViewsDataSourceImpl): + SearchViewsDataSource } \ No newline at end of file diff --git a/app/src/main/java/com/terning/point/di/ServiceModule.kt b/app/src/main/java/com/terning/point/di/ServiceModule.kt index 317c02f92..a4c281b3b 100644 --- a/app/src/main/java/com/terning/point/di/ServiceModule.kt +++ b/app/src/main/java/com/terning/point/di/ServiceModule.kt @@ -1,6 +1,7 @@ package com.terning.point.di import com.terning.data.service.MockService +import com.terning.data.service.SearchService import com.terning.point.di.qualifier.OPEN import dagger.Module import dagger.Provides @@ -18,4 +19,8 @@ object ServiceModule { fun provideMockService(@OPEN retrofit: Retrofit): MockService = retrofit.create(MockService::class.java) + @Provides + @Singleton + fun provideSearchService(@OPEN retrofit: Retrofit): SearchService = + retrofit.create(SearchService::class.java) } \ No newline at end of file diff --git a/feature/src/main/java/com/terning/feature/search/search/SearchRoute.kt b/feature/src/main/java/com/terning/feature/search/search/SearchRoute.kt index 17becd309..20ab506b2 100644 --- a/feature/src/main/java/com/terning/feature/search/search/SearchRoute.kt +++ b/feature/src/main/java/com/terning/feature/search/search/SearchRoute.kt @@ -10,9 +10,15 @@ import androidx.compose.material3.HorizontalDivider import androidx.compose.material3.Scaffold import androidx.compose.material3.Text import androidx.compose.runtime.Composable +import androidx.compose.runtime.LaunchedEffect +import androidx.compose.runtime.getValue import androidx.compose.ui.Modifier import androidx.compose.ui.res.stringResource import androidx.compose.ui.unit.dp +import androidx.hilt.navigation.compose.hiltViewModel +import androidx.lifecycle.compose.LocalLifecycleOwner +import androidx.lifecycle.compose.collectAsStateWithLifecycle +import androidx.lifecycle.flowWithLifecycle import androidx.navigation.NavHostController import com.terning.core.designsystem.component.textfield.SearchTextField import com.terning.core.designsystem.component.topappbar.LogoTopAppBar @@ -20,6 +26,8 @@ import com.terning.core.designsystem.theme.Black import com.terning.core.designsystem.theme.Grey100 import com.terning.core.designsystem.theme.TerningTheme import com.terning.core.extension.noRippleClickable +import com.terning.core.state.UiState +import com.terning.domain.entity.response.SearchViewsResponseModel import com.terning.feature.R import com.terning.feature.search.search.component.ImageSlider import com.terning.feature.search.search.component.InternListType @@ -29,16 +37,44 @@ import com.terning.feature.search.searchprocess.navigation.navigateSearchProcess @Composable fun SearchRoute( navController: NavHostController, + viewModel: SearchViewModel = hiltViewModel(), ) { - SearchScreen( - navController = navController - ) + val lifecycleOwner = LocalLifecycleOwner.current + + val state by viewModel.state.collectAsStateWithLifecycle(lifecycleOwner = lifecycleOwner) + + LaunchedEffect(key1 = true) { + viewModel.getSearchViews() + } + + LaunchedEffect(viewModel.sideEffect, lifecycleOwner) { + viewModel.sideEffect.flowWithLifecycle(lifecycle = lifecycleOwner.lifecycle) + .collect { sideEffect -> + when (sideEffect) { + is SearchViewsSideEffect.Toast -> {} + } + } + } + + when (state.searchViewsList) { + is UiState.Loading -> {} + is UiState.Empty -> {} + is UiState.Failure -> {} + is UiState.Success -> { + SearchScreen( + navController = navController, + searchViewsList = (state.searchViewsList as UiState.Success>).data + ) + } + + } } @Composable fun SearchScreen( modifier: Modifier = Modifier, navController: NavHostController, + searchViewsList: List, ) { val images = listOf( R.drawable.ic_nav_search, diff --git a/feature/src/main/java/com/terning/feature/search/search/SearchViewModel.kt b/feature/src/main/java/com/terning/feature/search/search/SearchViewModel.kt index e1b1ddf10..d55431d8c 100644 --- a/feature/src/main/java/com/terning/feature/search/search/SearchViewModel.kt +++ b/feature/src/main/java/com/terning/feature/search/search/SearchViewModel.kt @@ -10,6 +10,7 @@ import dagger.hilt.android.lifecycle.HiltViewModel import kotlinx.coroutines.flow.MutableSharedFlow import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.flow.StateFlow +import kotlinx.coroutines.flow.asSharedFlow import kotlinx.coroutines.flow.asStateFlow import kotlinx.coroutines.launch import javax.inject.Inject @@ -22,12 +23,13 @@ class SearchViewModel @Inject constructor( val state: StateFlow = _state.asStateFlow() private val _sideEffect: MutableSharedFlow = MutableSharedFlow() + val sideEffect = _sideEffect.asSharedFlow() init { getSearchViews() } - private fun getSearchViews() { + fun getSearchViews() { viewModelScope.launch { searchViewsRepository.getSearchViewsList().onSuccess { response -> val searchViewsList = response.map { entity -> From 37568729017c3abca9a0b6e911c337ca22882ff5 Mon Sep 17 00:00:00 2001 From: arinming Date: Tue, 16 Jul 2024 01:09:42 +0900 Subject: [PATCH 05/14] =?UTF-8?q?[FEAT/#79]=20=EC=9D=B8=ED=84=B4=20?= =?UTF-8?q?=EC=BB=B4=ED=8F=AC=EB=84=8C=ED=8A=B8=EC=97=90=20searchViewsList?= =?UTF-8?q?=20=EC=A0=81=EC=9A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../feature/search/search/SearchRoute.kt | 10 +++++-- .../search/search/component/SearchIntern.kt | 27 ++++++++++++------- .../search/component/SearchInternList.kt | 8 ++++-- feature/src/main/res/values/strings.xml | 1 + 4 files changed, 33 insertions(+), 13 deletions(-) diff --git a/feature/src/main/java/com/terning/feature/search/search/SearchRoute.kt b/feature/src/main/java/com/terning/feature/search/search/SearchRoute.kt index 20ab506b2..d024b6f42 100644 --- a/feature/src/main/java/com/terning/feature/search/search/SearchRoute.kt +++ b/feature/src/main/java/com/terning/feature/search/search/SearchRoute.kt @@ -127,13 +127,19 @@ fun SearchScreen( color = Black ) - SearchInternList(type = InternListType.VIEW) + SearchInternList( + type = InternListType.VIEW, + searchViewsList = searchViewsList + ) HorizontalDivider( thickness = 4.dp, modifier = Modifier.padding(vertical = 8.dp), color = Grey100, ) - SearchInternList(type = InternListType.SCRAP) + SearchInternList( + type = InternListType.SCRAP, + searchViewsList = searchViewsList + ) } } } diff --git a/feature/src/main/java/com/terning/feature/search/search/component/SearchIntern.kt b/feature/src/main/java/com/terning/feature/search/search/component/SearchIntern.kt index e2b6109f5..1101ce7b6 100644 --- a/feature/src/main/java/com/terning/feature/search/search/component/SearchIntern.kt +++ b/feature/src/main/java/com/terning/feature/search/search/component/SearchIntern.kt @@ -1,6 +1,5 @@ package com.terning.feature.search.search.component -import androidx.compose.foundation.Image import androidx.compose.foundation.background import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Column @@ -13,17 +12,23 @@ import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.draw.shadow import androidx.compose.ui.graphics.Color -import androidx.compose.ui.res.painterResource +import androidx.compose.ui.platform.LocalContext +import androidx.compose.ui.res.stringResource import androidx.compose.ui.text.style.TextOverflow import androidx.compose.ui.unit.dp +import coil.compose.AsyncImage +import coil.request.ImageRequest import com.terning.core.designsystem.theme.Black import com.terning.core.designsystem.theme.Grey400 import com.terning.core.designsystem.theme.TerningTheme import com.terning.core.designsystem.theme.White +import com.terning.domain.entity.response.SearchViewsResponseModel import com.terning.feature.R @Composable -fun SearchIntern() { +fun SearchIntern( + searchViews: SearchViewsResponseModel, +) { Column( verticalArrangement = Arrangement.spacedBy( 10.dp, @@ -43,16 +48,20 @@ fun SearchIntern() { ) .padding(vertical = 8.dp) ) { - Image( - painter = painterResource(id = R.drawable.ic_nav_search), - contentDescription = null, + AsyncImage( + model = ImageRequest.Builder(LocalContext.current) + .data(searchViews.companyImage) + .crossfade(true) + .build(), + contentDescription = stringResource(id = R.string.search_image), modifier = Modifier .fillMaxWidth() .padding(16.dp) - .background(Grey400) - ) + .background(Grey400), + + ) Text( - text = "[유한킴벌리]\n그린캠프 w. 대학생 숲 \n활동가 모집", + text = searchViews.title, modifier = Modifier.padding(horizontal = 8.dp), style = TerningTheme.typography.body6, color = Black, diff --git a/feature/src/main/java/com/terning/feature/search/search/component/SearchInternList.kt b/feature/src/main/java/com/terning/feature/search/search/component/SearchInternList.kt index 0060685c0..3a03eaac7 100644 --- a/feature/src/main/java/com/terning/feature/search/search/component/SearchInternList.kt +++ b/feature/src/main/java/com/terning/feature/search/search/component/SearchInternList.kt @@ -11,11 +11,13 @@ import androidx.compose.ui.res.stringResource import androidx.compose.ui.unit.dp import com.terning.core.designsystem.theme.Grey400 import com.terning.core.designsystem.theme.TerningTheme +import com.terning.domain.entity.response.SearchViewsResponseModel import com.terning.feature.R @Composable fun SearchInternList( type: InternListType, + searchViewsList: List, ) { Column(modifier = Modifier.padding(horizontal = 24.dp)) { Text( @@ -33,8 +35,10 @@ fun SearchInternList( modifier = Modifier.padding(vertical = 8.dp), horizontalArrangement = Arrangement.spacedBy(12.dp), ) { - items(5) { - SearchIntern() + items(searchViewsList.size) { index -> + SearchIntern( + searchViews = searchViewsList[index] + ) } } } diff --git a/feature/src/main/res/values/strings.xml b/feature/src/main/res/values/strings.xml index d89353a51..b70bd83d7 100644 --- a/feature/src/main/res/values/strings.xml +++ b/feature/src/main/res/values/strings.xml @@ -31,6 +31,7 @@ 관심있는 인턴 공고 키워드를 검색해 보세요 요즘 대학생들에게 인기 있는 공고 지금 조회수가 많은 공고들이에요 + 공고 이미지 지금 스크랩수가 많은 공고들이에요 From 396e4f74390e5e9bb9126a2424765ee0dc6b551a Mon Sep 17 00:00:00 2001 From: arinming Date: Tue, 16 Jul 2024 01:27:02 +0900 Subject: [PATCH 06/14] =?UTF-8?q?[FEAT/#79]=20=EB=8D=94=EB=AF=B8=EB=8D=B0?= =?UTF-8?q?=EC=9D=B4=ED=84=B0=20=EC=97=B0=EA=B2=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../SearchViewsDataSourceImpl.kt | 22 +++++++++++++++++-- .../dto/response/SearchViewsResponseDto.kt | 2 +- .../SearchViewsRepositoryImpl.kt | 2 +- .../com/terning/data/service/SearchService.kt | 22 ++++++++++++++++++- 4 files changed, 43 insertions(+), 5 deletions(-) diff --git a/data/src/main/java/com/terning/data/datasourceimpl/SearchViewsDataSourceImpl.kt b/data/src/main/java/com/terning/data/datasourceimpl/SearchViewsDataSourceImpl.kt index 075e657bf..e20473fbd 100644 --- a/data/src/main/java/com/terning/data/datasourceimpl/SearchViewsDataSourceImpl.kt +++ b/data/src/main/java/com/terning/data/datasourceimpl/SearchViewsDataSourceImpl.kt @@ -8,6 +8,24 @@ import javax.inject.Inject class SearchViewsDataSourceImpl @Inject constructor( private val searchService: SearchService ): SearchViewsDataSource { - override suspend fun getSearchViews(): SearchViewsResponseDto = - searchService.getSearchViewsList() + override suspend fun getSearchViews(): SearchViewsResponseDto { + return SearchViewsResponseDto( + status = 200, + message = "탐색 > 조회수 많은 공고를 조회하는데 성공했습니다", + result = SearchViewsResponseDto.Result( + accountments = listOf( + SearchViewsResponseDto.SearchViewsData( + internshipAnnouncementId = 23L, + companyImage = "https://www.google.co.kr/url?sa=i&url=https%3A%2F%2Fm.blog.naver.com%2F41minit%2F222640892626&psig=AOvVaw37hxkUffP2inv54ayG_I3K&ust=1721147168119000&source=images&cd=vfe&opi=89978449&ved=0CBEQjRxqFwoTCMjD_f66qYcDFQAAAAAdAAAAABAE", + title = "[유한킴벌리]그린캠프 w. 대학생 숲 활동가 모집" + ), + SearchViewsResponseDto.SearchViewsData( + internshipAnnouncementId = 3L, + companyImage = "https://www.google.co.kr/url?sa=i&url=https%3A%2F%2Fm.blog.naver.com%2F41minit%2F222640892626&psig=AOvVaw37hxkUffP2inv54ayG_I3K&ust=1721147168119000&source=images&cd=vfe&opi=89978449&ved=0CBEQjRxqFwoTCMjD_f66qYcDFQAAAAAdAAAAABAE", + title = "[Someone] 콘텐츠 마케터 대학생 인턴 채용" + ) + ) + ) + ) + } } \ No newline at end of file diff --git a/data/src/main/java/com/terning/data/dto/response/SearchViewsResponseDto.kt b/data/src/main/java/com/terning/data/dto/response/SearchViewsResponseDto.kt index 38ee2544f..e21a39387 100644 --- a/data/src/main/java/com/terning/data/dto/response/SearchViewsResponseDto.kt +++ b/data/src/main/java/com/terning/data/dto/response/SearchViewsResponseDto.kt @@ -29,7 +29,7 @@ data class SearchViewsResponseDto( val title: String, ) - fun toMockEntity(): List = result.accountments.map { + fun toSearchViewsEntity(): List = result.accountments.map { SearchViewsResponseModel( title = it.title, companyImage = it.companyImage, diff --git a/data/src/main/java/com/terning/data/repositoryimpl/SearchViewsRepositoryImpl.kt b/data/src/main/java/com/terning/data/repositoryimpl/SearchViewsRepositoryImpl.kt index 73e5b99a5..24110f2bd 100644 --- a/data/src/main/java/com/terning/data/repositoryimpl/SearchViewsRepositoryImpl.kt +++ b/data/src/main/java/com/terning/data/repositoryimpl/SearchViewsRepositoryImpl.kt @@ -10,6 +10,6 @@ class SearchViewsRepositoryImpl @Inject constructor( ) : SearchViewsRepository { override suspend fun getSearchViewsList(): Result> = runCatching { - searchViewsDataSource.getSearchViews().toMockEntity() + searchViewsDataSource.getSearchViews().toSearchViewsEntity() } } \ No newline at end of file diff --git a/data/src/main/java/com/terning/data/service/SearchService.kt b/data/src/main/java/com/terning/data/service/SearchService.kt index bfdddc887..b4a38f501 100644 --- a/data/src/main/java/com/terning/data/service/SearchService.kt +++ b/data/src/main/java/com/terning/data/service/SearchService.kt @@ -5,5 +5,25 @@ import retrofit2.http.GET interface SearchService { @GET("api/v1/search/views") - suspend fun getSearchViewsList(): SearchViewsResponseDto + suspend fun getSearchViewsList(): SearchViewsResponseDto { + return SearchViewsResponseDto( + status = 200, + message = "탐색 > 조회수 많은 공고를 조회하는데 성공했습니다", + result = SearchViewsResponseDto.Result( + accountments = listOf( + SearchViewsResponseDto.SearchViewsData( + internshipAnnouncementId = 23, + companyImage = "https://example.com/image1.jpg", + title = "[유한킴벌리]그린캠프 w. 대학생 숲 활동가 모집" + ), + SearchViewsResponseDto.SearchViewsData( + internshipAnnouncementId = 3, + companyImage = "https://example.com/image2.jpg", + title = "[Someone] 콘텐츠 마케터 대학생 인턴 채용" + ) + ) + ) + ) + } + } \ No newline at end of file From b5bb2cdebdc5ce4a83de5a4539f54f1662ec8f1a Mon Sep 17 00:00:00 2001 From: arinming Date: Tue, 16 Jul 2024 01:53:51 +0900 Subject: [PATCH 07/14] =?UTF-8?q?[FEAT/#79]=20=EC=9D=B4=EB=AF=B8=EC=A7=80?= =?UTF-8?q?=20=EB=A7=A4=ED=95=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../SearchViewsDataSourceImpl.kt | 4 +- .../search/search/component/SearchIntern.kt | 38 ++++++++++--------- 2 files changed, 23 insertions(+), 19 deletions(-) diff --git a/data/src/main/java/com/terning/data/datasourceimpl/SearchViewsDataSourceImpl.kt b/data/src/main/java/com/terning/data/datasourceimpl/SearchViewsDataSourceImpl.kt index e20473fbd..ff92130ac 100644 --- a/data/src/main/java/com/terning/data/datasourceimpl/SearchViewsDataSourceImpl.kt +++ b/data/src/main/java/com/terning/data/datasourceimpl/SearchViewsDataSourceImpl.kt @@ -16,12 +16,12 @@ class SearchViewsDataSourceImpl @Inject constructor( accountments = listOf( SearchViewsResponseDto.SearchViewsData( internshipAnnouncementId = 23L, - companyImage = "https://www.google.co.kr/url?sa=i&url=https%3A%2F%2Fm.blog.naver.com%2F41minit%2F222640892626&psig=AOvVaw37hxkUffP2inv54ayG_I3K&ust=1721147168119000&source=images&cd=vfe&opi=89978449&ved=0CBEQjRxqFwoTCMjD_f66qYcDFQAAAAAdAAAAABAE", + companyImage = "https://image.dongascience.com/Photo/2019/09/d2468576cecf1313437de5a883bfa2ed.jpg", title = "[유한킴벌리]그린캠프 w. 대학생 숲 활동가 모집" ), SearchViewsResponseDto.SearchViewsData( internshipAnnouncementId = 3L, - companyImage = "https://www.google.co.kr/url?sa=i&url=https%3A%2F%2Fm.blog.naver.com%2F41minit%2F222640892626&psig=AOvVaw37hxkUffP2inv54ayG_I3K&ust=1721147168119000&source=images&cd=vfe&opi=89978449&ved=0CBEQjRxqFwoTCMjD_f66qYcDFQAAAAAdAAAAABAE", + companyImage = "https://https://image.dongascience.com/Photo/2019/09/d2468576cecf1313437de5a883bfa2ed.jpg", title = "[Someone] 콘텐츠 마케터 대학생 인턴 채용" ) ) diff --git a/feature/src/main/java/com/terning/feature/search/search/component/SearchIntern.kt b/feature/src/main/java/com/terning/feature/search/search/component/SearchIntern.kt index 1101ce7b6..8c9c45462 100644 --- a/feature/src/main/java/com/terning/feature/search/search/component/SearchIntern.kt +++ b/feature/src/main/java/com/terning/feature/search/search/component/SearchIntern.kt @@ -3,15 +3,17 @@ package com.terning.feature.search.search.component import androidx.compose.foundation.background import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Column -import androidx.compose.foundation.layout.fillMaxWidth +import androidx.compose.foundation.layout.height import androidx.compose.foundation.layout.padding +import androidx.compose.foundation.layout.width +import androidx.compose.foundation.layout.wrapContentSize import androidx.compose.foundation.shape.RoundedCornerShape import androidx.compose.material3.Text import androidx.compose.runtime.Composable import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier -import androidx.compose.ui.draw.shadow -import androidx.compose.ui.graphics.Color +import androidx.compose.ui.draw.clip +import androidx.compose.ui.layout.ContentScale import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.res.stringResource import androidx.compose.ui.text.style.TextOverflow @@ -19,9 +21,9 @@ import androidx.compose.ui.unit.dp import coil.compose.AsyncImage import coil.request.ImageRequest import com.terning.core.designsystem.theme.Black -import com.terning.core.designsystem.theme.Grey400 import com.terning.core.designsystem.theme.TerningTheme import com.terning.core.designsystem.theme.White +import com.terning.core.extension.customShadow import com.terning.domain.entity.response.SearchViewsResponseModel import com.terning.feature.R @@ -36,12 +38,7 @@ fun SearchIntern( ), horizontalAlignment = Alignment.CenterHorizontally, modifier = Modifier - .shadow( - elevation = 4.dp, - // TODO 효빈 그림자 PR 풀 받아서 바꾸기 - spotColor = Color(0x26DDDDDD), - ambientColor = Color(0x26DDDDDD) - ) + .width(140.dp) .background( color = White, shape = RoundedCornerShape(size = 5.dp) @@ -54,15 +51,22 @@ fun SearchIntern( .crossfade(true) .build(), contentDescription = stringResource(id = R.string.search_image), + contentScale = ContentScale.Crop, modifier = Modifier - .fillMaxWidth() - .padding(16.dp) - .background(Grey400), - - ) + .height(76.dp) + .wrapContentSize() + .clip( + RoundedCornerShape( + topStart = 5.dp, + topEnd = 5.dp + ) + ) + ) Text( - text = searchViews.title, - modifier = Modifier.padding(horizontal = 8.dp), + text = "${searchViews.title} ${searchViews.title}${searchViews.title}${searchViews.title}", + modifier = Modifier + .padding(horizontal = 8.dp) + .wrapContentSize(), style = TerningTheme.typography.body6, color = Black, overflow = TextOverflow.Ellipsis, From 4dad80422fedc9c2001caa3087f741405cbcb604 Mon Sep 17 00:00:00 2001 From: arinming Date: Tue, 16 Jul 2024 02:01:46 +0900 Subject: [PATCH 08/14] =?UTF-8?q?[FEAT/#79]=20=EA=B3=B5=EA=B3=A0=20?= =?UTF-8?q?=EC=83=81=EC=84=B8=20=ED=8E=98=EC=9D=B4=EC=A7=80=20=EA=B2=BD?= =?UTF-8?q?=EB=A1=9C=20=EC=9D=B4=EB=8F=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/com/terning/feature/intern/InternRoute.kt | 4 +++- .../java/com/terning/feature/search/search/SearchRoute.kt | 6 ++++-- .../feature/search/search/component/SearchIntern.kt | 8 +++++++- .../feature/search/search/component/SearchInternList.kt | 5 ++++- 4 files changed, 18 insertions(+), 5 deletions(-) diff --git a/feature/src/main/java/com/terning/feature/intern/InternRoute.kt b/feature/src/main/java/com/terning/feature/intern/InternRoute.kt index 198943c7a..8a035648a 100644 --- a/feature/src/main/java/com/terning/feature/intern/InternRoute.kt +++ b/feature/src/main/java/com/terning/feature/intern/InternRoute.kt @@ -71,7 +71,9 @@ fun InternScreen( color = Grey200, offsetY = 2.dp ), - onBackButtonClick = {}, + onBackButtonClick = { + navController.navigateUp() + }, ) }, bottomBar = { diff --git a/feature/src/main/java/com/terning/feature/search/search/SearchRoute.kt b/feature/src/main/java/com/terning/feature/search/search/SearchRoute.kt index d024b6f42..9b3784b25 100644 --- a/feature/src/main/java/com/terning/feature/search/search/SearchRoute.kt +++ b/feature/src/main/java/com/terning/feature/search/search/SearchRoute.kt @@ -129,7 +129,8 @@ fun SearchScreen( SearchInternList( type = InternListType.VIEW, - searchViewsList = searchViewsList + searchViewsList = searchViewsList, + navController = navController ) HorizontalDivider( thickness = 4.dp, @@ -138,7 +139,8 @@ fun SearchScreen( ) SearchInternList( type = InternListType.SCRAP, - searchViewsList = searchViewsList + searchViewsList = searchViewsList, + navController = navController ) } } diff --git a/feature/src/main/java/com/terning/feature/search/search/component/SearchIntern.kt b/feature/src/main/java/com/terning/feature/search/search/component/SearchIntern.kt index 8c9c45462..f192453f4 100644 --- a/feature/src/main/java/com/terning/feature/search/search/component/SearchIntern.kt +++ b/feature/src/main/java/com/terning/feature/search/search/component/SearchIntern.kt @@ -18,18 +18,21 @@ import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.res.stringResource import androidx.compose.ui.text.style.TextOverflow import androidx.compose.ui.unit.dp +import androidx.navigation.NavHostController import coil.compose.AsyncImage import coil.request.ImageRequest import com.terning.core.designsystem.theme.Black import com.terning.core.designsystem.theme.TerningTheme import com.terning.core.designsystem.theme.White -import com.terning.core.extension.customShadow +import com.terning.core.extension.noRippleClickable import com.terning.domain.entity.response.SearchViewsResponseModel import com.terning.feature.R +import com.terning.feature.intern.navigation.navigateIntern @Composable fun SearchIntern( searchViews: SearchViewsResponseModel, + navController: NavHostController, ) { Column( verticalArrangement = Arrangement.spacedBy( @@ -44,6 +47,9 @@ fun SearchIntern( shape = RoundedCornerShape(size = 5.dp) ) .padding(vertical = 8.dp) + .noRippleClickable { + navController.navigateIntern() + } ) { AsyncImage( model = ImageRequest.Builder(LocalContext.current) diff --git a/feature/src/main/java/com/terning/feature/search/search/component/SearchInternList.kt b/feature/src/main/java/com/terning/feature/search/search/component/SearchInternList.kt index 3a03eaac7..e76f9f3b0 100644 --- a/feature/src/main/java/com/terning/feature/search/search/component/SearchInternList.kt +++ b/feature/src/main/java/com/terning/feature/search/search/component/SearchInternList.kt @@ -9,6 +9,7 @@ import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier import androidx.compose.ui.res.stringResource import androidx.compose.ui.unit.dp +import androidx.navigation.NavHostController import com.terning.core.designsystem.theme.Grey400 import com.terning.core.designsystem.theme.TerningTheme import com.terning.domain.entity.response.SearchViewsResponseModel @@ -18,6 +19,7 @@ import com.terning.feature.R fun SearchInternList( type: InternListType, searchViewsList: List, + navController: NavHostController ) { Column(modifier = Modifier.padding(horizontal = 24.dp)) { Text( @@ -37,7 +39,8 @@ fun SearchInternList( ) { items(searchViewsList.size) { index -> SearchIntern( - searchViews = searchViewsList[index] + searchViews = searchViewsList[index], + navController = navController ) } } From 572efd4fc34c18aa2429522c61080f98f87ea219 Mon Sep 17 00:00:00 2001 From: arinming Date: Tue, 16 Jul 2024 02:14:14 +0900 Subject: [PATCH 09/14] =?UTF-8?q?[RENAME/#79]=20=EA=B3=B5=EA=B3=A0=20?= =?UTF-8?q?=EC=A0=95=EB=B3=B4=20DTO=20=EC=9D=B4=EB=A6=84=20=EB=B3=80?= =?UTF-8?q?=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../terning/data/datasource/SearchViewsDataSource.kt | 4 ++-- .../data/datasourceimpl/SearchViewsDataSourceImpl.kt | 12 ++++++------ ...sponseDto.kt => InternAnnouncementResponseDto.kt} | 12 ++++++------ .../data/repositoryimpl/SearchViewsRepositoryImpl.kt | 6 +++--- .../java/com/terning/data/service/SearchService.kt | 12 ++++++------ ...seModel.kt => InternAnnouncementResponseModel.kt} | 2 +- .../domain/repository/SearchViewsRepository.kt | 4 ++-- .../com/terning/feature/search/search/SearchRoute.kt | 6 +++--- .../terning/feature/search/search/SearchViewModel.kt | 4 ++-- .../feature/search/search/SearchViewsState.kt | 4 ++-- .../feature/search/search/component/SearchIntern.kt | 4 ++-- .../search/search/component/SearchInternList.kt | 4 ++-- 12 files changed, 37 insertions(+), 37 deletions(-) rename data/src/main/java/com/terning/data/dto/response/{SearchViewsResponseDto.kt => InternAnnouncementResponseDto.kt} (68%) rename domain/src/main/java/com/terning/domain/entity/response/{SearchViewsResponseModel.kt => InternAnnouncementResponseModel.kt} (74%) diff --git a/data/src/main/java/com/terning/data/datasource/SearchViewsDataSource.kt b/data/src/main/java/com/terning/data/datasource/SearchViewsDataSource.kt index 727cf9671..139c5d971 100644 --- a/data/src/main/java/com/terning/data/datasource/SearchViewsDataSource.kt +++ b/data/src/main/java/com/terning/data/datasource/SearchViewsDataSource.kt @@ -1,7 +1,7 @@ package com.terning.data.datasource -import com.terning.data.dto.response.SearchViewsResponseDto +import com.terning.data.dto.response.InternAnnouncementResponseDto interface SearchViewsDataSource { - suspend fun getSearchViews(): SearchViewsResponseDto + suspend fun getSearchViews(): InternAnnouncementResponseDto } \ No newline at end of file diff --git a/data/src/main/java/com/terning/data/datasourceimpl/SearchViewsDataSourceImpl.kt b/data/src/main/java/com/terning/data/datasourceimpl/SearchViewsDataSourceImpl.kt index ff92130ac..26c00e999 100644 --- a/data/src/main/java/com/terning/data/datasourceimpl/SearchViewsDataSourceImpl.kt +++ b/data/src/main/java/com/terning/data/datasourceimpl/SearchViewsDataSourceImpl.kt @@ -1,25 +1,25 @@ package com.terning.data.datasourceimpl import com.terning.data.datasource.SearchViewsDataSource -import com.terning.data.dto.response.SearchViewsResponseDto +import com.terning.data.dto.response.InternAnnouncementResponseDto import com.terning.data.service.SearchService import javax.inject.Inject class SearchViewsDataSourceImpl @Inject constructor( private val searchService: SearchService ): SearchViewsDataSource { - override suspend fun getSearchViews(): SearchViewsResponseDto { - return SearchViewsResponseDto( + override suspend fun getSearchViews(): InternAnnouncementResponseDto { + return InternAnnouncementResponseDto( status = 200, message = "탐색 > 조회수 많은 공고를 조회하는데 성공했습니다", - result = SearchViewsResponseDto.Result( + result = InternAnnouncementResponseDto.Result( accountments = listOf( - SearchViewsResponseDto.SearchViewsData( + InternAnnouncementResponseDto.InternAnnouncementData( internshipAnnouncementId = 23L, companyImage = "https://image.dongascience.com/Photo/2019/09/d2468576cecf1313437de5a883bfa2ed.jpg", title = "[유한킴벌리]그린캠프 w. 대학생 숲 활동가 모집" ), - SearchViewsResponseDto.SearchViewsData( + InternAnnouncementResponseDto.InternAnnouncementData( internshipAnnouncementId = 3L, companyImage = "https://https://image.dongascience.com/Photo/2019/09/d2468576cecf1313437de5a883bfa2ed.jpg", title = "[Someone] 콘텐츠 마케터 대학생 인턴 채용" diff --git a/data/src/main/java/com/terning/data/dto/response/SearchViewsResponseDto.kt b/data/src/main/java/com/terning/data/dto/response/InternAnnouncementResponseDto.kt similarity index 68% rename from data/src/main/java/com/terning/data/dto/response/SearchViewsResponseDto.kt rename to data/src/main/java/com/terning/data/dto/response/InternAnnouncementResponseDto.kt index e21a39387..8830fc32d 100644 --- a/data/src/main/java/com/terning/data/dto/response/SearchViewsResponseDto.kt +++ b/data/src/main/java/com/terning/data/dto/response/InternAnnouncementResponseDto.kt @@ -1,11 +1,11 @@ package com.terning.data.dto.response -import com.terning.domain.entity.response.SearchViewsResponseModel +import com.terning.domain.entity.response.InternAnnouncementResponseModel import kotlinx.serialization.SerialName import kotlinx.serialization.Serializable @Serializable -data class SearchViewsResponseDto( +data class InternAnnouncementResponseDto( @SerialName("status") val status: Int, @SerialName("message") @@ -16,11 +16,11 @@ data class SearchViewsResponseDto( @Serializable data class Result( @SerialName("accountments") - val accountments: List, + val accountments: List, ) @Serializable - data class SearchViewsData( + data class InternAnnouncementData( @SerialName("internshipAnnouncementId") val internshipAnnouncementId: Long, @SerialName("companyImage") @@ -29,8 +29,8 @@ data class SearchViewsResponseDto( val title: String, ) - fun toSearchViewsEntity(): List = result.accountments.map { - SearchViewsResponseModel( + fun toInternAnnouncementEntity(): List = result.accountments.map { + InternAnnouncementResponseModel( title = it.title, companyImage = it.companyImage, announcementId = it.internshipAnnouncementId diff --git a/data/src/main/java/com/terning/data/repositoryimpl/SearchViewsRepositoryImpl.kt b/data/src/main/java/com/terning/data/repositoryimpl/SearchViewsRepositoryImpl.kt index 24110f2bd..8036b4b79 100644 --- a/data/src/main/java/com/terning/data/repositoryimpl/SearchViewsRepositoryImpl.kt +++ b/data/src/main/java/com/terning/data/repositoryimpl/SearchViewsRepositoryImpl.kt @@ -1,15 +1,15 @@ package com.terning.data.repositoryimpl import com.terning.data.datasource.SearchViewsDataSource -import com.terning.domain.entity.response.SearchViewsResponseModel +import com.terning.domain.entity.response.InternAnnouncementResponseModel import com.terning.domain.repository.SearchViewsRepository import javax.inject.Inject class SearchViewsRepositoryImpl @Inject constructor( private val searchViewsDataSource: SearchViewsDataSource, ) : SearchViewsRepository { - override suspend fun getSearchViewsList(): Result> = + override suspend fun getSearchViewsList(): Result> = runCatching { - searchViewsDataSource.getSearchViews().toSearchViewsEntity() + searchViewsDataSource.getSearchViews().toInternAnnouncementEntity() } } \ No newline at end of file diff --git a/data/src/main/java/com/terning/data/service/SearchService.kt b/data/src/main/java/com/terning/data/service/SearchService.kt index b4a38f501..2282ac28f 100644 --- a/data/src/main/java/com/terning/data/service/SearchService.kt +++ b/data/src/main/java/com/terning/data/service/SearchService.kt @@ -1,22 +1,22 @@ package com.terning.data.service -import com.terning.data.dto.response.SearchViewsResponseDto +import com.terning.data.dto.response.InternAnnouncementResponseDto import retrofit2.http.GET interface SearchService { @GET("api/v1/search/views") - suspend fun getSearchViewsList(): SearchViewsResponseDto { - return SearchViewsResponseDto( + suspend fun getSearchViewsList(): InternAnnouncementResponseDto { + return InternAnnouncementResponseDto( status = 200, message = "탐색 > 조회수 많은 공고를 조회하는데 성공했습니다", - result = SearchViewsResponseDto.Result( + result = InternAnnouncementResponseDto.Result( accountments = listOf( - SearchViewsResponseDto.SearchViewsData( + InternAnnouncementResponseDto.InternAnnouncementData( internshipAnnouncementId = 23, companyImage = "https://example.com/image1.jpg", title = "[유한킴벌리]그린캠프 w. 대학생 숲 활동가 모집" ), - SearchViewsResponseDto.SearchViewsData( + InternAnnouncementResponseDto.InternAnnouncementData( internshipAnnouncementId = 3, companyImage = "https://example.com/image2.jpg", title = "[Someone] 콘텐츠 마케터 대학생 인턴 채용" diff --git a/domain/src/main/java/com/terning/domain/entity/response/SearchViewsResponseModel.kt b/domain/src/main/java/com/terning/domain/entity/response/InternAnnouncementResponseModel.kt similarity index 74% rename from domain/src/main/java/com/terning/domain/entity/response/SearchViewsResponseModel.kt rename to domain/src/main/java/com/terning/domain/entity/response/InternAnnouncementResponseModel.kt index 0877ecf4a..f20adf48d 100644 --- a/domain/src/main/java/com/terning/domain/entity/response/SearchViewsResponseModel.kt +++ b/domain/src/main/java/com/terning/domain/entity/response/InternAnnouncementResponseModel.kt @@ -1,6 +1,6 @@ package com.terning.domain.entity.response -data class SearchViewsResponseModel( +data class InternAnnouncementResponseModel( val title: String, val companyImage: String, val announcementId: Long, diff --git a/domain/src/main/java/com/terning/domain/repository/SearchViewsRepository.kt b/domain/src/main/java/com/terning/domain/repository/SearchViewsRepository.kt index 3e64e61a0..0a1d00237 100644 --- a/domain/src/main/java/com/terning/domain/repository/SearchViewsRepository.kt +++ b/domain/src/main/java/com/terning/domain/repository/SearchViewsRepository.kt @@ -1,7 +1,7 @@ package com.terning.domain.repository -import com.terning.domain.entity.response.SearchViewsResponseModel +import com.terning.domain.entity.response.InternAnnouncementResponseModel interface SearchViewsRepository { - suspend fun getSearchViewsList(): Result> + suspend fun getSearchViewsList(): Result> } \ No newline at end of file diff --git a/feature/src/main/java/com/terning/feature/search/search/SearchRoute.kt b/feature/src/main/java/com/terning/feature/search/search/SearchRoute.kt index 9b3784b25..93c3c5fda 100644 --- a/feature/src/main/java/com/terning/feature/search/search/SearchRoute.kt +++ b/feature/src/main/java/com/terning/feature/search/search/SearchRoute.kt @@ -27,7 +27,7 @@ import com.terning.core.designsystem.theme.Grey100 import com.terning.core.designsystem.theme.TerningTheme import com.terning.core.extension.noRippleClickable import com.terning.core.state.UiState -import com.terning.domain.entity.response.SearchViewsResponseModel +import com.terning.domain.entity.response.InternAnnouncementResponseModel import com.terning.feature.R import com.terning.feature.search.search.component.ImageSlider import com.terning.feature.search.search.component.InternListType @@ -63,7 +63,7 @@ fun SearchRoute( is UiState.Success -> { SearchScreen( navController = navController, - searchViewsList = (state.searchViewsList as UiState.Success>).data + searchViewsList = (state.searchViewsList as UiState.Success>).data ) } @@ -74,7 +74,7 @@ fun SearchRoute( fun SearchScreen( modifier: Modifier = Modifier, navController: NavHostController, - searchViewsList: List, + searchViewsList: List, ) { val images = listOf( R.drawable.ic_nav_search, diff --git a/feature/src/main/java/com/terning/feature/search/search/SearchViewModel.kt b/feature/src/main/java/com/terning/feature/search/search/SearchViewModel.kt index d55431d8c..fa528ce90 100644 --- a/feature/src/main/java/com/terning/feature/search/search/SearchViewModel.kt +++ b/feature/src/main/java/com/terning/feature/search/search/SearchViewModel.kt @@ -3,7 +3,7 @@ package com.terning.feature.search.search import androidx.lifecycle.ViewModel import androidx.lifecycle.viewModelScope import com.terning.core.state.UiState -import com.terning.domain.entity.response.SearchViewsResponseModel +import com.terning.domain.entity.response.InternAnnouncementResponseModel import com.terning.domain.repository.SearchViewsRepository import com.terning.feature.R import dagger.hilt.android.lifecycle.HiltViewModel @@ -33,7 +33,7 @@ class SearchViewModel @Inject constructor( viewModelScope.launch { searchViewsRepository.getSearchViewsList().onSuccess { response -> val searchViewsList = response.map { entity -> - SearchViewsResponseModel( + InternAnnouncementResponseModel( title = entity.title, companyImage = entity.companyImage, announcementId = entity.announcementId diff --git a/feature/src/main/java/com/terning/feature/search/search/SearchViewsState.kt b/feature/src/main/java/com/terning/feature/search/search/SearchViewsState.kt index 93e2a9b5a..543a107fe 100644 --- a/feature/src/main/java/com/terning/feature/search/search/SearchViewsState.kt +++ b/feature/src/main/java/com/terning/feature/search/search/SearchViewsState.kt @@ -1,8 +1,8 @@ package com.terning.feature.search.search import com.terning.core.state.UiState -import com.terning.domain.entity.response.SearchViewsResponseModel +import com.terning.domain.entity.response.InternAnnouncementResponseModel data class SearchViewsState( - var searchViewsList: UiState> = UiState.Loading, + var searchViewsList: UiState> = UiState.Loading, ) \ No newline at end of file diff --git a/feature/src/main/java/com/terning/feature/search/search/component/SearchIntern.kt b/feature/src/main/java/com/terning/feature/search/search/component/SearchIntern.kt index f192453f4..44a60c298 100644 --- a/feature/src/main/java/com/terning/feature/search/search/component/SearchIntern.kt +++ b/feature/src/main/java/com/terning/feature/search/search/component/SearchIntern.kt @@ -25,13 +25,13 @@ import com.terning.core.designsystem.theme.Black import com.terning.core.designsystem.theme.TerningTheme import com.terning.core.designsystem.theme.White import com.terning.core.extension.noRippleClickable -import com.terning.domain.entity.response.SearchViewsResponseModel +import com.terning.domain.entity.response.InternAnnouncementResponseModel import com.terning.feature.R import com.terning.feature.intern.navigation.navigateIntern @Composable fun SearchIntern( - searchViews: SearchViewsResponseModel, + searchViews: InternAnnouncementResponseModel, navController: NavHostController, ) { Column( diff --git a/feature/src/main/java/com/terning/feature/search/search/component/SearchInternList.kt b/feature/src/main/java/com/terning/feature/search/search/component/SearchInternList.kt index e76f9f3b0..f8eecdea6 100644 --- a/feature/src/main/java/com/terning/feature/search/search/component/SearchInternList.kt +++ b/feature/src/main/java/com/terning/feature/search/search/component/SearchInternList.kt @@ -12,13 +12,13 @@ import androidx.compose.ui.unit.dp import androidx.navigation.NavHostController import com.terning.core.designsystem.theme.Grey400 import com.terning.core.designsystem.theme.TerningTheme -import com.terning.domain.entity.response.SearchViewsResponseModel +import com.terning.domain.entity.response.InternAnnouncementResponseModel import com.terning.feature.R @Composable fun SearchInternList( type: InternListType, - searchViewsList: List, + searchViewsList: List, navController: NavHostController ) { Column(modifier = Modifier.padding(horizontal = 24.dp)) { From 3375f8d37d46fdd3f1c92f98d6d6dcdceb9e401a Mon Sep 17 00:00:00 2001 From: arinming Date: Tue, 16 Jul 2024 03:40:59 +0900 Subject: [PATCH 10/14] =?UTF-8?q?[RENAME/#79]=20=EA=B3=B5=EA=B3=A0=20?= =?UTF-8?q?=EC=A0=95=EB=B3=B4=20DTO=20=EC=9D=B4=EB=A6=84=20=EB=B3=80?= =?UTF-8?q?=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../data/datasource/SearchViewsDataSource.kt | 4 ++-- .../SearchViewsDataSourceImpl.kt | 12 +++++----- ...sponseDto.kt => SearchViewsResponseDto.kt} | 23 ++++++++++--------- .../SearchViewsRepositoryImpl.kt | 6 ++--- .../com/terning/data/service/SearchService.kt | 12 +++++----- ...seModel.kt => SearchViewsResponseModel.kt} | 2 +- .../repository/SearchViewsRepository.kt | 4 ++-- .../feature/search/search/SearchRoute.kt | 6 ++--- .../feature/search/search/SearchViewModel.kt | 4 ++-- .../feature/search/search/SearchViewsState.kt | 4 ++-- .../search/search/component/SearchIntern.kt | 4 ++-- .../search/component/SearchInternList.kt | 4 ++-- 12 files changed, 43 insertions(+), 42 deletions(-) rename data/src/main/java/com/terning/data/dto/response/{InternAnnouncementResponseDto.kt => SearchViewsResponseDto.kt} (55%) rename domain/src/main/java/com/terning/domain/entity/response/{InternAnnouncementResponseModel.kt => SearchViewsResponseModel.kt} (74%) diff --git a/data/src/main/java/com/terning/data/datasource/SearchViewsDataSource.kt b/data/src/main/java/com/terning/data/datasource/SearchViewsDataSource.kt index 139c5d971..727cf9671 100644 --- a/data/src/main/java/com/terning/data/datasource/SearchViewsDataSource.kt +++ b/data/src/main/java/com/terning/data/datasource/SearchViewsDataSource.kt @@ -1,7 +1,7 @@ package com.terning.data.datasource -import com.terning.data.dto.response.InternAnnouncementResponseDto +import com.terning.data.dto.response.SearchViewsResponseDto interface SearchViewsDataSource { - suspend fun getSearchViews(): InternAnnouncementResponseDto + suspend fun getSearchViews(): SearchViewsResponseDto } \ No newline at end of file diff --git a/data/src/main/java/com/terning/data/datasourceimpl/SearchViewsDataSourceImpl.kt b/data/src/main/java/com/terning/data/datasourceimpl/SearchViewsDataSourceImpl.kt index 26c00e999..ff92130ac 100644 --- a/data/src/main/java/com/terning/data/datasourceimpl/SearchViewsDataSourceImpl.kt +++ b/data/src/main/java/com/terning/data/datasourceimpl/SearchViewsDataSourceImpl.kt @@ -1,25 +1,25 @@ package com.terning.data.datasourceimpl import com.terning.data.datasource.SearchViewsDataSource -import com.terning.data.dto.response.InternAnnouncementResponseDto +import com.terning.data.dto.response.SearchViewsResponseDto import com.terning.data.service.SearchService import javax.inject.Inject class SearchViewsDataSourceImpl @Inject constructor( private val searchService: SearchService ): SearchViewsDataSource { - override suspend fun getSearchViews(): InternAnnouncementResponseDto { - return InternAnnouncementResponseDto( + override suspend fun getSearchViews(): SearchViewsResponseDto { + return SearchViewsResponseDto( status = 200, message = "탐색 > 조회수 많은 공고를 조회하는데 성공했습니다", - result = InternAnnouncementResponseDto.Result( + result = SearchViewsResponseDto.Result( accountments = listOf( - InternAnnouncementResponseDto.InternAnnouncementData( + SearchViewsResponseDto.SearchViewsData( internshipAnnouncementId = 23L, companyImage = "https://image.dongascience.com/Photo/2019/09/d2468576cecf1313437de5a883bfa2ed.jpg", title = "[유한킴벌리]그린캠프 w. 대학생 숲 활동가 모집" ), - InternAnnouncementResponseDto.InternAnnouncementData( + SearchViewsResponseDto.SearchViewsData( internshipAnnouncementId = 3L, companyImage = "https://https://image.dongascience.com/Photo/2019/09/d2468576cecf1313437de5a883bfa2ed.jpg", title = "[Someone] 콘텐츠 마케터 대학생 인턴 채용" diff --git a/data/src/main/java/com/terning/data/dto/response/InternAnnouncementResponseDto.kt b/data/src/main/java/com/terning/data/dto/response/SearchViewsResponseDto.kt similarity index 55% rename from data/src/main/java/com/terning/data/dto/response/InternAnnouncementResponseDto.kt rename to data/src/main/java/com/terning/data/dto/response/SearchViewsResponseDto.kt index 8830fc32d..061070b0f 100644 --- a/data/src/main/java/com/terning/data/dto/response/InternAnnouncementResponseDto.kt +++ b/data/src/main/java/com/terning/data/dto/response/SearchViewsResponseDto.kt @@ -1,11 +1,11 @@ package com.terning.data.dto.response -import com.terning.domain.entity.response.InternAnnouncementResponseModel +import com.terning.domain.entity.response.SearchViewsResponseModel import kotlinx.serialization.SerialName import kotlinx.serialization.Serializable @Serializable -data class InternAnnouncementResponseDto( +data class SearchViewsResponseDto( @SerialName("status") val status: Int, @SerialName("message") @@ -16,11 +16,11 @@ data class InternAnnouncementResponseDto( @Serializable data class Result( @SerialName("accountments") - val accountments: List, + val accountments: List, ) @Serializable - data class InternAnnouncementData( + data class SearchViewsData( @SerialName("internshipAnnouncementId") val internshipAnnouncementId: Long, @SerialName("companyImage") @@ -29,11 +29,12 @@ data class InternAnnouncementResponseDto( val title: String, ) - fun toInternAnnouncementEntity(): List = result.accountments.map { - InternAnnouncementResponseModel( - title = it.title, - companyImage = it.companyImage, - announcementId = it.internshipAnnouncementId - ) - } + fun toSearchViewsEntity(): List = + result.accountments.map { + SearchViewsResponseModel( + title = it.title, + companyImage = it.companyImage, + announcementId = it.internshipAnnouncementId + ) + } } diff --git a/data/src/main/java/com/terning/data/repositoryimpl/SearchViewsRepositoryImpl.kt b/data/src/main/java/com/terning/data/repositoryimpl/SearchViewsRepositoryImpl.kt index 8036b4b79..24110f2bd 100644 --- a/data/src/main/java/com/terning/data/repositoryimpl/SearchViewsRepositoryImpl.kt +++ b/data/src/main/java/com/terning/data/repositoryimpl/SearchViewsRepositoryImpl.kt @@ -1,15 +1,15 @@ package com.terning.data.repositoryimpl import com.terning.data.datasource.SearchViewsDataSource -import com.terning.domain.entity.response.InternAnnouncementResponseModel +import com.terning.domain.entity.response.SearchViewsResponseModel import com.terning.domain.repository.SearchViewsRepository import javax.inject.Inject class SearchViewsRepositoryImpl @Inject constructor( private val searchViewsDataSource: SearchViewsDataSource, ) : SearchViewsRepository { - override suspend fun getSearchViewsList(): Result> = + override suspend fun getSearchViewsList(): Result> = runCatching { - searchViewsDataSource.getSearchViews().toInternAnnouncementEntity() + searchViewsDataSource.getSearchViews().toSearchViewsEntity() } } \ No newline at end of file diff --git a/data/src/main/java/com/terning/data/service/SearchService.kt b/data/src/main/java/com/terning/data/service/SearchService.kt index 2282ac28f..b4a38f501 100644 --- a/data/src/main/java/com/terning/data/service/SearchService.kt +++ b/data/src/main/java/com/terning/data/service/SearchService.kt @@ -1,22 +1,22 @@ package com.terning.data.service -import com.terning.data.dto.response.InternAnnouncementResponseDto +import com.terning.data.dto.response.SearchViewsResponseDto import retrofit2.http.GET interface SearchService { @GET("api/v1/search/views") - suspend fun getSearchViewsList(): InternAnnouncementResponseDto { - return InternAnnouncementResponseDto( + suspend fun getSearchViewsList(): SearchViewsResponseDto { + return SearchViewsResponseDto( status = 200, message = "탐색 > 조회수 많은 공고를 조회하는데 성공했습니다", - result = InternAnnouncementResponseDto.Result( + result = SearchViewsResponseDto.Result( accountments = listOf( - InternAnnouncementResponseDto.InternAnnouncementData( + SearchViewsResponseDto.SearchViewsData( internshipAnnouncementId = 23, companyImage = "https://example.com/image1.jpg", title = "[유한킴벌리]그린캠프 w. 대학생 숲 활동가 모집" ), - InternAnnouncementResponseDto.InternAnnouncementData( + SearchViewsResponseDto.SearchViewsData( internshipAnnouncementId = 3, companyImage = "https://example.com/image2.jpg", title = "[Someone] 콘텐츠 마케터 대학생 인턴 채용" diff --git a/domain/src/main/java/com/terning/domain/entity/response/InternAnnouncementResponseModel.kt b/domain/src/main/java/com/terning/domain/entity/response/SearchViewsResponseModel.kt similarity index 74% rename from domain/src/main/java/com/terning/domain/entity/response/InternAnnouncementResponseModel.kt rename to domain/src/main/java/com/terning/domain/entity/response/SearchViewsResponseModel.kt index f20adf48d..0877ecf4a 100644 --- a/domain/src/main/java/com/terning/domain/entity/response/InternAnnouncementResponseModel.kt +++ b/domain/src/main/java/com/terning/domain/entity/response/SearchViewsResponseModel.kt @@ -1,6 +1,6 @@ package com.terning.domain.entity.response -data class InternAnnouncementResponseModel( +data class SearchViewsResponseModel( val title: String, val companyImage: String, val announcementId: Long, diff --git a/domain/src/main/java/com/terning/domain/repository/SearchViewsRepository.kt b/domain/src/main/java/com/terning/domain/repository/SearchViewsRepository.kt index 0a1d00237..3e64e61a0 100644 --- a/domain/src/main/java/com/terning/domain/repository/SearchViewsRepository.kt +++ b/domain/src/main/java/com/terning/domain/repository/SearchViewsRepository.kt @@ -1,7 +1,7 @@ package com.terning.domain.repository -import com.terning.domain.entity.response.InternAnnouncementResponseModel +import com.terning.domain.entity.response.SearchViewsResponseModel interface SearchViewsRepository { - suspend fun getSearchViewsList(): Result> + suspend fun getSearchViewsList(): Result> } \ No newline at end of file diff --git a/feature/src/main/java/com/terning/feature/search/search/SearchRoute.kt b/feature/src/main/java/com/terning/feature/search/search/SearchRoute.kt index 93c3c5fda..9b3784b25 100644 --- a/feature/src/main/java/com/terning/feature/search/search/SearchRoute.kt +++ b/feature/src/main/java/com/terning/feature/search/search/SearchRoute.kt @@ -27,7 +27,7 @@ import com.terning.core.designsystem.theme.Grey100 import com.terning.core.designsystem.theme.TerningTheme import com.terning.core.extension.noRippleClickable import com.terning.core.state.UiState -import com.terning.domain.entity.response.InternAnnouncementResponseModel +import com.terning.domain.entity.response.SearchViewsResponseModel import com.terning.feature.R import com.terning.feature.search.search.component.ImageSlider import com.terning.feature.search.search.component.InternListType @@ -63,7 +63,7 @@ fun SearchRoute( is UiState.Success -> { SearchScreen( navController = navController, - searchViewsList = (state.searchViewsList as UiState.Success>).data + searchViewsList = (state.searchViewsList as UiState.Success>).data ) } @@ -74,7 +74,7 @@ fun SearchRoute( fun SearchScreen( modifier: Modifier = Modifier, navController: NavHostController, - searchViewsList: List, + searchViewsList: List, ) { val images = listOf( R.drawable.ic_nav_search, diff --git a/feature/src/main/java/com/terning/feature/search/search/SearchViewModel.kt b/feature/src/main/java/com/terning/feature/search/search/SearchViewModel.kt index fa528ce90..d55431d8c 100644 --- a/feature/src/main/java/com/terning/feature/search/search/SearchViewModel.kt +++ b/feature/src/main/java/com/terning/feature/search/search/SearchViewModel.kt @@ -3,7 +3,7 @@ package com.terning.feature.search.search import androidx.lifecycle.ViewModel import androidx.lifecycle.viewModelScope import com.terning.core.state.UiState -import com.terning.domain.entity.response.InternAnnouncementResponseModel +import com.terning.domain.entity.response.SearchViewsResponseModel import com.terning.domain.repository.SearchViewsRepository import com.terning.feature.R import dagger.hilt.android.lifecycle.HiltViewModel @@ -33,7 +33,7 @@ class SearchViewModel @Inject constructor( viewModelScope.launch { searchViewsRepository.getSearchViewsList().onSuccess { response -> val searchViewsList = response.map { entity -> - InternAnnouncementResponseModel( + SearchViewsResponseModel( title = entity.title, companyImage = entity.companyImage, announcementId = entity.announcementId diff --git a/feature/src/main/java/com/terning/feature/search/search/SearchViewsState.kt b/feature/src/main/java/com/terning/feature/search/search/SearchViewsState.kt index 543a107fe..93e2a9b5a 100644 --- a/feature/src/main/java/com/terning/feature/search/search/SearchViewsState.kt +++ b/feature/src/main/java/com/terning/feature/search/search/SearchViewsState.kt @@ -1,8 +1,8 @@ package com.terning.feature.search.search import com.terning.core.state.UiState -import com.terning.domain.entity.response.InternAnnouncementResponseModel +import com.terning.domain.entity.response.SearchViewsResponseModel data class SearchViewsState( - var searchViewsList: UiState> = UiState.Loading, + var searchViewsList: UiState> = UiState.Loading, ) \ No newline at end of file diff --git a/feature/src/main/java/com/terning/feature/search/search/component/SearchIntern.kt b/feature/src/main/java/com/terning/feature/search/search/component/SearchIntern.kt index 44a60c298..f192453f4 100644 --- a/feature/src/main/java/com/terning/feature/search/search/component/SearchIntern.kt +++ b/feature/src/main/java/com/terning/feature/search/search/component/SearchIntern.kt @@ -25,13 +25,13 @@ import com.terning.core.designsystem.theme.Black import com.terning.core.designsystem.theme.TerningTheme import com.terning.core.designsystem.theme.White import com.terning.core.extension.noRippleClickable -import com.terning.domain.entity.response.InternAnnouncementResponseModel +import com.terning.domain.entity.response.SearchViewsResponseModel import com.terning.feature.R import com.terning.feature.intern.navigation.navigateIntern @Composable fun SearchIntern( - searchViews: InternAnnouncementResponseModel, + searchViews: SearchViewsResponseModel, navController: NavHostController, ) { Column( diff --git a/feature/src/main/java/com/terning/feature/search/search/component/SearchInternList.kt b/feature/src/main/java/com/terning/feature/search/search/component/SearchInternList.kt index f8eecdea6..e76f9f3b0 100644 --- a/feature/src/main/java/com/terning/feature/search/search/component/SearchInternList.kt +++ b/feature/src/main/java/com/terning/feature/search/search/component/SearchInternList.kt @@ -12,13 +12,13 @@ import androidx.compose.ui.unit.dp import androidx.navigation.NavHostController import com.terning.core.designsystem.theme.Grey400 import com.terning.core.designsystem.theme.TerningTheme -import com.terning.domain.entity.response.InternAnnouncementResponseModel +import com.terning.domain.entity.response.SearchViewsResponseModel import com.terning.feature.R @Composable fun SearchInternList( type: InternListType, - searchViewsList: List, + searchViewsList: List, navController: NavHostController ) { Column(modifier = Modifier.padding(horizontal = 24.dp)) { From a939cffff6e04ceae7ee596876494aab4008ad16 Mon Sep 17 00:00:00 2001 From: arinming Date: Tue, 16 Jul 2024 04:36:46 +0900 Subject: [PATCH 11/14] =?UTF-8?q?[FEAT/#79]=20=EB=B9=88=20=EA=B2=80?= =?UTF-8?q?=EC=83=89=EC=96=B4=20=EC=9E=85=EB=A0=A5=20=EC=A0=9C=ED=95=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../component/textfield/TerningBasicTextField.kt | 8 +++++--- .../feature/search/search/component/SearchIntern.kt | 3 +++ 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/core/src/main/java/com/terning/core/designsystem/component/textfield/TerningBasicTextField.kt b/core/src/main/java/com/terning/core/designsystem/component/textfield/TerningBasicTextField.kt index 5fcea5394..d9526c2f8 100644 --- a/core/src/main/java/com/terning/core/designsystem/component/textfield/TerningBasicTextField.kt +++ b/core/src/main/java/com/terning/core/designsystem/component/textfield/TerningBasicTextField.kt @@ -68,9 +68,11 @@ fun TerningBasicTextField( keyboardOptions = KeyboardOptions(imeAction = ImeAction.Done), keyboardActions = KeyboardActions( onDone = { - keyboardController?.hide() - focusManager.clearFocus() - onDoneAction?.invoke() + if (value.isNotEmpty() && value.isNotBlank()) { + keyboardController?.hide() + focusManager.clearFocus() + onDoneAction?.invoke() + } } ), diff --git a/feature/src/main/java/com/terning/feature/search/search/component/SearchIntern.kt b/feature/src/main/java/com/terning/feature/search/search/component/SearchIntern.kt index f192453f4..c1265dedd 100644 --- a/feature/src/main/java/com/terning/feature/search/search/component/SearchIntern.kt +++ b/feature/src/main/java/com/terning/feature/search/search/component/SearchIntern.kt @@ -24,6 +24,7 @@ import coil.request.ImageRequest import com.terning.core.designsystem.theme.Black import com.terning.core.designsystem.theme.TerningTheme import com.terning.core.designsystem.theme.White +import com.terning.core.extension.customShadow import com.terning.core.extension.noRippleClickable import com.terning.domain.entity.response.SearchViewsResponseModel import com.terning.feature.R @@ -60,6 +61,7 @@ fun SearchIntern( contentScale = ContentScale.Crop, modifier = Modifier .height(76.dp) + .customShadow(offsetY = 3.dp) .wrapContentSize() .clip( RoundedCornerShape( @@ -68,6 +70,7 @@ fun SearchIntern( ) ) ) + Text( text = "${searchViews.title} ${searchViews.title}${searchViews.title}${searchViews.title}", modifier = Modifier From 08d7b39191687b096657ef6f75c97e0a44009689 Mon Sep 17 00:00:00 2001 From: arinming Date: Tue, 16 Jul 2024 17:44:54 +0900 Subject: [PATCH 12/14] =?UTF-8?q?[REFACTOR/#79]=20BaseResponse=20=EC=88=98?= =?UTF-8?q?=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../data/datasource/SearchViewsDataSource.kt | 3 +- .../SearchViewsDataSourceImpl.kt | 27 +++----------- .../dto/response/SearchViewsResponseDto.kt | 37 ++++++------------- .../SearchViewsRepositoryImpl.kt | 5 ++- .../com/terning/data/service/SearchService.kt | 23 +----------- 5 files changed, 24 insertions(+), 71 deletions(-) diff --git a/data/src/main/java/com/terning/data/datasource/SearchViewsDataSource.kt b/data/src/main/java/com/terning/data/datasource/SearchViewsDataSource.kt index 727cf9671..1eb55bce1 100644 --- a/data/src/main/java/com/terning/data/datasource/SearchViewsDataSource.kt +++ b/data/src/main/java/com/terning/data/datasource/SearchViewsDataSource.kt @@ -1,7 +1,8 @@ package com.terning.data.datasource +import com.terning.data.dto.BaseResponse import com.terning.data.dto.response.SearchViewsResponseDto interface SearchViewsDataSource { - suspend fun getSearchViews(): SearchViewsResponseDto + suspend fun getSearchViews(): BaseResponse } \ No newline at end of file diff --git a/data/src/main/java/com/terning/data/datasourceimpl/SearchViewsDataSourceImpl.kt b/data/src/main/java/com/terning/data/datasourceimpl/SearchViewsDataSourceImpl.kt index ff92130ac..bf82feb99 100644 --- a/data/src/main/java/com/terning/data/datasourceimpl/SearchViewsDataSourceImpl.kt +++ b/data/src/main/java/com/terning/data/datasourceimpl/SearchViewsDataSourceImpl.kt @@ -1,31 +1,14 @@ package com.terning.data.datasourceimpl import com.terning.data.datasource.SearchViewsDataSource +import com.terning.data.dto.BaseResponse import com.terning.data.dto.response.SearchViewsResponseDto import com.terning.data.service.SearchService import javax.inject.Inject class SearchViewsDataSourceImpl @Inject constructor( - private val searchService: SearchService -): SearchViewsDataSource { - override suspend fun getSearchViews(): SearchViewsResponseDto { - return SearchViewsResponseDto( - status = 200, - message = "탐색 > 조회수 많은 공고를 조회하는데 성공했습니다", - result = SearchViewsResponseDto.Result( - accountments = listOf( - SearchViewsResponseDto.SearchViewsData( - internshipAnnouncementId = 23L, - companyImage = "https://image.dongascience.com/Photo/2019/09/d2468576cecf1313437de5a883bfa2ed.jpg", - title = "[유한킴벌리]그린캠프 w. 대학생 숲 활동가 모집" - ), - SearchViewsResponseDto.SearchViewsData( - internshipAnnouncementId = 3L, - companyImage = "https://https://image.dongascience.com/Photo/2019/09/d2468576cecf1313437de5a883bfa2ed.jpg", - title = "[Someone] 콘텐츠 마케터 대학생 인턴 채용" - ) - ) - ) - ) - } + private val searchService: SearchService, +) : SearchViewsDataSource { + override suspend fun getSearchViews(): BaseResponse = + searchService.getSearchViewsList() } \ No newline at end of file diff --git a/data/src/main/java/com/terning/data/dto/response/SearchViewsResponseDto.kt b/data/src/main/java/com/terning/data/dto/response/SearchViewsResponseDto.kt index 061070b0f..f7f00d309 100644 --- a/data/src/main/java/com/terning/data/dto/response/SearchViewsResponseDto.kt +++ b/data/src/main/java/com/terning/data/dto/response/SearchViewsResponseDto.kt @@ -6,35 +6,20 @@ import kotlinx.serialization.Serializable @Serializable data class SearchViewsResponseDto( - @SerialName("status") - val status: Int, - @SerialName("message") - val message: String, - @SerialName("result") - val result: Result, + @SerialName("internshipAnnouncementId") + val internshipAnnouncementId: Long, + @SerialName("companyImage") + val companyImage: String, + @SerialName("title") + val title: String, ) { - @Serializable - data class Result( - @SerialName("accountments") - val accountments: List, - ) - - @Serializable - data class SearchViewsData( - @SerialName("internshipAnnouncementId") - val internshipAnnouncementId: Long, - @SerialName("companyImage") - val companyImage: String, - @SerialName("title") - val title: String, - ) fun toSearchViewsEntity(): List = - result.accountments.map { + listOf( SearchViewsResponseModel( - title = it.title, - companyImage = it.companyImage, - announcementId = it.internshipAnnouncementId + announcementId = internshipAnnouncementId, + companyImage = companyImage, + title = title, ) - } + ) } diff --git a/data/src/main/java/com/terning/data/repositoryimpl/SearchViewsRepositoryImpl.kt b/data/src/main/java/com/terning/data/repositoryimpl/SearchViewsRepositoryImpl.kt index 24110f2bd..162eb6f26 100644 --- a/data/src/main/java/com/terning/data/repositoryimpl/SearchViewsRepositoryImpl.kt +++ b/data/src/main/java/com/terning/data/repositoryimpl/SearchViewsRepositoryImpl.kt @@ -10,6 +10,9 @@ class SearchViewsRepositoryImpl @Inject constructor( ) : SearchViewsRepository { override suspend fun getSearchViewsList(): Result> = runCatching { - searchViewsDataSource.getSearchViews().toSearchViewsEntity() + searchViewsDataSource + .getSearchViews() + .result + .toSearchViewsEntity() } } \ No newline at end of file diff --git a/data/src/main/java/com/terning/data/service/SearchService.kt b/data/src/main/java/com/terning/data/service/SearchService.kt index b4a38f501..e6f3e27d1 100644 --- a/data/src/main/java/com/terning/data/service/SearchService.kt +++ b/data/src/main/java/com/terning/data/service/SearchService.kt @@ -1,29 +1,10 @@ package com.terning.data.service +import com.terning.data.dto.BaseResponse import com.terning.data.dto.response.SearchViewsResponseDto import retrofit2.http.GET interface SearchService { @GET("api/v1/search/views") - suspend fun getSearchViewsList(): SearchViewsResponseDto { - return SearchViewsResponseDto( - status = 200, - message = "탐색 > 조회수 많은 공고를 조회하는데 성공했습니다", - result = SearchViewsResponseDto.Result( - accountments = listOf( - SearchViewsResponseDto.SearchViewsData( - internshipAnnouncementId = 23, - companyImage = "https://example.com/image1.jpg", - title = "[유한킴벌리]그린캠프 w. 대학생 숲 활동가 모집" - ), - SearchViewsResponseDto.SearchViewsData( - internshipAnnouncementId = 3, - companyImage = "https://example.com/image2.jpg", - title = "[Someone] 콘텐츠 마케터 대학생 인턴 채용" - ) - ) - ) - ) - } - + suspend fun getSearchViewsList(): BaseResponse } \ No newline at end of file From afd35a67bf826c730046e6979975764231135b05 Mon Sep 17 00:00:00 2001 From: arinming Date: Tue, 16 Jul 2024 18:47:48 +0900 Subject: [PATCH 13/14] =?UTF-8?q?[REFACTOR/#79]=20=EB=A6=AC=EB=B7=B0?= =?UTF-8?q?=EC=97=90=20=EB=94=B0=EB=A5=B8=20DTO=20=EB=A6=AC=ED=8C=A9?= =?UTF-8?q?=ED=86=A0=EB=A7=81=20=EB=B0=8F=20=EB=8D=B0=EC=9D=B4=ED=84=B0=20?= =?UTF-8?q?=EB=AA=A8=EB=93=88=20=EB=A6=AC=EB=84=A4=EC=9E=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/terning/point/di/DataSourceModule.kt | 8 ++++---- .../java/com/terning/point/di/RepositoryModule.kt | 4 ++-- .../component/textfield/TerningBasicTextField.kt | 6 ++++-- ...archViewsDataSource.kt => SearchDataSource.kt} | 2 +- ...sDataSourceImpl.kt => SearchDataSourceImpl.kt} | 6 +++--- .../data/dto/response/SearchViewsResponseDto.kt | 8 +++++--- .../repositoryimpl/SearchViewsRepositoryImpl.kt | 15 ++++++--------- ...archViewsRepository.kt => SearchRepository.kt} | 2 +- .../terning/feature/search/search/SearchRoute.kt | 4 +++- .../feature/search/search/SearchViewModel.kt | 14 +++----------- 10 files changed, 32 insertions(+), 37 deletions(-) rename data/src/main/java/com/terning/data/datasource/{SearchViewsDataSource.kt => SearchDataSource.kt} (86%) rename data/src/main/java/com/terning/data/datasourceimpl/{SearchViewsDataSourceImpl.kt => SearchDataSourceImpl.kt} (73%) rename domain/src/main/java/com/terning/domain/repository/{SearchViewsRepository.kt => SearchRepository.kt} (84%) diff --git a/app/src/main/java/com/terning/point/di/DataSourceModule.kt b/app/src/main/java/com/terning/point/di/DataSourceModule.kt index 612d0d0ef..96ae882bc 100644 --- a/app/src/main/java/com/terning/point/di/DataSourceModule.kt +++ b/app/src/main/java/com/terning/point/di/DataSourceModule.kt @@ -1,9 +1,9 @@ package com.terning.point.di import com.terning.data.datasource.MockDataSource -import com.terning.data.datasource.SearchViewsDataSource +import com.terning.data.datasource.SearchDataSource import com.terning.data.datasourceimpl.MockDataSourceImpl -import com.terning.data.datasourceimpl.SearchViewsDataSourceImpl +import com.terning.data.datasourceimpl.SearchDataSourceImpl import dagger.Binds import dagger.Module import dagger.hilt.InstallIn @@ -20,6 +20,6 @@ abstract class DataSourceModule { @Binds @Singleton - abstract fun bindSearchViewsDataSource(searchViewsDataSourceImpl: SearchViewsDataSourceImpl): - SearchViewsDataSource + abstract fun bindSearchViewsDataSource(searchViewsDataSourceImpl: SearchDataSourceImpl): + SearchDataSource } \ No newline at end of file diff --git a/app/src/main/java/com/terning/point/di/RepositoryModule.kt b/app/src/main/java/com/terning/point/di/RepositoryModule.kt index c70b1bcd4..7369a65d7 100644 --- a/app/src/main/java/com/terning/point/di/RepositoryModule.kt +++ b/app/src/main/java/com/terning/point/di/RepositoryModule.kt @@ -3,7 +3,7 @@ package com.terning.point.di import com.terning.data.repositoryimpl.MockRepositoryImpl import com.terning.data.repositoryimpl.SearchViewsRepositoryImpl import com.terning.domain.repository.MockRepository -import com.terning.domain.repository.SearchViewsRepository +import com.terning.domain.repository.SearchRepository import dagger.Binds import dagger.Module import dagger.hilt.InstallIn @@ -20,5 +20,5 @@ abstract class RepositoryModule { @Binds @Singleton - abstract fun bindSearchViewsRepository(searchViewsRepositoryImpl: SearchViewsRepositoryImpl): SearchViewsRepository + abstract fun bindSearchViewsRepository(searchViewsRepositoryImpl: SearchViewsRepositoryImpl): SearchRepository } \ No newline at end of file diff --git a/core/src/main/java/com/terning/core/designsystem/component/textfield/TerningBasicTextField.kt b/core/src/main/java/com/terning/core/designsystem/component/textfield/TerningBasicTextField.kt index d9526c2f8..d30599864 100644 --- a/core/src/main/java/com/terning/core/designsystem/component/textfield/TerningBasicTextField.kt +++ b/core/src/main/java/com/terning/core/designsystem/component/textfield/TerningBasicTextField.kt @@ -68,10 +68,12 @@ fun TerningBasicTextField( keyboardOptions = KeyboardOptions(imeAction = ImeAction.Done), keyboardActions = KeyboardActions( onDone = { - if (value.isNotEmpty() && value.isNotBlank()) { + if (value.isNotBlank()) { keyboardController?.hide() focusManager.clearFocus() - onDoneAction?.invoke() + if (onDoneAction != null) { + onDoneAction() + } } } ), diff --git a/data/src/main/java/com/terning/data/datasource/SearchViewsDataSource.kt b/data/src/main/java/com/terning/data/datasource/SearchDataSource.kt similarity index 86% rename from data/src/main/java/com/terning/data/datasource/SearchViewsDataSource.kt rename to data/src/main/java/com/terning/data/datasource/SearchDataSource.kt index 1eb55bce1..cc15b29b6 100644 --- a/data/src/main/java/com/terning/data/datasource/SearchViewsDataSource.kt +++ b/data/src/main/java/com/terning/data/datasource/SearchDataSource.kt @@ -3,6 +3,6 @@ package com.terning.data.datasource import com.terning.data.dto.BaseResponse import com.terning.data.dto.response.SearchViewsResponseDto -interface SearchViewsDataSource { +interface SearchDataSource { suspend fun getSearchViews(): BaseResponse } \ No newline at end of file diff --git a/data/src/main/java/com/terning/data/datasourceimpl/SearchViewsDataSourceImpl.kt b/data/src/main/java/com/terning/data/datasourceimpl/SearchDataSourceImpl.kt similarity index 73% rename from data/src/main/java/com/terning/data/datasourceimpl/SearchViewsDataSourceImpl.kt rename to data/src/main/java/com/terning/data/datasourceimpl/SearchDataSourceImpl.kt index bf82feb99..7a5872e56 100644 --- a/data/src/main/java/com/terning/data/datasourceimpl/SearchViewsDataSourceImpl.kt +++ b/data/src/main/java/com/terning/data/datasourceimpl/SearchDataSourceImpl.kt @@ -1,14 +1,14 @@ package com.terning.data.datasourceimpl -import com.terning.data.datasource.SearchViewsDataSource +import com.terning.data.datasource.SearchDataSource import com.terning.data.dto.BaseResponse import com.terning.data.dto.response.SearchViewsResponseDto import com.terning.data.service.SearchService import javax.inject.Inject -class SearchViewsDataSourceImpl @Inject constructor( +class SearchDataSourceImpl @Inject constructor( private val searchService: SearchService, -) : SearchViewsDataSource { +) : SearchDataSource { override suspend fun getSearchViews(): BaseResponse = searchService.getSearchViewsList() } \ No newline at end of file diff --git a/data/src/main/java/com/terning/data/dto/response/SearchViewsResponseDto.kt b/data/src/main/java/com/terning/data/dto/response/SearchViewsResponseDto.kt index f7f00d309..a01922c7a 100644 --- a/data/src/main/java/com/terning/data/dto/response/SearchViewsResponseDto.kt +++ b/data/src/main/java/com/terning/data/dto/response/SearchViewsResponseDto.kt @@ -14,12 +14,14 @@ data class SearchViewsResponseDto( val title: String, ) { - fun toSearchViewsEntity(): List = - listOf( + + fun toSearchViewsEntity(): List { + return listOf( SearchViewsResponseModel( announcementId = internshipAnnouncementId, companyImage = companyImage, title = title, ) ) -} + } +} \ No newline at end of file diff --git a/data/src/main/java/com/terning/data/repositoryimpl/SearchViewsRepositoryImpl.kt b/data/src/main/java/com/terning/data/repositoryimpl/SearchViewsRepositoryImpl.kt index 162eb6f26..9ae8429c8 100644 --- a/data/src/main/java/com/terning/data/repositoryimpl/SearchViewsRepositoryImpl.kt +++ b/data/src/main/java/com/terning/data/repositoryimpl/SearchViewsRepositoryImpl.kt @@ -1,18 +1,15 @@ package com.terning.data.repositoryimpl -import com.terning.data.datasource.SearchViewsDataSource +import com.terning.data.datasource.SearchDataSource import com.terning.domain.entity.response.SearchViewsResponseModel -import com.terning.domain.repository.SearchViewsRepository +import com.terning.domain.repository.SearchRepository import javax.inject.Inject class SearchViewsRepositoryImpl @Inject constructor( - private val searchViewsDataSource: SearchViewsDataSource, -) : SearchViewsRepository { + private val searchDataSource: SearchDataSource, +) : SearchRepository { override suspend fun getSearchViewsList(): Result> = runCatching { - searchViewsDataSource - .getSearchViews() - .result - .toSearchViewsEntity() + searchDataSource.getSearchViews().result.toSearchViewsEntity() } -} \ No newline at end of file +} diff --git a/domain/src/main/java/com/terning/domain/repository/SearchViewsRepository.kt b/domain/src/main/java/com/terning/domain/repository/SearchRepository.kt similarity index 84% rename from domain/src/main/java/com/terning/domain/repository/SearchViewsRepository.kt rename to domain/src/main/java/com/terning/domain/repository/SearchRepository.kt index 3e64e61a0..5ff6e0e52 100644 --- a/domain/src/main/java/com/terning/domain/repository/SearchViewsRepository.kt +++ b/domain/src/main/java/com/terning/domain/repository/SearchRepository.kt @@ -2,6 +2,6 @@ package com.terning.domain.repository import com.terning.domain.entity.response.SearchViewsResponseModel -interface SearchViewsRepository { +interface SearchRepository { suspend fun getSearchViewsList(): Result> } \ No newline at end of file diff --git a/feature/src/main/java/com/terning/feature/search/search/SearchRoute.kt b/feature/src/main/java/com/terning/feature/search/search/SearchRoute.kt index 9b3784b25..720e58869 100644 --- a/feature/src/main/java/com/terning/feature/search/search/SearchRoute.kt +++ b/feature/src/main/java/com/terning/feature/search/search/SearchRoute.kt @@ -51,7 +51,9 @@ fun SearchRoute( viewModel.sideEffect.flowWithLifecycle(lifecycle = lifecycleOwner.lifecycle) .collect { sideEffect -> when (sideEffect) { - is SearchViewsSideEffect.Toast -> {} + is SearchViewsSideEffect.Toast -> { + sideEffect.message + } } } } diff --git a/feature/src/main/java/com/terning/feature/search/search/SearchViewModel.kt b/feature/src/main/java/com/terning/feature/search/search/SearchViewModel.kt index d55431d8c..f9736104d 100644 --- a/feature/src/main/java/com/terning/feature/search/search/SearchViewModel.kt +++ b/feature/src/main/java/com/terning/feature/search/search/SearchViewModel.kt @@ -4,7 +4,7 @@ import androidx.lifecycle.ViewModel import androidx.lifecycle.viewModelScope import com.terning.core.state.UiState import com.terning.domain.entity.response.SearchViewsResponseModel -import com.terning.domain.repository.SearchViewsRepository +import com.terning.domain.repository.SearchRepository import com.terning.feature.R import dagger.hilt.android.lifecycle.HiltViewModel import kotlinx.coroutines.flow.MutableSharedFlow @@ -17,7 +17,7 @@ import javax.inject.Inject @HiltViewModel class SearchViewModel @Inject constructor( - private val searchViewsRepository: SearchViewsRepository, + private val searchRepository: SearchRepository, ) : ViewModel() { private val _state: MutableStateFlow = MutableStateFlow(SearchViewsState()) val state: StateFlow = _state.asStateFlow() @@ -31,18 +31,10 @@ class SearchViewModel @Inject constructor( fun getSearchViews() { viewModelScope.launch { - searchViewsRepository.getSearchViewsList().onSuccess { response -> - val searchViewsList = response.map { entity -> - SearchViewsResponseModel( - title = entity.title, - companyImage = entity.companyImage, - announcementId = entity.announcementId - ) - } + searchRepository.getSearchViewsList().onSuccess { searchViewsList -> _state.value = _state.value.copy( searchViewsList = UiState.Success(searchViewsList) ) - _sideEffect.emit(SearchViewsSideEffect.Toast(R.string.server_success)) }.onFailure { _sideEffect.emit(SearchViewsSideEffect.Toast(R.string.server_failure)) } From 4d3990d407059dc5c79931b8069a6648cc7bad1b Mon Sep 17 00:00:00 2001 From: arinming Date: Tue, 16 Jul 2024 21:31:36 +0900 Subject: [PATCH 14/14] =?UTF-8?q?[RENAME/#79]=20=EB=A6=AC=EB=B7=B0?= =?UTF-8?q?=EC=97=90=20=EB=94=B0=EB=A5=B8=20=EB=8D=B0=EC=9D=B4=ED=84=B0=20?= =?UTF-8?q?=EB=AA=A8=EB=8D=B8=20=EB=A6=AC=EB=84=A4=EC=9E=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/terning/data/dto/response/SearchViewsResponseDto.kt | 6 +++--- .../data/repositoryimpl/SearchViewsRepositoryImpl.kt | 4 ++-- ...earchViewsResponseModel.kt => InternshipAnnouncement.kt} | 2 +- .../java/com/terning/domain/repository/SearchRepository.kt | 4 ++-- .../java/com/terning/feature/search/search/SearchRoute.kt | 6 +++--- .../com/terning/feature/search/search/SearchViewModel.kt | 1 - .../com/terning/feature/search/search/SearchViewsState.kt | 4 ++-- .../terning/feature/search/search/component/SearchIntern.kt | 4 ++-- .../feature/search/search/component/SearchInternList.kt | 4 ++-- 9 files changed, 17 insertions(+), 18 deletions(-) rename domain/src/main/java/com/terning/domain/entity/response/{SearchViewsResponseModel.kt => InternshipAnnouncement.kt} (77%) diff --git a/data/src/main/java/com/terning/data/dto/response/SearchViewsResponseDto.kt b/data/src/main/java/com/terning/data/dto/response/SearchViewsResponseDto.kt index a01922c7a..1f928b498 100644 --- a/data/src/main/java/com/terning/data/dto/response/SearchViewsResponseDto.kt +++ b/data/src/main/java/com/terning/data/dto/response/SearchViewsResponseDto.kt @@ -1,6 +1,6 @@ package com.terning.data.dto.response -import com.terning.domain.entity.response.SearchViewsResponseModel +import com.terning.domain.entity.response.InternshipAnnouncement import kotlinx.serialization.SerialName import kotlinx.serialization.Serializable @@ -15,9 +15,9 @@ data class SearchViewsResponseDto( ) { - fun toSearchViewsEntity(): List { + fun toSearchViewsEntity(): List { return listOf( - SearchViewsResponseModel( + InternshipAnnouncement( announcementId = internshipAnnouncementId, companyImage = companyImage, title = title, diff --git a/data/src/main/java/com/terning/data/repositoryimpl/SearchViewsRepositoryImpl.kt b/data/src/main/java/com/terning/data/repositoryimpl/SearchViewsRepositoryImpl.kt index 9ae8429c8..3900c1f5e 100644 --- a/data/src/main/java/com/terning/data/repositoryimpl/SearchViewsRepositoryImpl.kt +++ b/data/src/main/java/com/terning/data/repositoryimpl/SearchViewsRepositoryImpl.kt @@ -1,14 +1,14 @@ package com.terning.data.repositoryimpl import com.terning.data.datasource.SearchDataSource -import com.terning.domain.entity.response.SearchViewsResponseModel +import com.terning.domain.entity.response.InternshipAnnouncement import com.terning.domain.repository.SearchRepository import javax.inject.Inject class SearchViewsRepositoryImpl @Inject constructor( private val searchDataSource: SearchDataSource, ) : SearchRepository { - override suspend fun getSearchViewsList(): Result> = + override suspend fun getSearchViewsList(): Result> = runCatching { searchDataSource.getSearchViews().result.toSearchViewsEntity() } diff --git a/domain/src/main/java/com/terning/domain/entity/response/SearchViewsResponseModel.kt b/domain/src/main/java/com/terning/domain/entity/response/InternshipAnnouncement.kt similarity index 77% rename from domain/src/main/java/com/terning/domain/entity/response/SearchViewsResponseModel.kt rename to domain/src/main/java/com/terning/domain/entity/response/InternshipAnnouncement.kt index 0877ecf4a..c090f25a9 100644 --- a/domain/src/main/java/com/terning/domain/entity/response/SearchViewsResponseModel.kt +++ b/domain/src/main/java/com/terning/domain/entity/response/InternshipAnnouncement.kt @@ -1,6 +1,6 @@ package com.terning.domain.entity.response -data class SearchViewsResponseModel( +data class InternshipAnnouncement( val title: String, val companyImage: String, val announcementId: Long, diff --git a/domain/src/main/java/com/terning/domain/repository/SearchRepository.kt b/domain/src/main/java/com/terning/domain/repository/SearchRepository.kt index 5ff6e0e52..c4b83bdb6 100644 --- a/domain/src/main/java/com/terning/domain/repository/SearchRepository.kt +++ b/domain/src/main/java/com/terning/domain/repository/SearchRepository.kt @@ -1,7 +1,7 @@ package com.terning.domain.repository -import com.terning.domain.entity.response.SearchViewsResponseModel +import com.terning.domain.entity.response.InternshipAnnouncement interface SearchRepository { - suspend fun getSearchViewsList(): Result> + suspend fun getSearchViewsList(): Result> } \ No newline at end of file diff --git a/feature/src/main/java/com/terning/feature/search/search/SearchRoute.kt b/feature/src/main/java/com/terning/feature/search/search/SearchRoute.kt index 720e58869..f554ba8eb 100644 --- a/feature/src/main/java/com/terning/feature/search/search/SearchRoute.kt +++ b/feature/src/main/java/com/terning/feature/search/search/SearchRoute.kt @@ -27,7 +27,7 @@ import com.terning.core.designsystem.theme.Grey100 import com.terning.core.designsystem.theme.TerningTheme import com.terning.core.extension.noRippleClickable import com.terning.core.state.UiState -import com.terning.domain.entity.response.SearchViewsResponseModel +import com.terning.domain.entity.response.InternshipAnnouncement import com.terning.feature.R import com.terning.feature.search.search.component.ImageSlider import com.terning.feature.search.search.component.InternListType @@ -65,7 +65,7 @@ fun SearchRoute( is UiState.Success -> { SearchScreen( navController = navController, - searchViewsList = (state.searchViewsList as UiState.Success>).data + searchViewsList = (state.searchViewsList as UiState.Success>).data ) } @@ -76,7 +76,7 @@ fun SearchRoute( fun SearchScreen( modifier: Modifier = Modifier, navController: NavHostController, - searchViewsList: List, + searchViewsList: List, ) { val images = listOf( R.drawable.ic_nav_search, diff --git a/feature/src/main/java/com/terning/feature/search/search/SearchViewModel.kt b/feature/src/main/java/com/terning/feature/search/search/SearchViewModel.kt index f9736104d..d99b6894b 100644 --- a/feature/src/main/java/com/terning/feature/search/search/SearchViewModel.kt +++ b/feature/src/main/java/com/terning/feature/search/search/SearchViewModel.kt @@ -3,7 +3,6 @@ package com.terning.feature.search.search import androidx.lifecycle.ViewModel import androidx.lifecycle.viewModelScope import com.terning.core.state.UiState -import com.terning.domain.entity.response.SearchViewsResponseModel import com.terning.domain.repository.SearchRepository import com.terning.feature.R import dagger.hilt.android.lifecycle.HiltViewModel diff --git a/feature/src/main/java/com/terning/feature/search/search/SearchViewsState.kt b/feature/src/main/java/com/terning/feature/search/search/SearchViewsState.kt index 93e2a9b5a..d9cf41ed8 100644 --- a/feature/src/main/java/com/terning/feature/search/search/SearchViewsState.kt +++ b/feature/src/main/java/com/terning/feature/search/search/SearchViewsState.kt @@ -1,8 +1,8 @@ package com.terning.feature.search.search import com.terning.core.state.UiState -import com.terning.domain.entity.response.SearchViewsResponseModel +import com.terning.domain.entity.response.InternshipAnnouncement data class SearchViewsState( - var searchViewsList: UiState> = UiState.Loading, + var searchViewsList: UiState> = UiState.Loading, ) \ No newline at end of file diff --git a/feature/src/main/java/com/terning/feature/search/search/component/SearchIntern.kt b/feature/src/main/java/com/terning/feature/search/search/component/SearchIntern.kt index c1265dedd..96e1c551a 100644 --- a/feature/src/main/java/com/terning/feature/search/search/component/SearchIntern.kt +++ b/feature/src/main/java/com/terning/feature/search/search/component/SearchIntern.kt @@ -26,13 +26,13 @@ import com.terning.core.designsystem.theme.TerningTheme import com.terning.core.designsystem.theme.White import com.terning.core.extension.customShadow import com.terning.core.extension.noRippleClickable -import com.terning.domain.entity.response.SearchViewsResponseModel +import com.terning.domain.entity.response.InternshipAnnouncement import com.terning.feature.R import com.terning.feature.intern.navigation.navigateIntern @Composable fun SearchIntern( - searchViews: SearchViewsResponseModel, + searchViews: InternshipAnnouncement, navController: NavHostController, ) { Column( diff --git a/feature/src/main/java/com/terning/feature/search/search/component/SearchInternList.kt b/feature/src/main/java/com/terning/feature/search/search/component/SearchInternList.kt index e76f9f3b0..f8abf167e 100644 --- a/feature/src/main/java/com/terning/feature/search/search/component/SearchInternList.kt +++ b/feature/src/main/java/com/terning/feature/search/search/component/SearchInternList.kt @@ -12,13 +12,13 @@ import androidx.compose.ui.unit.dp import androidx.navigation.NavHostController import com.terning.core.designsystem.theme.Grey400 import com.terning.core.designsystem.theme.TerningTheme -import com.terning.domain.entity.response.SearchViewsResponseModel +import com.terning.domain.entity.response.InternshipAnnouncement import com.terning.feature.R @Composable fun SearchInternList( type: InternListType, - searchViewsList: List, + searchViewsList: List, navController: NavHostController ) { Column(modifier = Modifier.padding(horizontal = 24.dp)) {