-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #84 from everymeals/feature/api_get_university
[feature/api_get_university] 대학 목록 조회 API 연결
- Loading branch information
Showing
32 changed files
with
365 additions
and
363 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 0 additions & 9 deletions
9
data/src/main/java/com/everymeal/data/datasource/FoodDataSource.kt
This file was deleted.
Oops, something went wrong.
26 changes: 0 additions & 26 deletions
26
data/src/main/java/com/everymeal/data/datasource/FoodDataSourceImpl.kt
This file was deleted.
Oops, something went wrong.
7 changes: 7 additions & 0 deletions
7
data/src/main/java/com/everymeal/data/datasource/onboarding/OnboardingDataSource.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package com.everymeal.data.datasource.onboarding | ||
|
||
import com.everymeal.data.model.onboarding.UniversityData | ||
|
||
interface OnboardingDataSource { | ||
suspend fun getUniversity(): Result<List<UniversityData>> | ||
} |
15 changes: 15 additions & 0 deletions
15
data/src/main/java/com/everymeal/data/datasource/onboarding/OnboardingDataSourceImpl.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package com.everymeal.data.datasource.onboarding | ||
|
||
import com.everymeal.data.model.onboarding.UniversityData | ||
import com.everymeal.data.model.unwrapData | ||
import com.everymeal.data.service.onboarding.OnboardingApi | ||
import javax.inject.Inject | ||
|
||
class OnboardingDataSourceImpl @Inject constructor( | ||
private val onboardingApi: OnboardingApi | ||
) : OnboardingDataSource { | ||
|
||
override suspend fun getUniversity(): Result<List<UniversityData>> { | ||
return runCatching { onboardingApi.getUniversity() }.unwrapData() | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
data/src/main/java/com/everymeal/data/model/BaseResponse.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package com.everymeal.data.model | ||
|
||
import kotlinx.serialization.Serializable | ||
|
||
@Serializable | ||
data class BaseResponse<T>( | ||
val localDateTime: String, | ||
val message: String, | ||
val data: T, | ||
) | ||
|
||
fun <T> Result<BaseResponse<T>>.unwrapData(): Result<T> { | ||
return this.map { it.data } | ||
} |
44 changes: 0 additions & 44 deletions
44
data/src/main/java/com/everymeal/data/model/GetWeekFood.kt
This file was deleted.
Oops, something went wrong.
27 changes: 27 additions & 0 deletions
27
data/src/main/java/com/everymeal/data/model/onboarding/GetUniversityData.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package com.everymeal.data.model.onboarding | ||
|
||
import com.everymeal.domain.model.onboarding.GetUniversityEntity | ||
import kotlinx.serialization.Serializable | ||
|
||
@Serializable | ||
data class UniversityData( | ||
val idx: Int, | ||
val universityName: String, | ||
val campusName: String, | ||
val universityShortName: String | ||
) | ||
|
||
fun List<UniversityData>.toUniversityEntity(): GetUniversityEntity { | ||
val universityDataList = this.map { result -> | ||
GetUniversityEntity.UniversityData( | ||
idx = result.idx, | ||
universityName = result.universityName, | ||
campusName = result.campusName, | ||
universityShortName = result.universityShortName | ||
) | ||
} | ||
|
||
return GetUniversityEntity( | ||
data = universityDataList | ||
) | ||
} |
16 changes: 0 additions & 16 deletions
16
data/src/main/java/com/everymeal/data/repository/FoodRepositoryImpl.kt
This file was deleted.
Oops, something went wrong.
16 changes: 16 additions & 0 deletions
16
data/src/main/java/com/everymeal/data/repository/onboarding/OnboardingRepositoryImpl.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package com.everymeal.data.repository.onboarding | ||
|
||
import com.everymeal.data.datasource.onboarding.OnboardingDataSource | ||
import com.everymeal.data.model.onboarding.toUniversityEntity | ||
import com.everymeal.domain.model.onboarding.GetUniversityEntity | ||
import com.everymeal.domain.repository.onboarding.OnboardingRepository | ||
import javax.inject.Inject | ||
|
||
class OnboardingRepositoryImpl @Inject constructor( | ||
private val onboardingDataSource: OnboardingDataSource | ||
): OnboardingRepository { | ||
|
||
override suspend fun getUniversity(): Result<GetUniversityEntity> { | ||
return onboardingDataSource.getUniversity().map { it.toUniversityEntity() } | ||
} | ||
} |
14 changes: 0 additions & 14 deletions
14
data/src/main/java/com/everymeal/data/service/ExampleApi.kt
This file was deleted.
Oops, something went wrong.
11 changes: 11 additions & 0 deletions
11
data/src/main/java/com/everymeal/data/service/onboarding/OnboardingApi.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package com.everymeal.data.service.onboarding | ||
|
||
import com.everymeal.data.model.BaseResponse | ||
import com.everymeal.data.model.onboarding.UniversityData | ||
import retrofit2.http.GET | ||
|
||
interface OnboardingApi { | ||
|
||
@GET("/api/v1/universities") | ||
suspend fun getUniversity(): BaseResponse<List<UniversityData>> | ||
} |
18 changes: 0 additions & 18 deletions
18
domain/src/main/java/com/everymeal/domain/model/ResponseWeekFoodEntity.kt
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
12 changes: 12 additions & 0 deletions
12
domain/src/main/java/com/everymeal/domain/model/onboarding/GetUniversityEntity.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package com.everymeal.domain.model.onboarding | ||
|
||
data class GetUniversityEntity( | ||
val data: List<UniversityData> | ||
) { | ||
data class UniversityData( | ||
val idx: Int, | ||
val universityName: String, | ||
val campusName: String, | ||
val universityShortName: String | ||
) | ||
} |
8 changes: 0 additions & 8 deletions
8
domain/src/main/java/com/everymeal/domain/repository/FoodRepository.kt
This file was deleted.
Oops, something went wrong.
7 changes: 7 additions & 0 deletions
7
domain/src/main/java/com/everymeal/domain/repository/onboarding/OnboardingRepository.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package com.everymeal.domain.repository.onboarding | ||
|
||
import com.everymeal.domain.model.onboarding.GetUniversityEntity | ||
|
||
interface OnboardingRepository { | ||
suspend fun getUniversity(): Result<GetUniversityEntity> | ||
} |
Oops, something went wrong.