-
Notifications
You must be signed in to change notification settings - Fork 3
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: 홈화면 API 연결 #74
feat: 홈화면 API 연결 #74
Changes from 1 commit
8333c97
32964b8
ca5f94b
6405e23
4dffb85
9b09925
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package com.zzang.chongdae.data.mapper | ||
|
||
import com.zzang.chongdae.data.remote.dto.response.RemoteOffering | ||
import com.zzang.chongdae.domain.model.Offering | ||
|
||
fun RemoteOffering.toDomain() = | ||
Offering( | ||
id = this.id, | ||
title = this.title, | ||
meetingAddress = this.meetingAddress, | ||
thumbnailUrl = this.thumbnailUrl, | ||
totalCount = this.totalCount, | ||
currentCount = this.currentCount, | ||
dividedPrice = this.dividedPrice, | ||
condition = this.condition.toDomain(), | ||
isOpen = this.isOpen, | ||
) |
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package com.zzang.chongdae.data.remote.api | ||
|
||
import com.zzang.chongdae.data.remote.dto.response.OfferingsResponse | ||
import retrofit2.Response | ||
import retrofit2.http.GET | ||
import retrofit2.http.Query | ||
|
||
interface OfferingsApiService { | ||
@GET("/offerings") | ||
suspend fun getArticles( | ||
@Query("last-id") lastOfferingId: Long, | ||
@Query("page-size") pageSize: Int, | ||
): Response<OfferingsResponse> | ||
} |
This file was deleted.
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package com.zzang.chongdae.data.remote.source | ||
|
||
import com.zzang.chongdae.data.remote.dto.response.OfferingsResponse | ||
|
||
interface OfferingsDataSource { | ||
suspend fun fetchOfferings(lastOfferingId:Long, pageSize:Int): Result<OfferingsResponse> | ||
} |
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package com.zzang.chongdae.data.remote.source.impl | ||
|
||
import com.zzang.chongdae.data.remote.api.OfferingsApiService | ||
import com.zzang.chongdae.data.remote.dto.response.OfferingsResponse | ||
import com.zzang.chongdae.data.remote.source.OfferingsDataSource | ||
|
||
class OfferingsDataSourceImpl( | ||
private val service: OfferingsApiService, | ||
) : OfferingsDataSource { | ||
override suspend fun fetchOfferings( | ||
lastOfferingId: Long, | ||
pageSize: Int | ||
): Result<OfferingsResponse> = | ||
runCatching { | ||
service.getArticles(lastOfferingId, pageSize).body() ?: throw IllegalStateException() | ||
} | ||
} |
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package com.zzang.chongdae.data.repository.remote | ||
|
||
import com.zzang.chongdae.data.mapper.toDomain | ||
import com.zzang.chongdae.data.remote.source.OfferingsDataSource | ||
import com.zzang.chongdae.domain.model.Offering | ||
import com.zzang.chongdae.domain.repository.OfferingsRepository | ||
|
||
class OfferingsRepositoryImpl( | ||
private val offeringsDataSource: OfferingsDataSource, | ||
) : OfferingsRepository { | ||
override suspend fun fetchOfferings( | ||
lastOfferingId: Long, | ||
pageSize: Int | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ktlint가 걸리겠군요 ㅋㅋ There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 이상하게도 lintcheck와 CI는 통과하더라구요,,, 하하 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. CI가 왜 통과한건지 신기하네요?? 😲 |
||
): Result<List<Offering>> { | ||
return offeringsDataSource.fetchOfferings(lastOfferingId, pageSize).mapCatching { | ||
it.offerings.map { it.toDomain() } | ||
} | ||
} | ||
} |
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,13 @@ | ||
package com.zzang.chongdae.domain.model | ||
|
||
import java.time.LocalDateTime | ||
|
||
data class Article( | ||
data class Offering( | ||
val id: Long, | ||
val thumbnailUrl: String, | ||
val deadline: LocalDateTime, | ||
val title: String, | ||
val meetingAddress: String, | ||
val splitPrice: Int, | ||
val thumbnailUrl: String?, | ||
val totalCount: Int, | ||
val currentCount: Int, | ||
val isClosed: Boolean, | ||
val dividedPrice: Int, | ||
val condition: OfferingCondition, | ||
val isOpen: Boolean, | ||
) |
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package com.zzang.chongdae.domain.repository | ||
|
||
import com.zzang.chongdae.domain.model.Offering | ||
|
||
interface OfferingsRepository { | ||
suspend fun fetchOfferings(lastOfferingId:Long, pageSize:Int): Result<List<Offering>> | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
여기도 린트가 걸리겠어요!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
전체적으로 ./gradlew ktFormat 부탁해요~