-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
247 additions
and
3 deletions.
There are no files selected for viewing
17 changes: 17 additions & 0 deletions
17
app/src/main/java/org/android/bbangzip/data/datasource/remote/ExamRemoteDataSource.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package org.android.bbangzip.data.datasource.remote | ||
|
||
import org.android.bbangzip.data.dto.response.ResponseExamNameDto | ||
import org.android.bbangzip.data.service.ExamService | ||
import org.android.bbangzip.data.util.base.BaseResponse | ||
import javax.inject.Inject | ||
|
||
class ExamRemoteDataSource | ||
@Inject | ||
constructor( | ||
private val examService: ExamService, | ||
) { | ||
suspend fun getSubjectDetail( | ||
subjectId: Int, | ||
examName: String, | ||
):BaseResponse<ResponseExamNameDto?> = examService.getSubjectDetail(subjectId = subjectId, examName = examName) | ||
} |
54 changes: 54 additions & 0 deletions
54
app/src/main/java/org/android/bbangzip/data/dto/response/ResponseExamNameDto.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
package org.android.bbangzip.data.dto.response | ||
|
||
|
||
import kotlinx.serialization.SerialName | ||
import kotlinx.serialization.Serializable | ||
import org.android.bbangzip.domain.model.SubjectDetailInfoEntity | ||
import org.android.bbangzip.domain.model.ToDoCardEntity | ||
|
||
@Serializable | ||
data class ResponseExamNameDto( | ||
@SerialName("examDate") | ||
val examDate: String, | ||
@SerialName("examDday") | ||
val examDday: Int, | ||
@SerialName("motivationMessage") | ||
val motivationMessage: String, | ||
@SerialName("studyList") | ||
val studyList: List<StudyInfo> | ||
){ | ||
fun toSubjectDetailInfoEntity() = SubjectDetailInfoEntity( | ||
examDate = examDate, | ||
examDday = examDday, | ||
motivationMessage = motivationMessage, | ||
todoList = studyList.map { it.toToDoCardEntity() } | ||
) | ||
} | ||
|
||
@Serializable | ||
data class StudyInfo( | ||
@SerialName("deadline") | ||
val deadline: String, | ||
@SerialName("finishPage") | ||
val finishPage: Int, | ||
@SerialName("isFinished") | ||
val isFinished: Boolean, | ||
@SerialName("pieceId") | ||
val pieceId: Int, | ||
@SerialName("remainingDays") | ||
val remainingDays: Int, | ||
@SerialName("startPage") | ||
val startPage: Int, | ||
@SerialName("studyContents") | ||
val studyContents: String | ||
){ | ||
fun toToDoCardEntity() = ToDoCardEntity( | ||
deadline = deadline, | ||
finishPage = finishPage, | ||
pieceId = pieceId, | ||
remainingDays = remainingDays, | ||
startPage = startPage, | ||
studyContents = studyContents, | ||
isFinished = isFinished | ||
) | ||
} |
24 changes: 24 additions & 0 deletions
24
app/src/main/java/org/android/bbangzip/data/repositoryImpl/remote/ExamRepositoryImpl.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package org.android.bbangzip.data.repositoryImpl.remote | ||
|
||
import org.android.bbangzip.data.datasource.remote.ExamRemoteDataSource | ||
import org.android.bbangzip.domain.model.SubjectDetailInfoEntity | ||
import org.android.bbangzip.domain.repository.remote.ExamRepository | ||
import javax.inject.Inject | ||
|
||
class ExamRepositoryImpl | ||
@Inject | ||
constructor( | ||
private val examRemoteDataSource: ExamRemoteDataSource, | ||
) : ExamRepository { | ||
override suspend fun getSubjectDetail( | ||
subjectId: Int, | ||
examName: String, | ||
): Result<SubjectDetailInfoEntity> = | ||
runCatching { | ||
val response = examRemoteDataSource.getSubjectDetail(subjectId = subjectId, examName = examName) | ||
|
||
val responseData = response.data ?: throw IllegalStateException(response.message ?: "Null Error") | ||
|
||
responseData.toSubjectDetailInfoEntity() | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
app/src/main/java/org/android/bbangzip/data/service/ExamService.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package org.android.bbangzip.data.service | ||
|
||
import org.android.bbangzip.data.dto.response.ResponseExamNameDto | ||
import org.android.bbangzip.data.util.base.BaseResponse | ||
import retrofit2.http.GET | ||
import retrofit2.http.Path | ||
|
||
interface ExamService { | ||
@GET("/api/v1/exams/{subjectId}/{examName}") | ||
suspend fun getSubjectDetail( | ||
@Path("subjectId") subjectId: Int, | ||
@Path("examName") examName: String, | ||
): BaseResponse<ResponseExamNameDto?> | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 8 additions & 0 deletions
8
app/src/main/java/org/android/bbangzip/domain/model/SubjectDetailInfoEntity.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package org.android.bbangzip.domain.model | ||
|
||
data class SubjectDetailInfoEntity( | ||
val examDate: String, | ||
val examDday: Int, | ||
val motivationMessage: String, | ||
val todoList: List<ToDoCardEntity> | ||
) |
10 changes: 10 additions & 0 deletions
10
app/src/main/java/org/android/bbangzip/domain/repository/remote/ExamRepository.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package org.android.bbangzip.domain.repository.remote | ||
|
||
import org.android.bbangzip.domain.model.SubjectDetailInfoEntity | ||
|
||
interface ExamRepository { | ||
suspend fun getSubjectDetail( | ||
subjectId: Int, | ||
examName: String, | ||
) : Result<SubjectDetailInfoEntity> | ||
} |
13 changes: 13 additions & 0 deletions
13
app/src/main/java/org/android/bbangzip/domain/usecase/GetSubjectDetailUseCase.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package org.android.bbangzip.domain.usecase | ||
|
||
import org.android.bbangzip.domain.model.BadgeDetailEntity | ||
import org.android.bbangzip.domain.model.SubjectDetailInfoEntity | ||
import org.android.bbangzip.domain.repository.remote.ExamRepository | ||
import org.android.bbangzip.domain.repository.remote.MyPageRepository | ||
|
||
class GetSubjectDetailUseCase( | ||
private val examRepository: ExamRepository, | ||
) { | ||
suspend operator fun invoke(subjectId: Int, examName: String): Result<SubjectDetailInfoEntity> = | ||
examRepository.getSubjectDetail(subjectId = subjectId, examName = examName) | ||
} |
13 changes: 13 additions & 0 deletions
13
app/src/main/java/org/android/bbangzip/presentation/model/SubjectDetailInfo.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package org.android.bbangzip.presentation.model | ||
|
||
import android.os.Parcelable | ||
import kotlinx.parcelize.Parcelize | ||
import org.android.bbangzip.presentation.model.card.ToDoCardModel | ||
|
||
@Parcelize | ||
data class SubjectDetailInfo( | ||
val examDate: String, | ||
val examDday: Int, | ||
val motivationMessage: String, | ||
val todoList: List<ToDoCardModel> | ||
): Parcelable |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters