-
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.
Merge pull request #50 from SOPT-all/feat/api-todo
[feat] Piece Service API 구현
- Loading branch information
Showing
45 changed files
with
1,164 additions
and
42 deletions.
There are no files selected for viewing
16 changes: 16 additions & 0 deletions
16
...rc/main/java/org/android/bbangzip/data/datasource/remote/AssignToTodayRemoteDataSource.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.datasource.remote | ||
|
||
import org.android.bbangzip.data.dto.request.RequestPieceIdDto | ||
import org.android.bbangzip.data.service.PieceService | ||
import org.android.bbangzip.data.util.base.BaseResponse | ||
import javax.inject.Inject | ||
|
||
class AssignToTodayRemoteDataSource | ||
@Inject | ||
constructor( | ||
private val pieceService: PieceService, | ||
) { | ||
suspend fun postDeletedItemList( | ||
requestPieceIdDto: RequestPieceIdDto, | ||
): BaseResponse<Unit?> = pieceService.postAddTodoItemList(requestPieceIdDto = requestPieceIdDto) | ||
} |
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
16 changes: 16 additions & 0 deletions
16
app/src/main/java/org/android/bbangzip/data/datasource/remote/HideRemoteDataSource.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.datasource.remote | ||
|
||
import org.android.bbangzip.data.dto.request.RequestPieceIdDto | ||
import org.android.bbangzip.data.service.PieceService | ||
import org.android.bbangzip.data.util.base.BaseResponse | ||
import javax.inject.Inject | ||
|
||
class HideRemoteDataSource | ||
@Inject | ||
constructor( | ||
private val pieceService: PieceService, | ||
) { | ||
suspend fun postDeletedItemList( | ||
requestPieceIdDto: RequestPieceIdDto, | ||
): BaseResponse<Unit?> = pieceService.postDeletedItemList(requestPieceIdDto = requestPieceIdDto) | ||
} |
18 changes: 18 additions & 0 deletions
18
app/src/main/java/org/android/bbangzip/data/datasource/remote/MarkDoneRemoteDataStore.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.datasource.remote | ||
|
||
import org.android.bbangzip.data.dto.request.RequestMarkDoneDto | ||
import org.android.bbangzip.data.dto.response.ResponseMarkDoneDto | ||
import org.android.bbangzip.data.service.PieceService | ||
import org.android.bbangzip.data.util.base.BaseResponse | ||
import javax.inject.Inject | ||
|
||
class MarkDoneRemoteDataStore | ||
@Inject | ||
constructor( | ||
private val pieceService: PieceService, | ||
) { | ||
suspend fun postCompleteCardId( | ||
pieceId: Int, | ||
requestMarkDoneDto: RequestMarkDoneDto, | ||
): BaseResponse<ResponseMarkDoneDto?> = pieceService.postCompleteCardId(pieceId = pieceId, requestMarkDoneDto = requestMarkDoneDto) | ||
} |
17 changes: 17 additions & 0 deletions
17
app/src/main/java/org/android/bbangzip/data/datasource/remote/MarkUnDoneRemoteDataStore.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.request.RequestMarkDoneDto | ||
import org.android.bbangzip.data.service.PieceService | ||
import org.android.bbangzip.data.util.base.BaseResponse | ||
import javax.inject.Inject | ||
|
||
class MarkUnDoneRemoteDataStore | ||
@Inject | ||
constructor( | ||
private val pieceService: PieceService, | ||
) { | ||
suspend fun postUnCompleteCardId( | ||
pieceId: Int, | ||
requestMarkDoneDto: RequestMarkDoneDto, | ||
): BaseResponse<Unit?> = pieceService.postUnCompleteCardId(pieceId = pieceId, requestMarkDoneDto = requestMarkDoneDto) | ||
} |
25 changes: 25 additions & 0 deletions
25
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,25 @@ | ||
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, | ||
) | ||
} |
23 changes: 23 additions & 0 deletions
23
app/src/main/java/org/android/bbangzip/data/datasource/remote/TodoRemoteDataSource.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.ResponseTodoDto | ||
import org.android.bbangzip.data.service.PieceService | ||
import org.android.bbangzip.data.util.base.BaseResponse | ||
import javax.inject.Inject | ||
|
||
class TodoRemoteDataSource | ||
@Inject | ||
constructor( | ||
private val pieceService: PieceService, | ||
) { | ||
suspend fun getAddTodolist( | ||
year: Int, | ||
semester: String, | ||
sortOption: String, | ||
): BaseResponse<ResponseTodoDto?> = | ||
pieceService.getAddTodoList( | ||
year = year, | ||
semester = semester, | ||
sortOption = sortOption, | ||
) | ||
} |
10 changes: 10 additions & 0 deletions
10
app/src/main/java/org/android/bbangzip/data/dto/request/RequestMarkDoneDto.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.dto.request | ||
|
||
import kotlinx.serialization.SerialName | ||
import kotlinx.serialization.Serializable | ||
|
||
@Serializable | ||
data class RequestMarkDoneDto( | ||
@SerialName("isFinished") | ||
val isFinished: Boolean, | ||
) |
10 changes: 10 additions & 0 deletions
10
app/src/main/java/org/android/bbangzip/data/dto/request/RequestPieceIdDto.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.dto.request | ||
|
||
import kotlinx.serialization.SerialName | ||
import kotlinx.serialization.Serializable | ||
|
||
@Serializable | ||
data class RequestPieceIdDto( | ||
@SerialName("pieceIds") | ||
val pieceIds: List<Int>, | ||
) |
41 changes: 41 additions & 0 deletions
41
app/src/main/java/org/android/bbangzip/data/dto/response/ResponseMarkDoneDto.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,41 @@ | ||
package org.android.bbangzip.data.dto.response | ||
|
||
import kotlinx.serialization.SerialName | ||
import kotlinx.serialization.Serializable | ||
import org.android.bbangzip.domain.model.BadgeCardEntity | ||
import org.android.bbangzip.domain.model.BadgeCardListEntity | ||
|
||
@Serializable | ||
data class ResponseMarkDoneDto( | ||
@SerialName("badges") | ||
val badges: List<Badge>?, | ||
@SerialName("completeCounts") | ||
val completeCounts: Int, | ||
@SerialName("todayCounts") | ||
val todayCounts: Int, | ||
) { | ||
fun toBadgeCardListEntity() = | ||
BadgeCardListEntity( | ||
badgeCardList = | ||
badges?.map { item -> | ||
item.toBadgeCardEntity() | ||
} ?: listOf(), | ||
) | ||
} | ||
|
||
@Serializable | ||
data class Badge( | ||
@SerialName("badgeImage") | ||
val badgeImage: String, | ||
@SerialName("badgeName") | ||
val badgeName: String, | ||
@SerialName("hashTags") | ||
val hashTags: List<String>, | ||
) { | ||
fun toBadgeCardEntity() = | ||
BadgeCardEntity( | ||
badgeImage = badgeImage, | ||
badgeName = badgeName, | ||
hashTags = hashTags, | ||
) | ||
} |
67 changes: 67 additions & 0 deletions
67
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,67 @@ | ||
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("todoPiecesList") | ||
val todayList: List<TodoInfo>, | ||
@SerialName("pendingCount") | ||
val pendingCount: Int, | ||
@SerialName("todayCount") | ||
val todayCount: Int?, | ||
) { | ||
fun toTodoInfoEntity() = | ||
ToDoInfoEntity( | ||
todoList = | ||
todayList.map { todoItem -> | ||
todoItem.toTodoCardEntity() | ||
}, | ||
pendingCount = pendingCount, | ||
remainingStudyCount = todayCount ?: 0, | ||
completeCount = completeCount ?: 0, | ||
) | ||
} | ||
|
||
@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.split("-").let { parts -> | ||
"${parts[0]}년 ${parts[1].toInt()}월 ${parts[2].toInt()}일" | ||
}, | ||
remainingDays = remainingDays, | ||
isFinished = isFinished, | ||
) | ||
} |
57 changes: 57 additions & 0 deletions
57
app/src/main/java/org/android/bbangzip/data/dto/response/ResponseTodoDto.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,57 @@ | ||
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 ResponseTodoDto( | ||
@SerialName("todoCount") | ||
val todoCount: Int, | ||
@SerialName("todoList") | ||
val todoList: List<TodoCardInfo>, | ||
) { | ||
fun toTodoCardInfoEntity() = | ||
ToDoInfoEntity( | ||
todoList = | ||
todoList.map { todoItem -> | ||
todoItem.toTodoCardEntity() | ||
}, | ||
) | ||
} | ||
|
||
@Serializable | ||
data class TodoCardInfo( | ||
@SerialName("deadline") | ||
val deadline: String, | ||
@SerialName("examName") | ||
val examName: String, | ||
@SerialName("finishPage") | ||
val finishPage: Int, | ||
@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.split("-").let { parts -> | ||
"${parts[0]}년 ${parts[1].toInt()}월 ${parts[2].toInt()}일" | ||
}, | ||
remainingDays = remainingDays, | ||
) | ||
} |
Oops, something went wrong.