Skip to content

Commit

Permalink
[MERGE] #94 -> develop
Browse files Browse the repository at this point in the history
[FEAT/#94] 필터링 λ·° / μ„œλ²„ν†΅μ‹  κ΅¬ν˜„
  • Loading branch information
leeeyubin authored Jul 17, 2024
2 parents 76334ae + 68059c3 commit fbc6293
Show file tree
Hide file tree
Showing 36 changed files with 395 additions and 106 deletions.
6 changes: 4 additions & 2 deletions app/src/main/java/com/terning/point/di/AuthInterceptor.kt
Original file line number Diff line number Diff line change
Expand Up @@ -77,13 +77,15 @@ class AuthInterceptor @Inject constructor(
}

private fun Request.Builder.newAuthBuilder() =
this.addHeader(AUTHORIZATION, "$BEARER ${terningDataStore.accessToken}")
this.addHeader(
AUTHORIZATION, "$BEARER "
//+ "$TEMP_TOKEN"
)

companion object {
private const val CODE_TOKEN_EXPIRED = 401
private const val TOKEN_EXPIRED_ERROR = "토큰이 λ§Œλ£Œλ˜μ—ˆμ–΄μš”\nλ‹€μ‹œ 둜그인 ν•΄μ£Όμ„Έμš”"
private const val BEARER = "Bearer"
private const val AUTHORIZATION = "Authorization"
}

}
10 changes: 8 additions & 2 deletions app/src/main/java/com/terning/point/di/DataSourceModule.kt
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
package com.terning.point.di

import com.terning.data.datasource.AuthDataSource
import com.terning.data.datasource.CalendarDataSource
import com.terning.data.datasource.FilteringDataSource
import com.terning.data.datasource.SearchDataSource
import com.terning.data.datasource.TokenReissueDataSource
import com.terning.data.datasourceimpl.AuthDataSourceImpl
import com.terning.data.datasourceimpl.SearchDataSourceImpl
import com.terning.data.datasource.CalendarDataSource
import com.terning.data.datasourceimpl.CalendarDataSourceImpl
import com.terning.data.datasourceimpl.FilteringDataSourceImpl
import com.terning.data.datasourceimpl.SearchDataSourceImpl
import com.terning.data.datasourceimpl.TokenReissueDataSourceImpl
import dagger.Binds
import dagger.Module
Expand Down Expand Up @@ -34,4 +36,8 @@ abstract class DataSourceModule {
@Binds
@Singleton
abstract fun bindTokenReissueDataSource(tokenReissueDataSourceImpl: TokenReissueDataSourceImpl): TokenReissueDataSource

@Binds
@Singleton
abstract fun bindFilteringDataSource(filteringDataSourceImpl: FilteringDataSourceImpl): FilteringDataSource
}
1 change: 1 addition & 0 deletions app/src/main/java/com/terning/point/di/DataStoreModule.kt
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,5 @@ object DataStoreModule {
@Singleton
fun provideTerningDataStore(dataStoreImpl: TerningDataStoreImpl): TerningDataStore =
dataStoreImpl

}
8 changes: 7 additions & 1 deletion app/src/main/java/com/terning/point/di/RepositoryModule.kt
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
package com.terning.point.di

import com.terning.data.repositoryimpl.AuthRepositoryImpl
import com.terning.data.repositoryimpl.SearchRepositoryImpl
import com.terning.data.repositoryimpl.CalendarRepositoryImpl
import com.terning.data.repositoryimpl.FilteringRepositoryImpl
import com.terning.data.repositoryimpl.SearchRepositoryImpl
import com.terning.data.repositoryimpl.TokenReissueRepositoryImpl
import com.terning.data.repositoryimpl.TokenRepositoryImpl
import com.terning.domain.repository.AuthRepository
import com.terning.domain.repository.CalendarRepository
import com.terning.domain.repository.FilteringRepository
import com.terning.domain.repository.SearchRepository
import com.terning.domain.repository.TokenReissueRepository
import com.terning.domain.repository.TokenRepository
Expand Down Expand Up @@ -39,4 +41,8 @@ abstract class RepositoryModule {
@Binds
@Singleton
abstract fun bindTokenReissueRepository(tokenReissueRepositoryImpl: TokenReissueRepositoryImpl): TokenReissueRepository

@Binds
@Singleton
abstract fun bindFilteringRepository(filteringRepositoryImpl: FilteringRepositoryImpl): FilteringRepository
}
6 changes: 6 additions & 0 deletions app/src/main/java/com/terning/point/di/ServiceModule.kt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.terning.point.di

