Skip to content

Commit

Permalink
#69 feat : dto 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
SeonHwan-Kim authored and wateralsie committed Jul 21, 2023
1 parent a9b98e2 commit a0fc42e
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package com.lionheart.data.model.response

import com.lionheart.domain.entity.Article
import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable

@Serializable
class WeeklyArticleResponse(
@SerialName("articleSummaries")
val articleSummaries: List<ArticleResponse>,
@SerialName("week")
val week: Int
) {
@Serializable
data class ArticleResponse(
@SerialName("articleId")
val articleId: Long,
@SerialName("title")
val title: String,
@SerialName("mainImageUrl")
val mainImageUrl: String,
@SerialName("firstBodyContent")
val firstBodyContent: String,
@SerialName("requiredTime")
val requiredTime: Long,
@SerialName("isMarked")
val isMarked: Boolean,
@SerialName("tags")
val tags: List<String>,
) {
fun toArticleEntity() = Article(
articleId = articleId,
title = title,
mainImageUrl = mainImageUrl,
firstBodyContent = firstBodyContent,
requiredTime = requiredTime,
isMarked = isMarked,
tags = tags,
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import com.lionheart.data.model.response.ArticleListResponse
import com.lionheart.data.model.response.BaseResponse
import com.lionheart.data.model.response.BookMarkListResponse
import com.lionheart.data.model.response.TodayArticleResponse
import com.lionheart.data.model.response.WeeklyArticleResponse
import com.lionheart.domain.entity.ArticleCategory
import retrofit2.http.Body
import retrofit2.http.GET
Expand All @@ -30,7 +31,7 @@ interface ArticleService {
@GET("/api/v1/article/week/{week}")
suspend fun getWeeklyArticle(
@Path("week") week: Long,
): BaseResponse<ArticleListResponse>
): BaseResponse<WeeklyArticleResponse>

@GET("/api/v1/article/bookmarks")
suspend fun getBookmarks(): BaseResponse<BookMarkListResponse>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class CourseDetailActivity :

override fun constructLayout() {
getWeeklyArticle()
Timber.d("${intent.getIntExtra("week", 0)}, ${intent.getStringExtra("imageUrl")}")
Timber.d("${intent.getLongExtra("week", 0)}, ${intent.getStringExtra("imageUrl")}")
// databinding
with(binding) {
vm = viewModel
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class CourseFragment : BindingFragment<FragmentCourseBinding>(R.layout.fragment_

private fun initRecyclerView() {
viewModel.courseList.observe(this@CourseFragment) {
_courseAdapter = CourseAdapter(it) { week, image -> goToDetail(week.toInt(), image) }
_courseAdapter = CourseAdapter(it) { week, image -> goToDetail(week, image) }

with(binding.rvCourseContent) {
adapter = courseAdapter
Expand All @@ -55,7 +55,7 @@ class CourseFragment : BindingFragment<FragmentCourseBinding>(R.layout.fragment_
}
}

private fun goToDetail(week: Int, image: String) {
private fun goToDetail(week: Long, image: String) {
Intent(activity, CourseDetailActivity::class.java).apply {
putExtra(WEEK, week)
putExtra("imageUrl", image)
Expand Down

0 comments on commit a0fc42e

Please sign in to comment.