Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ internal data class BookmarkQuestionRequest(
/**
* 문제 북마크 설정 응답이다.
*
* @property isBookmarked 서버에 적용된 북마크 상태
* @property bookmarked 서버에 적용된 북마크 상태
*/
@Serializable
internal data class BookmarkQuestionResponse(
val isBookmarked: Boolean = false,
val bookmarked: Boolean = false,
)
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ internal data class AvailableProjectResponse(
*
* @property projectId 문제가 속한 프로젝트 식별자
* @property projectName 저장소 이름
* @property setId 문제가 속한 학습 세트 식별자
* @property setLabel 세트 라벨
* @property problemNumber 세트 내 문제 번호
* @property questionId 문제 식별자
Expand All @@ -42,6 +43,7 @@ internal data class AvailableProjectResponse(
internal data class BookmarkedQuestionResponse(
val projectId: String,
val projectName: String = "",
val setId: String = "",
val setLabel: String = "",
val problemNumber: Int = 0,
val questionId: String,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ internal data class ProjectListResponse(
* @property techStack 기술 스택
* @property currentSetLabel 다음에 풀 문제가 속한 세트 라벨
* @property currentSetTitle 다음에 풀 문제가 속한 세트 제목
* @property nextProblemId 이어서 풀 문제 식별자
* @property nextSetId 이어서 풀 문제가 속한 학습 세트 식별자
* @property nextQuestionId 이어서 풀 문제 식별자
* @property overallProgressPercent 프로젝트 전체 진행률(%)
*/
@Serializable
Expand All @@ -34,6 +35,7 @@ internal data class ProjectItemResponse(
val techStack: List<String> = emptyList(),
val currentSetLabel: String = "",
val currentSetTitle: String = "",
val nextProblemId: String? = null,
val nextSetId: String? = null,
val nextQuestionId: String? = null,
val overallProgressPercent: Int = 0,
)
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@ internal fun ProjectItemResponse.toDomain(): ProjectSummary =
techStack = techStack,
currentSetLabel = currentSetLabel,
currentSetTitle = currentSetTitle,
nextProblemId = nextProblemId,
nextSetId = nextSetId,
nextQuestionId = nextQuestionId,
overallProgressPercent = overallProgressPercent,
)

Expand Down Expand Up @@ -233,6 +234,7 @@ internal fun BookmarkedQuestionResponse.toDomain(): BookmarkedQuestion =
BookmarkedQuestion(
projectId = projectId,
projectName = projectName,
setId = setId,
setLabel = setLabel,
problemNumber = problemNumber,
questionId = questionId,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ class ProjectRepositoryImpl(
"${questionPath(projectId, questionId)}/bookmark",
BookmarkQuestionRequest(bookmarked),
).requireData("문제 북마크 응답이 올바르지 않습니다.")
.isBookmarked
.bookmarked
}

override suspend fun getBookmarkedQuestions(projectId: String?): Result<BookmarkedQuestions> =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,8 @@ class ProjectRepositoryImplTest {
assertEquals(listOf("react"), page.items.map { it.repositoryName })
assertEquals(listOf("TypeScript", "JavaScript"), page.items.first().techStack)
assertEquals("Set 1", page.items.first().currentSetLabel)
assertEquals("q1", page.items.first().nextProblemId)
assertEquals("s1", page.items.first().nextSetId)
assertEquals("q1", page.items.first().nextQuestionId)
assertEquals(40, page.items.first().overallProgressPercent)
}

Expand Down Expand Up @@ -282,7 +283,7 @@ class ProjectRepositoryImplTest {
/** 북마크 설정이 서버가 적용한 상태를 돌려주는지 검증한다. */
@Test
fun bookmarkQuestion_성공하면_적용된상태를반환한다() {
val networkClient = FakeNetworkClient("""{"success":true,"data":{"isBookmarked":true}}""")
val networkClient = FakeNetworkClient("""{"success":true,"data":{"bookmarked":true}}""")

val bookmarked = runBlocking { ProjectRepositoryImpl(networkClient).bookmarkQuestion("p1", "q1", true) }.getOrThrow()

Expand Down Expand Up @@ -328,7 +329,8 @@ class ProjectRepositoryImplTest {
private const val PROJECT_LIST_RESPONSE =
"""{"success":true,"data":{"items":[{"projectId":"p1","repositoryName":"react",""" +
""""repositoryImageUrl":"https://example.com/a.png","techStack":["TypeScript","JavaScript"],""" +
""""currentSetLabel":"Set 1","currentSetTitle":"라우팅","nextProblemId":"q1","overallProgressPercent":40}],""" +
""""currentSetLabel":"Set 1","currentSetTitle":"라우팅","nextSetId":"s1","nextQuestionId":"q1",""" +
""""overallProgressPercent":40}],""" +
""""hasNext":true}}"""

private const val PROJECT_DETAIL_RESPONSE =
Expand All @@ -353,7 +355,7 @@ class ProjectRepositoryImplTest {

private const val BOOKMARK_LIST_RESPONSE =
"""{"success":true,"data":{"totalCount":1,"availableProjects":[{"projectId":"p1","projectName":"react"}],""" +
""""bookmarks":[{"projectId":"p1","projectName":"react","setLabel":"Set 1","problemNumber":1,""" +
""""bookmarks":[{"projectId":"p1","projectName":"react","setId":"s1","setLabel":"Set 1","problemNumber":1,""" +
""""questionId":"q1","question":"문제1"}]}}"""
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ data class AvailableProject(
*
* @property projectId 문제가 속한 프로젝트 식별자
* @property projectName 저장소 이름
* @property setId 문제가 속한 학습 세트 식별자
* @property setLabel 세트 라벨 (예: `"Set 1"`)
* @property problemNumber 세트 내 문제 번호. 1부터 시작한다
* @property questionId 문제 식별자
Expand All @@ -37,6 +38,7 @@ data class AvailableProject(
data class BookmarkedQuestion(
val projectId: String,
val projectName: String,
val setId: String,
val setLabel: String,
val problemNumber: Int,
val questionId: String,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ data class ProjectPage(
* @property techStack 저장소에서 추출한 기술 스택
* @property currentSetLabel 다음에 풀 문제가 속한 세트 라벨 (예: `"Set 1"`)
* @property currentSetTitle 다음에 풀 문제가 속한 세트 제목
* @property nextProblemId 이어서 풀 문제 식별자. 풀 문제가 없으면 `null`
* @property nextSetId 이어서 풀 문제가 속한 학습 세트 식별자. 풀 문제가 없으면 `null`
* @property nextQuestionId 이어서 풀 문제 식별자. 풀 문제가 없으면 `null`
* @property overallProgressPercent 프로젝트 전체 진행률(%)
*/
data class ProjectSummary(
Expand All @@ -30,7 +31,8 @@ data class ProjectSummary(
val techStack: List<String>,
val currentSetLabel: String,
val currentSetTitle: String,
val nextProblemId: String?,
val nextSetId: String?,
val nextQuestionId: String?,
val overallProgressPercent: Int,
)

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package com.nexters.hytime.gitit.domain.usecase

import com.nexters.hytime.gitit.domain.repository.ProjectRepository

/**
* 문제의 북마크 상태를 서버에 설정한다.
*
* @property repository 프로젝트 정보를 제공하는 도메인 계약
*/
class BookmarkQuestionUseCase(
private val repository: ProjectRepository,
) {
/**
* 북마크 상태를 설정하고 서버에 적용된 값을 받는다.
*
* @param projectId 문제가 속한 프로젝트 식별자
* @param questionId 북마크할 문제 식별자
* @param bookmarked 설정할 북마크 상태
* @return 서버에 적용된 북마크 상태 또는 실패 원인
*/
suspend operator fun invoke(
projectId: String,
questionId: String,
bookmarked: Boolean,
): Result<Boolean> = repository.bookmarkQuestion(projectId, questionId, bookmarked)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package com.nexters.hytime.gitit.domain.usecase

import com.nexters.hytime.gitit.domain.repository.ProjectRepository

/**
* 등록한 프로젝트를 삭제한다.
*
* @property repository 프로젝트 정보를 제공하는 도메인 계약
*/
class DeleteProjectUseCase(
private val repository: ProjectRepository,
) {
/**
* 프로젝트를 서버에서 삭제한다.
*
* @param projectId 삭제할 프로젝트 식별자
* @return 삭제 결과 또는 실패 원인
*/
suspend operator fun invoke(projectId: String): Result<Unit> = repository.deleteProject(projectId)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package com.nexters.hytime.gitit.domain.usecase

import com.nexters.hytime.gitit.domain.model.BookmarkedQuestions
import com.nexters.hytime.gitit.domain.repository.ProjectRepository

/**
* 북마크한 문제 목록을 조회한다.
*
* @property repository 프로젝트 정보를 제공하는 도메인 계약
*/
class GetBookmarkedQuestionsUseCase(
private val repository: ProjectRepository,
) {
/**
* 저장한 문제 화면에 표시할 북마크 목록을 가져온다.
*
* @param projectId 특정 프로젝트로 좁힐 때 사용할 식별자. `null`이면 전체를 조회한다
* @return 조회된 북마크 목록 또는 실패 원인
*/
suspend operator fun invoke(projectId: String? = null): Result<BookmarkedQuestions> = repository.getBookmarkedQuestions(projectId)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package com.nexters.hytime.gitit.domain.usecase

import com.nexters.hytime.gitit.domain.model.LearningSet
import com.nexters.hytime.gitit.domain.repository.ProjectRepository

/**
* 문제 풀이에 필요한 학습 세트를 조회한다.
*
* @property repository 프로젝트 정보를 제공하는 도메인 계약
*/
class GetLearningSetUseCase(
private val repository: ProjectRepository,
) {
/**
* 학습 세트 하나를 문제 목록과 함께 가져온다.
*
* @param projectId 세트가 속한 프로젝트 식별자
* @param setId 조회할 학습 세트 식별자
* @return 조회된 학습 세트 또는 실패 원인
*/
suspend operator fun invoke(
projectId: String,
setId: String,
): Result<LearningSet> = repository.getLearningSet(projectId, setId)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package com.nexters.hytime.gitit.domain.usecase

import com.nexters.hytime.gitit.domain.model.MemberProfile
import com.nexters.hytime.gitit.domain.repository.MemberRepository

/**
* 현재 회원의 프로필과 학습 현황을 조회한다.
*
* @property repository 회원 정보를 제공하는 도메인 계약
*/
class GetMemberProfileUseCase(
private val repository: MemberRepository,
) {
/**
* 마이 화면에 표시할 프로필을 가져온다.
*
* @return 조회된 프로필 또는 실패 원인
*/
suspend operator fun invoke(): Result<MemberProfile> = repository.getMemberProfile()
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package com.nexters.hytime.gitit.domain.usecase

import com.nexters.hytime.gitit.domain.model.ProjectDetail
import com.nexters.hytime.gitit.domain.repository.ProjectRepository

/**
* 프로젝트 상세 정보를 조회한다.
*
* @property repository 프로젝트 정보를 제공하는 도메인 계약
*/
class GetProjectDetailUseCase(
private val repository: ProjectRepository,
) {
/**
* 상세 화면에 표시할 프로젝트 정보를 가져온다.
*
* @param projectId 조회할 프로젝트 식별자
* @return 조회된 상세 정보 또는 실패 원인
*/
suspend operator fun invoke(projectId: String): Result<ProjectDetail> = repository.getProjectDetail(projectId)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package com.nexters.hytime.gitit.domain.usecase

import com.nexters.hytime.gitit.domain.model.ProjectPage
import com.nexters.hytime.gitit.domain.repository.ProjectRepository

/**
* 등록한 프로젝트 목록을 페이지 단위로 조회한다.
*
* @property repository 프로젝트 정보를 제공하는 도메인 계약
*/
class GetProjectsUseCase(
private val repository: ProjectRepository,
) {
/**
* 프로젝트 한 페이지를 가져온다.
*
* @param page 0부터 시작하는 페이지 번호
* @param size 한 페이지에 담을 프로젝트 수
* @return 조회된 페이지 또는 실패 원인
*/
suspend operator fun invoke(
page: Int = ProjectRepository.DEFAULT_PAGE,
size: Int = ProjectRepository.DEFAULT_PAGE_SIZE,
): Result<ProjectPage> = repository.getProjects(page, size)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package com.nexters.hytime.gitit.domain.usecase

import com.nexters.hytime.gitit.domain.model.ChoiceAnswerResult
import com.nexters.hytime.gitit.domain.repository.ProjectRepository

/**
* 4지선다 문제의 답을 제출하고 채점 결과를 받는다.
*
* @property repository 프로젝트 정보를 제공하는 도메인 계약
*/
class SubmitChoiceAnswerUseCase(
private val repository: ProjectRepository,
) {
/**
* 고른 선택지를 서버에 제출한다. 다시 제출하면 이전 답을 덮어쓴다.
*
* @param projectId 문제가 속한 프로젝트 식별자
* @param questionId 답을 낼 문제 식별자
* @param selectedIndex 고른 선택지 번호. 0부터 시작한다
* @return 정답 여부·정답 번호·해설 또는 실패 원인
*/
suspend operator fun invoke(
projectId: String,
questionId: String,
selectedIndex: Int,
): Result<ChoiceAnswerResult> = repository.submitChoiceAnswer(projectId, questionId, selectedIndex)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package com.nexters.hytime.gitit.domain.usecase

import com.nexters.hytime.gitit.domain.model.EssayAnswerResult
import com.nexters.hytime.gitit.domain.repository.ProjectRepository

/**
* 서술형 문제의 답을 제출하고 해설과 자가채점 기준을 받는다.
*
* @property repository 프로젝트 정보를 제공하는 도메인 계약
*/
class SubmitEssayAnswerUseCase(
private val repository: ProjectRepository,
) {
/**
* 작성한 답안을 서버에 제출한다. 다시 제출하면 이전 답을 덮어쓴다.
*
* @param projectId 문제가 속한 프로젝트 식별자
* @param questionId 답을 낼 문제 식별자
* @param text 서술형 답안. 비어 있으면 서버가 거부한다
* @return 해설과 자가채점 기준 또는 실패 원인
*/
suspend operator fun invoke(
projectId: String,
questionId: String,
text: String,
): Result<EssayAnswerResult> = repository.submitEssayAnswer(projectId, questionId, text)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package com.nexters.hytime.gitit.domain.usecase

import com.nexters.hytime.gitit.domain.model.CareerLevel
import com.nexters.hytime.gitit.domain.repository.MemberRepository

/**
* 회원의 개발 수준만 변경한다. 개발 분야에는 영향을 주지 않는다.
*
* @property repository 회원 정보를 제공하는 도메인 계약
*/
class UpdateCareerLevelUseCase(
private val repository: MemberRepository,
) {
/**
* 새로 선택한 개발 수준을 서버에 저장한다.
*
* @param careerLevel 새로 선택한 개발 수준
* @return 변경 결과 또는 실패 원인
*/
suspend operator fun invoke(careerLevel: CareerLevel): Result<Unit> = repository.updateCareerLevel(careerLevel)
}
Loading
Loading