import com.terning.data.service.AuthService
import com.terning.data.service.FilteringService
import com.terning.data.service.CalendarService
import com.terning.data.service.SearchService
import com.terning.data.service.TokenReissueService
Expand Down Expand Up @@ -37,4 +38,9 @@ object ServiceModule {
@Singleton
fun provideTokenReissueService(@REISSUE retrofit: Retrofit): TokenReissueService =
retrofit.create(TokenReissueService::class.java)

@Provides
@Singleton
fun provideFilteringService(@JWT retrofit: Retrofit): FilteringService =
retrofit.create(FilteringService::class.java)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package com.terning.data.datasource

import com.terning.data.dto.NonDataBaseResponse
import com.terning.data.dto.request.FilteringRequestDto

interface FilteringDataSource {
suspend fun postFiltering(userId: Long, request: FilteringRequestDto): NonDataBaseResponse
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package com.terning.data.datasourceimpl

import com.terning.data.datasource.FilteringDataSource
import com.terning.data.dto.NonDataBaseResponse
import com.terning.data.dto.request.FilteringRequestDto
import com.terning.data.service.FilteringService
import javax.inject.Inject

class FilteringDataSourceImpl @Inject constructor(
private val filteringService: FilteringService
) : FilteringDataSource {
override suspend fun postFiltering(
userId: Long,
request: FilteringRequestDto
): NonDataBaseResponse =
filteringService.postFilteringService(userId, request)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package com.terning.data.dto.request

import com.terning.domain.entity.request.FilteringRequestModel
import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable

@Serializable
data class FilteringRequestDto(
@SerialName("grade")
val grade: Int,
@SerialName("workingPeriod")
val workingPeriod: Int,
@SerialName("startYear")
val startYear: Int,
@SerialName("startMonth")
val startMonth: Int
)

fun FilteringRequestModel.toFilteringRequestDto(): FilteringRequestDto =
FilteringRequestDto(
grade = grade,
workingPeriod = workingPeriod,
startYear = startYear,
startMonth = startMonth
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package com.terning.data.repositoryimpl

import com.terning.data.datasource.FilteringDataSource
import com.terning.data.dto.request.toFilteringRequestDto
import com.terning.domain.entity.request.FilteringRequestModel
import com.terning.domain.repository.FilteringRepository
import javax.inject.Inject

class FilteringRepositoryImpl @Inject constructor(
private val filteringDataSource: FilteringDataSource
) : FilteringRepository {
override suspend fun postFiltering(
userId: Long,
request: FilteringRequestModel
): Result<Unit> =
runCatching {
filteringDataSource.postFiltering(
userId,
request.toFilteringRequestDto()
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ class TokenRepositoryImpl @Inject constructor(
terningDataStore.userId = userId
}

override fun getUserId(): Long = terningDataStore.userId

override fun clearInfo() {
terningDataStore.clearInfo()
}
Expand Down
15 changes: 15 additions & 0 deletions data/src/main/java/com/terning/data/service/FilteringService.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package com.terning.data.service

import com.terning.data.dto.NonDataBaseResponse
import com.terning.data.dto.request.FilteringRequestDto
import retrofit2.http.Body
import retrofit2.http.Header
import retrofit2.http.POST

interface FilteringService {
@POST("/api/v1/auth/sign-up/filter")
suspend fun postFilteringService(
@Header("User-Id") userId: Long,
@Body request: FilteringRequestDto
): NonDataBaseResponse
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package com.terning.domain.entity.request

data class FilteringRequestModel(
val grade: Int,
val workingPeriod: Int,
val startYear: Int,
val startMonth: Int
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package com.terning.domain.repository

import com.terning.domain.entity.request.FilteringRequestModel

interface FilteringRepository {
suspend fun postFiltering(
userId: Long,
request: FilteringRequestModel
): Result<Unit>
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,7 @@ interface TokenRepository {

fun setUserId(userId: Long)

fun getUserId() : Long

fun clearInfo()
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.terning.feature.onboarding.filtering
package com.terning.feature.filtering.filtering

import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Spacer
Expand All @@ -7,8 +7,11 @@ import androidx.compose.foundation.layout.padding
import androidx.compose.material3.Scaffold
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableIntStateOf
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.ui.Modifier
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.unit.dp
Expand All @@ -19,18 +22,21 @@ import com.terning.core.designsystem.component.image.TerningImage
import com.terning.core.designsystem.component.topappbar.BackButtonTopAppBar
import com.terning.core.designsystem.theme.TerningTheme
import com.terning.feature.R
import com.terning.feature.onboarding.filtering.component.StatusOneRadioGroup
import com.terning.feature.onboarding.filtering.navigation.navigateFilteringTwo
import com.terning.feature.filtering.filtering.component.StatusOneRadioGroup
import com.terning.feature.filtering.filtering.navigation.navigateFilteringTwo

@Composable
fun FilteringOneScreen(
name: String,
navController: NavController,
modifier: Modifier = Modifier,
filteringViewModel: FilteringViewModel = hiltViewModel(),
onButtonClick: () -> Unit = {},
viewModel: FilteringViewModel = hiltViewModel(),
onButtonClick: (Int) -> Unit = {},
) {
val isButtonValid = remember { mutableStateOf(false) }

var grade by remember { mutableIntStateOf(-1) }

Scaffold(
modifier = modifier,
topBar = {
Expand All @@ -54,7 +60,7 @@ fun FilteringOneScreen(
Text(
text = stringResource(
id = R.string.filtering_status1_title,
filteringViewModel.name
name
),
style = TerningTheme.typography.title3,
modifier = modifier.padding(
Expand All @@ -63,7 +69,10 @@ fun FilteringOneScreen(
)
)
Text(
text = stringResource(id = R.string.filtering_status1_sub, filteringViewModel.name),
text = stringResource(
id = R.string.filtering_status1_sub,
name
),
style = TerningTheme.typography.body5,
modifier = modifier.padding(
top = 3.dp,
Expand All @@ -72,9 +81,10 @@ fun FilteringOneScreen(
)
)
StatusOneRadioGroup(
onButtonClick = {
onButtonClick()
onButtonClick = { index ->
onButtonClick(index)
isButtonValid.value = true
grade = index
}
)
Text(
Expand All @@ -90,7 +100,7 @@ fun FilteringOneScreen(
style = TerningTheme.typography.button0,
paddingVertical = 20.dp,
text = R.string.filtering_button,
onButtonClick = { navController.navigateFilteringTwo() },
onButtonClick = { navController.navigateFilteringTwo(grade) },
modifier = modifier.padding(bottom = 12.dp),
isEnabled = isButtonValid.value
)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package com.terning.feature.filtering.filtering

import androidx.annotation.StringRes

sealed class FilteringSideEffect {
data object NavigateToStartHome : FilteringSideEffect()
data class ShowToast(@StringRes val message: Int) : FilteringSideEffect()
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package com.terning.feature.filtering.filtering

data class FilteringState(
val grade: Int = -1,
val workingPeriod: Int = -1,
val startYear: Int = -1,
val startMonth: Int = -1
)
Loading

0 comments on commit fbc6293

Please sign in to comment.