-
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
18 changed files
with
344 additions
and
145 deletions.
There are no files selected for viewing
10 changes: 10 additions & 0 deletions
10
app/src/main/java/org/android/bbangzip/data/datasource/remote/SubjectRemoteDataSource.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.data.datasource.remote | ||
|
||
import org.android.bbangzip.data.dto.response.ResponseSubjectFilterDto | ||
import org.android.bbangzip.data.service.SubjectService | ||
import org.android.bbangzip.data.util.base.BaseResponse | ||
import javax.inject.Inject | ||
|
||
class SubjectRemoteDataSource @Inject constructor(private val subjectService: SubjectService) { | ||
suspend fun getSubjectInfo():BaseResponse<ResponseSubjectFilterDto?> = subjectService.getSubjectInfo() | ||
} |
68 changes: 68 additions & 0 deletions
68
app/src/main/java/org/android/bbangzip/data/dto/response/ResponseSubjectFilterDto.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,68 @@ | ||
package org.android.bbangzip.data.dto.response | ||
|
||
|
||
import kotlinx.serialization.SerialName | ||
import kotlinx.serialization.Serializable | ||
import org.android.bbangzip.domain.model.SubjectCardDetailTodoInfoEntity | ||
import org.android.bbangzip.domain.model.SubjectCardInfoEntity | ||
import org.android.bbangzip.domain.model.SubjectInfoEntity | ||
import timber.log.Timber | ||
|
||
@Serializable | ||
data class ResponseSubjectFilterDto( | ||
@SerialName("semester") | ||
val semester: String, | ||
@SerialName("subjectList") | ||
val subjectList: List<SubjectListInfo>, | ||
@SerialName("year") | ||
val year: Int | ||
) { | ||
fun toSubjectInfoEntity() = | ||
SubjectInfoEntity( | ||
semester = semester, | ||
subjectList = subjectList.map { it.toSubjectCardInfoEntity() }, | ||
year = year | ||
) | ||
} | ||
|
||
@Serializable | ||
data class SubjectListInfo( | ||
@SerialName("studyList") | ||
val studyList: List<SubjectStudyInfo>, | ||
@SerialName("subjectId") | ||
val subjectId: Int, | ||
@SerialName("subjectName") | ||
val subjectName: String | ||
) { | ||
fun toSubjectCardInfoEntity() = | ||
SubjectCardInfoEntity( | ||
subjectId = subjectId, | ||
subjectName = subjectName, | ||
studyList = studyList.filter { data -> | ||
data.examDday < 0 | ||
}.map { | ||
it.toSubjectCardDetailTodoInfoEntity() | ||
} | ||
) | ||
} | ||
|
||
|
||
@Serializable | ||
data class SubjectStudyInfo( | ||
@SerialName("examDDay") | ||
val examDday: Int, | ||
@SerialName("examName") | ||
val examName: String, | ||
@SerialName("pendingCount") | ||
val pendingCount: Int, | ||
@SerialName("remainingCount") | ||
val remainingCount: Int | ||
) { | ||
fun toSubjectCardDetailTodoInfoEntity() = | ||
SubjectCardDetailTodoInfoEntity( | ||
examDday = examDday, | ||
examName = examName, | ||
pendingCount = pendingCount, | ||
remainingCount = remainingCount | ||
) | ||
} |
24 changes: 24 additions & 0 deletions
24
app/src/main/java/org/android/bbangzip/data/repositoryImpl/remote/SubjectRepositoryImpl.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.data.datasource.remote.SubjectRemoteDataSource | ||
import org.android.bbangzip.domain.model.SubjectInfoEntity | ||
import org.android.bbangzip.domain.repository.remote.ExamRepository | ||
import org.android.bbangzip.domain.repository.remote.SubjectRepository | ||
import javax.inject.Inject | ||
|
||
class SubjectRepositoryImpl | ||
@Inject | ||
constructor( | ||
private val subjectRemoteDataSource: SubjectRemoteDataSource, | ||
) : SubjectRepository { | ||
override suspend fun getSubjectInfo(): Result<SubjectInfoEntity> = | ||
runCatching { | ||
val response = subjectRemoteDataSource.getSubjectInfo() | ||
|
||
val responseData = response.data ?: throw IllegalStateException(response.message ?: "Null Error") | ||
|
||
responseData.toSubjectInfoEntity() | ||
} | ||
|
||
} |
11 changes: 11 additions & 0 deletions
11
app/src/main/java/org/android/bbangzip/data/service/SubjectService.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,11 @@ | ||
package org.android.bbangzip.data.service | ||
|
||
import org.android.bbangzip.data.dto.response.ResponseSubjectFilterDto | ||
import org.android.bbangzip.data.util.base.BaseResponse | ||
import retrofit2.http.GET | ||
import retrofit2.http.Path | ||
|
||
interface SubjectService { | ||
@GET("/api/v1/subjects/filter?year=2025&semester=1학기") | ||
suspend fun getSubjectInfo() : BaseResponse<ResponseSubjectFilterDto?> | ||
} |
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
21 changes: 21 additions & 0 deletions
21
app/src/main/java/org/android/bbangzip/domain/model/SubjectInfoEntity.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,21 @@ | ||
package org.android.bbangzip.domain.model | ||
|
||
data class SubjectInfoEntity( | ||
val semester: String, | ||
val subjectList: List<SubjectCardInfoEntity>, | ||
val year: Int | ||
) | ||
|
||
data class SubjectCardInfoEntity( | ||
val studyList: List<SubjectCardDetailTodoInfoEntity?>, | ||
val subjectId: Int, | ||
val subjectName: String | ||
) | ||
|
||
data class SubjectCardDetailTodoInfoEntity( | ||
val examDday: Int, | ||
val examName: String?, | ||
val pendingCount: Int, | ||
val remainingCount: Int | ||
) | ||
|
9 changes: 9 additions & 0 deletions
9
app/src/main/java/org/android/bbangzip/domain/repository/remote/SubjectRepository.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,9 @@ | ||
package org.android.bbangzip.domain.repository.remote | ||
|
||
import org.android.bbangzip.data.dto.response.ResponseSubjectFilterDto | ||
import org.android.bbangzip.data.util.base.BaseResponse | ||
import org.android.bbangzip.domain.model.SubjectInfoEntity | ||
|
||
interface SubjectRepository { | ||
suspend fun getSubjectInfo(): Result<SubjectInfoEntity> | ||
} |
11 changes: 11 additions & 0 deletions
11
app/src/main/java/org/android/bbangzip/domain/usecase/GetSubjectInfoUseCase.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,11 @@ | ||
package org.android.bbangzip.domain.usecase | ||
|
||
import org.android.bbangzip.domain.model.SubjectInfoEntity | ||
import org.android.bbangzip.domain.repository.remote.SubjectRepository | ||
|
||
class GetSubjectInfoUseCase( | ||
private val subjectRepository: SubjectRepository, | ||
) { | ||
suspend operator fun invoke(): Result<SubjectInfoEntity> = | ||
subjectRepository.getSubjectInfo() | ||
} |
9 changes: 9 additions & 0 deletions
9
app/src/main/java/org/android/bbangzip/presentation/model/SubjectInfo.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,9 @@ | ||
package org.android.bbangzip.presentation.model | ||
|
||
import org.android.bbangzip.presentation.model.card.SubjectCardModel | ||
|
||
data class SubjectInfo( | ||
val semester: String, | ||
val subjectList: List<SubjectCardModel>, | ||
val year: Int | ||
) |
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
Oops, something went wrong.