-
Notifications
You must be signed in to change notification settings - Fork 0
[Feat/IPLC-23] 홈 api 연결 #199
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
The head ref may contain hidden characters: "feat/IPLC-23-\uD648-API-\uC5F0\uACB0"
Changes from 8 commits
ddeb19a
02fe654
7f08e43
6bc7948
2f8321b
64db469
1d6c0ae
471aabf
fe9c763
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| package org.sopt.certi.core.util | ||
|
|
||
| fun Int.dateString(): String { | ||
| return if (this.toString().length == 1) { | ||
| "0$this" | ||
| } else { | ||
| this.toString() | ||
| } | ||
| } | ||
|
Collaborator
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. [3] 이거 길이 체크 안 해도 |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -17,3 +17,11 @@ fun String.toLocalDateOrMin(): LocalDate = | |
| fun String.toLocalDateOrNull(): LocalDate? = | ||
| runCatching { LocalDate.parse(this, DateFormatters.dotDate) } | ||
| .getOrElse { null } | ||
|
|
||
| fun String.dateString(): String { | ||
| return if (this.length == 1) { | ||
| "0$this" | ||
| } else { | ||
| this | ||
| } | ||
| } | ||
|
Comment on lines
+21
to
+23
Collaborator
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. [3] 이것도 |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| package org.sopt.certi.data.remote.dto.response | ||
|
|
||
| import kotlinx.serialization.SerialName | ||
| import kotlinx.serialization.Serializable | ||
|
|
||
| @Serializable | ||
| data class GetPreCertDayListResponseDto( | ||
| @SerialName("date") | ||
| val date: String, | ||
| @SerialName("certifications") | ||
| val certifications: List<PreCertDayItemResponseDto>? | ||
| ) | ||
|
|
||
| @Serializable | ||
| data class PreCertDayItemResponseDto( | ||
| @SerialName("certificationId") | ||
| val certificationId: Long, | ||
| @SerialName("certificationName") | ||
| val certificationName: String, | ||
| @SerialName("tags") | ||
| val tags: List<String>, | ||
| @SerialName("averagePeriod") | ||
| val averagePeriod: String, | ||
| @SerialName("charge") | ||
| val charge: String, | ||
| @SerialName("agencyName") | ||
| val agencyName: String, | ||
| @SerialName("testType") | ||
| val testType: String, | ||
| @SerialName("description") | ||
| val description: String, | ||
| @SerialName("applicationMethod") | ||
| val applicationMethod: String, | ||
| @SerialName("applicationUrl") | ||
| val applicationUrl: String, | ||
| @SerialName("expirationPeriod") | ||
| val expirationPeriod: String, | ||
| @SerialName("city") | ||
| val city: String, | ||
| @SerialName("state") | ||
| val state: String, | ||
| @SerialName("testDate") | ||
| val testDate: String, | ||
| @SerialName("isAcquired") | ||
| val isAcquired: Boolean | ||
| ) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| package org.sopt.certi.data.remote.dto.response | ||
|
|
||
| import kotlinx.serialization.SerialName | ||
| import kotlinx.serialization.Serializable | ||
|
|
||
| @Serializable | ||
| data class GetPreCertMonthResponseDto( | ||
| @SerialName("year") | ||
| val year: Int, | ||
| @SerialName("month") | ||
| val month: Int, | ||
| @SerialName("days") | ||
| val days: List<PreCertMonthDayItem> | ||
| ) | ||
|
|
||
| @Serializable | ||
| data class PreCertMonthDayItem( | ||
| @SerialName("day") | ||
| val day: Int, | ||
| @SerialName("count") | ||
| val count: Int | ||
| ) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -9,6 +9,7 @@ import org.sopt.certi.domain.model.user.UserInfoData | |
| import org.sopt.certi.domain.repository.HomeRepository | ||
| import javax.inject.Inject | ||
| import org.sopt.certi.data.remote.util.HttpResponseHandler.handleNullableApiResponse | ||
| import org.sopt.certi.domain.model.certification.PreCertDayData | ||
|
|
||
| class HomeRepositoryImpl @Inject constructor( | ||
| private val homeRemoteDataSource: HomeRemoteDataSource, | ||
|
|
@@ -58,4 +59,22 @@ class HomeRepositoryImpl @Inject constructor( | |
| Unit | ||
| } | ||
| } | ||
|
|
||
| override suspend fun getPreCertMonth(year: Int, month: Int): Result<List<Int>> { | ||
| return runCatching { | ||
|
Collaborator
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. [2]: 왜 safeApiCall 안 쓰고 runCatching 쓰셨나요 |
||
| homeRemoteDataSource.getPreCertMonth(year, month) | ||
| .handleApiResponse() | ||
| .getOrThrow() | ||
| .toDomain() | ||
| } | ||
| } | ||
|
|
||
| override suspend fun getPreCertDay(date: String): Result<PreCertDayData> { | ||
| return runCatching { | ||
| homeRemoteDataSource.getPreCertDay(date) | ||
| .handleApiResponse() | ||
| .getOrThrow() | ||
| .toDomain() | ||
| } | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| package org.sopt.certi.domain.model.certification | ||
|
|
||
| data class PreCertDayData( | ||
| val date: String = "", | ||
| val certifications: List<CertificationData>? = emptyList() | ||
| ) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| package org.sopt.certi.domain.usecase.certification | ||
|
|
||
| import org.sopt.certi.domain.repository.HomeRepository | ||
| import javax.inject.Inject | ||
|
|
||
| class GetPreCertDayUseCase @Inject constructor( | ||
| private val homeRepository: HomeRepository | ||
| ) { | ||
| suspend operator fun invoke(date: String) = homeRepository.getPreCertDay(date) | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| package org.sopt.certi.domain.usecase.certification | ||
|
|
||
| import org.sopt.certi.domain.repository.HomeRepository | ||
| import javax.inject.Inject | ||
|
|
||
| class GetPreCertMonthUseCase @Inject constructor( | ||
| private val homeRepository: HomeRepository | ||
| ) { | ||
| suspend operator fun invoke(year: Int, month: Int) = homeRepository.getPreCertMonth(year, month) | ||
| } |
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.
[1] 이거 이름 img_logo_black으로 해야 하는거 아닌가요