Skip to content

Commit

Permalink
feat: Tạo model và dto cho get study set by id request
Browse files Browse the repository at this point in the history
  • Loading branch information
nqmgaming committed Sep 30, 2024
1 parent 96a2a49 commit 2b034ce
Show file tree
Hide file tree
Showing 9 changed files with 109 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package com.pwhs.quickmem.data.dto.color

import com.google.gson.annotations.SerializedName

data class ColorResponseDto(
@SerializedName("id")
val id: Int,

@SerializedName("name")
val name: String,

@SerializedName("hexValue")
val hexValue: String
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package com.pwhs.quickmem.data.dto.study_set

import com.google.gson.annotations.SerializedName
import com.pwhs.quickmem.data.dto.color.ColorResponseDto
import com.pwhs.quickmem.data.dto.subject.SubjectResponseDto

data class GetStudySetResponseDto(
@SerializedName("id")
val id: String,

@SerializedName("title")
val title: String,

@SerializedName("description")
val description: String,

@SerializedName("isPublic")
val isPublic: Boolean,

@SerializedName("createdAt")
val createdAt: String, // Sử dụng String hoặc LocalDateTime

@SerializedName("updatedAt")
val updatedAt: String,

@SerializedName("ownerId")
val ownerId: String,

@SerializedName("subject")
val subject: SubjectResponseDto? = null,

@SerializedName("color")
val color: ColorResponseDto? = null
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package com.pwhs.quickmem.data.dto.subject

import com.google.gson.annotations.SerializedName

data class SubjectResponseDto(
@SerializedName("id")
val id: Int,

@SerializedName("name")
val name: String
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package com.pwhs.quickmem.data.mapper.color

import com.pwhs.quickmem.data.dto.color.ColorResponseDto
import com.pwhs.quickmem.domain.model.color.ColorModel

fun ColorResponseDto.toColorModel() = ColorModel(
id = id,
name = name,
hexValue = hexValue
)

fun ColorModel.toColorResponseDto() = ColorResponseDto(
id = id,
name = name,
hexValue = hexValue
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package com.pwhs.quickmem.data.mapper.subject

import com.pwhs.quickmem.data.dto.subject.SubjectResponseDto
import com.pwhs.quickmem.domain.model.subject.SubjectModel

fun SubjectResponseDto.toSubjectModel() = SubjectModel(
id = id,
name = name,
)

fun SubjectModel.toSubjectResponseDto() = SubjectResponseDto(
id = id,
name = name,
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package com.pwhs.quickmem.domain.model.study_set

import com.pwhs.quickmem.data.dto.color.ColorResponseDto
import com.pwhs.quickmem.data.dto.subject.SubjectResponseDto

data class GetStudySetResponseModel(
val id: String,
val title: String,
val description: String,
val isPublic: Boolean,
val createdAt: String,
val updatedAt: String,
val ownerId: String,
val subject: SubjectResponseDto? = null,
val color: ColorResponseDto? = null
)
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ data class SubjectModel(
val name: String,
@DrawableRes val iconRes: Int? = null,
val color: Color? = null,
val description: String?,
val description: String? = null,
val createdAt: String? = null,
val updatedAt: String? = null
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,6 @@ interface StudySetRepository {
token: String,
createStudySetRequestModel: CreateStudySetRequestModel
): Flow<Resources<CreateStudySetResponseModel>>


}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import androidx.compose.material3.Scaffold
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.getValue
import androidx.compose.runtime.rememberCoroutineScope
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
Expand All @@ -26,13 +25,12 @@ import com.ramcosta.composedestinations.annotation.Destination
import com.ramcosta.composedestinations.annotation.RootGraph
import com.ramcosta.composedestinations.generated.destinations.HomeScreenDestination
import com.ramcosta.composedestinations.generated.destinations.SearchScreenDestination

import com.ramcosta.composedestinations.navigation.DestinationsNavigator

@Destination<RootGraph>
@Composable
fun HomeScreen(
modifier: Modifier,
modifier: Modifier = Modifier,
navigator: DestinationsNavigator,
viewModel: HomeViewModel = hiltViewModel()
) {
Expand Down

0 comments on commit 2b034ce

Please sign in to comment.