Skip to content

Commit

Permalink
Merge pull request #50 from SOPT-all/feat/api-todo
Browse files Browse the repository at this point in the history
[feat] Piece Service API 구현
  • Loading branch information
beom84 authored Jan 22, 2025
2 parents aa0e312 + 66c1a11 commit 4ce994f
Show file tree
Hide file tree
Showing 45 changed files with 1,164 additions and 42 deletions.
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

0 comments on commit 4ce994f

Please sign in to comment.