Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/jaino/#67 #68

Merged
merged 22 commits into from
Dec 23, 2023
Merged
Show file tree
Hide file tree
Changes from 18 commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
622c893
[REFACTOR] #65 : SurveyFormDataSource κ΅¬ν˜„ 및 섀문쑰사 ν˜•μ‹ 폼 μ €μž₯ 및 λΆˆλŸ¬μ˜€λŠ” 둜직 λͺ¨λ‘ …
jeongjaino Dec 22, 2023
6b720a2
[REFACTOR] #65 : SurveyFormRepository κ΅¬ν˜„ 및 섀문쑰사 ν˜•μ‹ 폼 μ €μž₯ 및 λΆˆλŸ¬μ˜€λŠ” 둜직 Mig…
jeongjaino Dec 22, 2023
2f5aaed
[CHORE] #65 : managementRepository, surveyRepository -> surveyFormRep…
jeongjaino Dec 22, 2023
e26381a
[CHORE] #65 : surveyForm network model move to survey/form
jeongjaino Dec 22, 2023
2786891
[CHORE] #65 : surveyResponse field answerList to surveyAnswerList
jeongjaino Dec 22, 2023
2a42c2e
[FEATURE] #65 : Survey DTO κ΅¬ν˜„
jeongjaino Dec 22, 2023
826ee5f
[FEATURE] #65 : SurveyDataSource μ„€λ¬Έ 쑰사 응닡 둜직 κ΅¬ν˜„
jeongjaino Dec 22, 2023
7cd3aab
[FEATURE] #65 : SurveyDataRepository μ„€λ¬Έ 쑰사 응닡 λͺ¨λΈ DTO λ³€κ²½ 둜직 κ΅¬ν˜„
jeongjaino Dec 22, 2023
bd8c446
[FEATURE] #65 : μ„€λ¬Έ 응닡 등둝 μœ μŠ€μΌ€μ΄μŠ€ κ΅¬ν˜„
jeongjaino Dec 22, 2023
944ad02
[FEATURE] #65 : μ„€λ¬Έ 확인 ν™”λ©΄ NavArgument 등둝
jeongjaino Dec 22, 2023
cfce195
[FEATURE] #65 : μ„€λ¬Έ 확인 ν™”λ©΄ NavArgument 등둝
jeongjaino Dec 22, 2023
cf67be9
[FEATURE] #65 : κ΄€λ¦¬ν™”λ©΄μ—μ„œ μ„€λ¬Έ 확인 ν™”λ©΄μœΌλ‘œ μ „ν™˜ κ΅¬ν˜„
jeongjaino Dec 22, 2023
a2eb2e9
[CHORE] #65 : μ‚¬μš©ν•˜μ§€ μ•ŠλŠ” 클래슀 μ†Œκ±°
jeongjaino Dec 22, 2023
0b63a55
[FEATURE] #66 : μ œμΆœν•œ 섀문인지 νŒλ‹¨ν•˜λŠ” 둜직 κ΅¬ν˜„
jeongjaino Dec 22, 2023
e1848f3
[FEATURE] #66 : μ œμΆœν•œ 섀문인지 ν™•μΈν•˜λŠ” μœ μŠ€μΌ€μ΄μŠ€ κ΅¬ν˜„
jeongjaino Dec 22, 2023
7ca9e3f
[FEATURE] #66 : 제좜 기둝에 따라, μž‘μ„±ν™”λ©΄μœΌλ‘œ μ „ν™˜ 둜직 κ΅¬ν˜„
jeongjaino Dec 22, 2023
e15c559
[FEATURE] #66 : 제좜 기둝에 따라, μž‘μ„±ν™”λ©΄μœΌλ‘œ μ „ν™˜ 둜직 κ΅¬ν˜„
jeongjaino Dec 22, 2023
964db3e
[FEATURE] #66 : 주관식 응닡이 10κΈ€μž 이상일 경우, λ²„νŠΌμ΄ ν™œμ„±ν™” λ˜λ„λ‘ κ΅¬ν˜„
jeongjaino Dec 22, 2023
f2477ec
[CHORE] #67 : Survey Check Route Object to const val
jeongjaino Dec 23, 2023
9dfc6d6
[STYLE] #67 : 단일문 ν•¨μˆ˜ block to equal둜 λ³€κ²½
jeongjaino Dec 23, 2023
ce29f57
[REFACTOR] #67 : λ‹€μŒ 질문 λ„˜κΈ°λŠ” 둜직 ViewModel to View둜 μ „ν™˜
jeongjaino Dec 23, 2023
690a3d3
[CHORE] #67 : String to LocalDateTime λ³€ν™˜ μœ ν‹Έλ¦¬ν‹° κ΅¬ν˜„
jeongjaino Dec 23, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions app/src/main/java/com/wap/wapp/navigation/WappNavHost.kt
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import com.wap.wapp.feature.auth.signin.navigation.navigateToSignIn
import com.wap.wapp.feature.auth.signin.navigation.signInScreen
import com.wap.wapp.feature.auth.signup.navigation.navigateToSignUp
import com.wap.wapp.feature.auth.signup.navigation.signUpScreen
import com.wap.wapp.feature.management.check.navigation.navigateToSurveyCheck
import com.wap.wapp.feature.management.check.navigation.surveyCheckScreen
import com.wap.wapp.feature.management.navigation.managementScreen
import com.wap.wapp.feature.management.navigation.navigateToManagement
Expand Down Expand Up @@ -61,7 +62,7 @@ fun WappNavHost(
)
noticeScreen()
surveyNavGraph(
navigateToSurvey = navController::navigateToSurvey ,
navigateToSurvey = navController::navigateToSurvey,
navigateToSurveyAnswer = navController::navigateToSurveyAnswer,
)
surveyCheckScreen(
Expand All @@ -77,8 +78,9 @@ fun WappNavHost(
navigateToProfileSetting = { navController.navigateToProfileSetting() },
)
managementScreen(
navigateToSurveyRegistration = { navController.navigateToSurveyRegistration() },
navigateToEventRegistration = { navController.navigateToEventRegistration() },
navigateToSurveyRegistration = navController::navigateToSurveyRegistration,
navigateToEventRegistration = navController::navigateToEventRegistration,
navigateToSurveyCheck = navController::navigateToSurveyCheck,
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import com.wap.wapp.core.data.repository.event.EventRepository
import com.wap.wapp.core.data.repository.event.EventRepositoryImpl
import com.wap.wapp.core.data.repository.management.ManagementRepository
import com.wap.wapp.core.data.repository.management.ManagementRepositoryImpl
import com.wap.wapp.core.data.repository.survey.SurveyFormRepository
import com.wap.wapp.core.data.repository.survey.SurveyFormRepositoryImpl
import com.wap.wapp.core.data.repository.survey.SurveyRepository
import com.wap.wapp.core.data.repository.survey.SurveyRepositoryImpl
import com.wap.wapp.core.data.repository.user.UserRepository
Expand Down Expand Up @@ -35,6 +37,12 @@ abstract class DataModule {
surveyRepositoryImpl: SurveyRepositoryImpl,
): SurveyRepository

@Binds
@Singleton
abstract fun bindsSurveyFormRepository(
surveyFormRepositoryImpl: SurveyFormRepositoryImpl,
): SurveyFormRepository

@Binds
@Singleton
abstract fun bindsEventRepository(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
package com.wap.wapp.core.data.repository.management

import com.wap.wapp.core.model.survey.SurveyForm

interface ManagementRepository {
suspend fun getManager(userId: String): Result<Boolean>

suspend fun postManager(userId: String): Result<Unit>

suspend fun getManagementCode(code: String): Result<Boolean>

suspend fun postSurveyForm(surveyForm: SurveyForm): Result<Unit>
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
package com.wap.wapp.core.data.repository.management

import com.wap.wapp.core.model.survey.SurveyForm
import com.wap.wapp.core.network.model.management.SurveyFormRequest
import com.wap.wapp.core.network.source.management.ManagementDataSource
import java.time.format.DateTimeFormatter
import javax.inject.Inject

class ManagementRepositoryImpl @Inject constructor(
Expand All @@ -20,17 +17,4 @@ class ManagementRepositoryImpl @Inject constructor(
override suspend fun getManagementCode(code: String): Result<Boolean> {
return managementDataSource.getManagementCode(code)
}

override suspend fun postSurveyForm(surveyForm: SurveyForm): Result<Unit> {
return managementDataSource.postSurveyForm(
surveyFormRequest = SurveyFormRequest(
eventId = surveyForm.eventId,
title = surveyForm.title,
content = surveyForm.content,
surveyQuestionList = surveyForm.surveyQuestionList,
deadline = surveyForm.deadline.format(DateTimeFormatter.ISO_LOCAL_DATE_TIME),
),
eventId = surveyForm.eventId,
)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package com.wap.wapp.core.data.repository.survey

import com.wap.wapp.core.model.survey.SurveyForm

interface SurveyFormRepository {
suspend fun getSurveyForm(eventId: Int): Result<SurveyForm>

suspend fun getSurveyFormList(): Result<List<SurveyForm>>

suspend fun postSurveyForm(surveyForm: SurveyForm): Result<Unit>
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package com.wap.wapp.core.data.repository.survey

import com.wap.wapp.core.model.survey.SurveyForm
import com.wap.wapp.core.network.model.survey.form.SurveyFormRequest
import com.wap.wapp.core.network.source.survey.SurveyFormDataSource
import java.time.format.DateTimeFormatter
import javax.inject.Inject

class SurveyFormRepositoryImpl @Inject constructor(
private val surveyFormDataSource: SurveyFormDataSource,
) : SurveyFormRepository {
override suspend fun getSurveyForm(eventId: Int): Result<SurveyForm> {
return surveyFormDataSource.getSurveyForm(eventId).mapCatching { surveyFormResponse ->
surveyFormResponse.toDomain()
}
}

override suspend fun getSurveyFormList(): Result<List<SurveyForm>> {
return surveyFormDataSource.getSurveyFormList().mapCatching { surveyFormResponseList ->
surveyFormResponseList.map { surveyFormResponse ->
surveyFormResponse.toDomain()
}
}
}

override suspend fun postSurveyForm(surveyForm: SurveyForm): Result<Unit> {
return surveyFormDataSource.postSurveyForm(
surveyFormRequest = SurveyFormRequest(
eventId = surveyForm.eventId,
title = surveyForm.title,
content = surveyForm.content,
surveyQuestionList = surveyForm.surveyQuestionList,
deadline = surveyForm.deadline.format(DateTimeFormatter.ISO_LOCAL_DATE_TIME),
),
)
}
}
Original file line number Diff line number Diff line change
@@ -1,14 +1,22 @@
package com.wap.wapp.core.data.repository.survey

import com.wap.wapp.core.model.survey.Survey
import com.wap.wapp.core.model.survey.SurveyForm
import com.wap.wapp.core.model.survey.SurveyAnswer
import java.time.LocalDateTime

interface SurveyRepository {
suspend fun getSurveyList(): Result<List<Survey>>

suspend fun getSurvey(surveyId: String): Result<Survey>

suspend fun getSurveyFormList(): Result<List<SurveyForm>>
suspend fun postSurvey(
eventId: Int,
userId: String,
title: String,
content: String,
surveyAnswerList: List<SurveyAnswer>,
surveyedAt: LocalDateTime,
): Result<Unit>

suspend fun getSurveyForm(eventId: Int): Result<SurveyForm>
suspend fun isSubmittedSurvey(eventId: Int, userId: String): Result<Boolean>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

넀이밍 μ•„μ£Ό μ’‹μ•„μš” !

}
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
package com.wap.wapp.core.data.repository.survey

import com.wap.wapp.core.model.survey.Survey
import com.wap.wapp.core.model.survey.SurveyForm
import com.wap.wapp.core.model.survey.SurveyAnswer
import com.wap.wapp.core.network.source.survey.SurveyDataSource
import com.wap.wapp.core.network.source.user.UserDataSource
import java.time.LocalDateTime
import java.time.format.DateTimeFormatter
import javax.inject.Inject

class SurveyRepositoryImpl @Inject constructor(
Expand Down Expand Up @@ -42,22 +44,30 @@ class SurveyRepositoryImpl @Inject constructor(
}
}

override suspend fun postSurvey(
eventId: Int,
userId: String,
title: String,
content: String,
surveyAnswerList: List<SurveyAnswer>,
surveyedAt: LocalDateTime,
): Result<Unit> {
return surveyDataSource.postSurvey(
eventId = eventId,
userId = userId,
title = title,
content = content,
surveyAnswerList = surveyAnswerList,
surveyedAt = surveyedAt.format(DateTimeFormatter.ISO_LOCAL_DATE_TIME),
)
}

override suspend fun isSubmittedSurvey(eventId: Int, userId: String): Result<Boolean> {
return surveyDataSource.isSubmittedSurvey(eventId, userId)
}

private val noticeNameResponse: Result<String> = Result.success("notice datasource dummy data")

// TODO 도메인 λͺ¨λΈ κ΅¬ν˜„μ„ μœ„ν•œ μ΅μŠ€ν…μ…˜, notice DataSource κ΅¬ν˜„ ν›„ μ†Œκ±°
private fun String.toDomain(): String = this

override suspend fun getSurveyFormList(): Result<List<SurveyForm>> {
return surveyDataSource.getSurveyFormList().mapCatching { surveyFormResponseList ->
surveyFormResponseList.map { surveyFormResponse ->
surveyFormResponse.toDomain()
}
}
}

override suspend fun getSurveyForm(eventId: Int): Result<SurveyForm> {
return surveyDataSource.getSurveyForm(eventId).mapCatching { surveyFormResponse ->
surveyFormResponse.toDomain()
}
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.wap.wapp.core.domain.usecase.management

import com.wap.wapp.core.data.repository.management.ManagementRepository
import com.wap.wapp.core.data.repository.survey.SurveyFormRepository
import com.wap.wapp.core.model.event.Event
import com.wap.wapp.core.model.survey.SurveyForm
import com.wap.wapp.core.model.survey.SurveyQuestion
Expand All @@ -10,7 +10,7 @@ import java.time.LocalTime
import javax.inject.Inject

class RegisterSurveyUseCase @Inject constructor(
private val managementRepository: ManagementRepository,
private val surveyFormRepository: SurveyFormRepository,
) {
suspend operator fun invoke(
event: Event,
Expand All @@ -21,7 +21,7 @@ class RegisterSurveyUseCase @Inject constructor(
deadlineTime: LocalTime,
): Result<Unit> {
return runCatching {
managementRepository.postSurveyForm(
surveyFormRepository.postSurveyForm(
SurveyForm(
eventId = event.eventId,
title = title,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package com.wap.wapp.core.domain.usecase.survey

import com.wap.wapp.core.data.repository.survey.SurveyRepository
import com.wap.wapp.core.data.repository.survey.SurveyFormRepository
import javax.inject.Inject

class GetSurveyFormListUseCase @Inject constructor(
private val surveyRepository: SurveyRepository,
private val surveyFormRepository: SurveyFormRepository,
) {
suspend operator fun invoke() = surveyRepository.getSurveyFormList()
suspend operator fun invoke() = surveyFormRepository.getSurveyFormList()
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package com.wap.wapp.core.domain.usecase.survey

import com.wap.wapp.core.data.repository.survey.SurveyRepository
import com.wap.wapp.core.data.repository.survey.SurveyFormRepository
import javax.inject.Inject

class GetSurveyFormUseCase @Inject constructor(
private val surveyRepository: SurveyRepository,
private val surveyFormRepository: SurveyFormRepository,
) {
suspend operator fun invoke(eventId: Int) = surveyRepository.getSurveyForm(eventId)
suspend operator fun invoke(eventId: Int) = surveyFormRepository.getSurveyForm(eventId)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package com.wap.wapp.core.domain.usecase.survey

import com.wap.wapp.core.data.repository.survey.SurveyRepository
import com.wap.wapp.core.data.repository.user.UserRepository
import javax.inject.Inject

class IsSubmittedSurveyUseCase @Inject constructor(
private val userRepository: UserRepository,
private val surveyRepository: SurveyRepository,
) {
suspend operator fun invoke(eventId: Int): Result<Boolean> {
return runCatching {
val userId = userRepository.getUserId().getOrThrow()

surveyRepository.isSubmittedSurvey(
userId = userId,
eventId = eventId,
).getOrThrow()
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package com.wap.wapp.core.domain.usecase.survey

import com.wap.wapp.core.data.repository.survey.SurveyRepository
import com.wap.wapp.core.data.repository.user.UserRepository
import com.wap.wapp.core.model.survey.SurveyAnswer
import java.time.LocalDateTime
import javax.inject.Inject

class PostSurveyUseCase @Inject constructor(
private val userRepository: UserRepository,
private val surveyRepository: SurveyRepository,
) {
suspend operator fun invoke(
eventId: Int,
title: String,
content: String,
surveyAnswerList: List<SurveyAnswer>,
): Result<Unit> {
return runCatching {
val userId = userRepository.getUserId().getOrThrow()

surveyRepository.postSurvey(
userId = userId,
eventId = eventId,
title = title,
content = content,
surveyAnswerList = surveyAnswerList,
surveyedAt = LocalDateTime.now(),
)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ data class Survey(
val userName: String,
val title: String,
val content: String,
val answerList: List<SurveyAnswer>,
val surveyAnswerList: List<SurveyAnswer>,
val surveyedAt: LocalDateTime,
)
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import com.wap.wapp.core.network.source.management.ManagementDataSource
import com.wap.wapp.core.network.source.management.ManagementDataSourceImpl
import com.wap.wapp.core.network.source.survey.SurveyDataSource
import com.wap.wapp.core.network.source.survey.SurveyDataSourceImpl
import com.wap.wapp.core.network.source.survey.SurveyFormDataSource
import com.wap.wapp.core.network.source.survey.SurveyFormDataSourceImpl
import com.wap.wapp.core.network.source.user.UserDataSource
import com.wap.wapp.core.network.source.user.UserDataSourceImpl
import dagger.Binds
Expand Down Expand Up @@ -36,6 +38,12 @@ abstract class NetworkModule {
surveyDataSourceImpl: SurveyDataSourceImpl,
): SurveyDataSource

@Binds
@Singleton
abstract fun bindsSurveyFormDateSource(
surveyFormDataSourceImpl: SurveyFormDataSourceImpl,
): SurveyFormDataSource

@Binds
@Singleton
abstract fun bindsEventDataSource(
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package com.wap.wapp.core.network.model.survey

import com.wap.wapp.core.model.survey.SurveyAnswer

data class SurveyRequest(
val surveyId: String,
val eventId: Int,
val userId: String,
val title: String,
val content: String,
val surveyAnswerList: List<SurveyAnswer>,
val surveyedAt: String,
)
Loading