Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[feat] Piece Service API 구현 #50

Merged
merged 18 commits into from
Jan 22, 2025
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
@@ -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)
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@ class DummyRemoteDataSource
constructor(
private val dummyService: DummyService,
) {
suspend fun getDummyData(): BaseResponse<ResponseDummyDto> = dummyService.getDummy()
suspend fun getDummyData(): BaseResponse<ResponseDummyDto?> = dummyService.getDummy()
}
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)
}
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)
}
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)
}
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,
)
}
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,
)
}
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,
)
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>,
)
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,
)
}
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,
)
}
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,
)
}
Loading
Loading