-
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
12 changed files
with
520 additions
and
255 deletions.
There are no files selected for viewing
23 changes: 23 additions & 0 deletions
23
app/src/main/java/org/android/bbangzip/data/datasource/remote/TodayOrdersRemoteDataSource.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,23 @@ | ||
package org.android.bbangzip.data.datasource.remote | ||
|
||
import org.android.bbangzip.data.dto.response.ResponseTodayOrdersDto | ||
import org.android.bbangzip.data.service.PieceService | ||
import org.android.bbangzip.data.util.base.BaseResponse | ||
import javax.inject.Inject | ||
|
||
class TodayOrdersRemoteDataSource @Inject | ||
constructor( | ||
private val pieceService: PieceService, | ||
) { | ||
suspend fun getTodoInfo( | ||
area: String, | ||
year: Int, | ||
semester: String, | ||
sortOption: String | ||
): BaseResponse<ResponseTodayOrdersDto> = pieceService.getTodoInfo( | ||
area = area, | ||
year = year, | ||
semester = semester, | ||
sortOption = sortOption | ||
) | ||
} |
16 changes: 16 additions & 0 deletions
16
app/src/main/java/org/android/bbangzip/data/dto/request/RequestTodayOrdersDto.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,16 @@ | ||
package org.android.bbangzip.data.dto.request | ||
|
||
import kotlinx.serialization.SerialName | ||
import kotlinx.serialization.Serializable | ||
|
||
@Serializable | ||
data class RequestTodayOrdersDto( | ||
@SerialName("area") | ||
val area: String, | ||
@SerialName("year") | ||
val year: Int, | ||
@SerialName("semester") | ||
val semester: String, | ||
@SerialName("sortOption") | ||
val sortOption: String, | ||
) |
65 changes: 65 additions & 0 deletions
65
app/src/main/java/org/android/bbangzip/data/dto/response/ResponseTodayOrdersDto.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,65 @@ | ||
package org.android.bbangzip.data.dto.response | ||
|
||
|
||
import kotlinx.serialization.SerialName | ||
import kotlinx.serialization.Serializable | ||
import org.android.bbangzip.domain.model.ToDoCardEntity | ||
import org.android.bbangzip.domain.model.ToDoInfoEntity | ||
|
||
@Serializable | ||
data class ResponseTodayOrdersDto( | ||
@SerialName("completeCount") | ||
val completeCount: Int, | ||
@SerialName("todoPieceStoList") | ||
val todayList: List<TodoInfo>, | ||
@SerialName("pendingCount") | ||
val pendingCount: Int, | ||
@SerialName("toadyCount") | ||
val todayCount: Int, | ||
) { | ||
fun toTodoInfoEntity() = | ||
ToDoInfoEntity( | ||
todoList = todayList.map { todoItem -> | ||
todoItem.toTodoCardEntity() | ||
}, | ||
pendingCount = pendingCount, | ||
remainingStudyCount = todayCount, | ||
completeCount = completeCount | ||
) | ||
} | ||
|
||
|
||
@Serializable | ||
data class TodoInfo( | ||
@SerialName("deadline") | ||
val deadline: String, | ||
@SerialName("examName") | ||
val examName: 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, | ||
@SerialName("subjectName") | ||
val subjectName: String | ||
) { | ||
fun toTodoCardEntity() = | ||
ToDoCardEntity( | ||
pieceId = pieceId, | ||
subjectName = subjectName, | ||
examName = examName, | ||
studyContents = studyContents, | ||
startPage = startPage, | ||
finishPage = finishPage, | ||
deadline = deadline, | ||
remainingDays = remainingDays, | ||
isFinished = isFinished | ||
) | ||
} |
30 changes: 30 additions & 0 deletions
30
app/src/main/java/org/android/bbangzip/data/repositoryImpl/PieceRepositoryImpl.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,30 @@ | ||
package org.android.bbangzip.data.repositoryImpl | ||
|
||
import org.android.bbangzip.data.datasource.remote.TodayOrdersRemoteDataSource | ||
import org.android.bbangzip.data.dto.request.RequestTodayOrdersDto | ||
import org.android.bbangzip.domain.model.ToDoInfoEntity | ||
import org.android.bbangzip.domain.repository.remote.PieceRepository | ||
import javax.inject.Inject | ||
|
||
class PieceRepositoryImpl | ||
@Inject | ||
constructor( | ||
private val todayOrdersRemoteDateSource: TodayOrdersRemoteDataSource, | ||
) : PieceRepository { | ||
override suspend fun getTodoInfo( | ||
area: String, | ||
year: Int, | ||
semester: String, | ||
sortOption: String | ||
): Result<ToDoInfoEntity> = | ||
runCatching { | ||
todayOrdersRemoteDateSource.getTodoInfo( | ||
area = area, | ||
year = year, | ||
semester = semester, | ||
sortOption = sortOption | ||
).data.toTodoInfoEntity() | ||
} | ||
|
||
} | ||
|
18 changes: 18 additions & 0 deletions
18
app/src/main/java/org/android/bbangzip/data/service/PieceService.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,18 @@ | ||
package org.android.bbangzip.data.service | ||
|
||
import org.android.bbangzip.data.dto.request.RequestTodayOrdersDto | ||
import org.android.bbangzip.data.dto.response.ResponseTodayOrdersDto | ||
import org.android.bbangzip.data.util.base.BaseResponse | ||
import retrofit2.http.Body | ||
import retrofit2.http.GET | ||
import retrofit2.http.Query | ||
|
||
interface PieceService { | ||
@GET("/api/v1/pieces/today/orders") | ||
suspend fun getTodoInfo( | ||
@Query("area") area: String, | ||
@Query("year") year: Int, | ||
@Query("semester") semester: String, | ||
@Query("sortOption") sortOption: String | ||
): BaseResponse<ResponseTodayOrdersDto> | ||
} |
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
14 changes: 14 additions & 0 deletions
14
app/src/main/java/org/android/bbangzip/domain/repository/remote/PieceRepository.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.domain.repository.remote | ||
|
||
import org.android.bbangzip.data.dto.request.RequestTodayOrdersDto | ||
import org.android.bbangzip.domain.model.ToDoInfoEntity | ||
|
||
interface PieceRepository { | ||
suspend fun getTodoInfo( | ||
area: String, | ||
year: Int, | ||
semester: String, | ||
sortOption: String | ||
): Result<ToDoInfoEntity> | ||
} | ||
|
21 changes: 21 additions & 0 deletions
21
app/src/main/java/org/android/bbangzip/domain/usecase/FetchToInfoUseCase.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.usecase | ||
|
||
import org.android.bbangzip.domain.model.ToDoInfoEntity | ||
import org.android.bbangzip.domain.repository.remote.PieceRepository | ||
|
||
class GetToInfoUseCase( | ||
private val pieceRepository: PieceRepository | ||
) { | ||
suspend operator fun invoke( | ||
area: String, | ||
year: Int, | ||
semester: String, | ||
sortOption: String | ||
): Result<ToDoInfoEntity> = | ||
pieceRepository.getTodoInfo( | ||
area = area, | ||
year = year, | ||
semester = semester, | ||
sortOption = sortOption | ||
) | ||
} |
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.