-
Notifications
You must be signed in to change notification settings - Fork 1
캠퍼스맵 API 추가 #732
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
Open
boiledeggg
wants to merge
4
commits into
develop
Choose a base branch
from
feature/kuring-map-api
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
캠퍼스맵 API 추가 #732
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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
61 changes: 61 additions & 0 deletions
61
data/place/src/main/java/com/ku_stacks/ku_ring/place/mapper/ResponseToDomain.kt
This file contains hidden or 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,61 @@ | ||
| package com.ku_stacks.ku_ring.place.mapper | ||
|
|
||
| import com.ku_stacks.ku_ring.domain.Place | ||
| import com.ku_stacks.ku_ring.domain.PlaceCategory | ||
| import com.ku_stacks.ku_ring.domain.PlaceFacility | ||
| import com.ku_stacks.ku_ring.domain.PlaceOperationHours | ||
| import com.ku_stacks.ku_ring.remote.place.response.PlaceBuildingDetailResponse | ||
| import com.ku_stacks.ku_ring.remote.place.response.PlaceBuildingResponse | ||
| import com.ku_stacks.ku_ring.remote.place.response.PlaceCampusPlaceResponse | ||
| import com.ku_stacks.ku_ring.remote.place.response.PlaceCategoryResponse | ||
| import com.ku_stacks.ku_ring.remote.place.response.PlaceOperatingHoursResponse | ||
|
|
||
| internal fun PlaceBuildingResponse.toDomain() = Place( | ||
| id = id.toString(), | ||
| name = name, | ||
| category = "", | ||
| address = address, | ||
| latitude = latitude, | ||
| longitude = longitude, | ||
| priority = Place.Priority.MIDDLE, | ||
| ) | ||
|
|
||
| internal fun PlaceBuildingDetailResponse.toDomain() = Place( | ||
| id = id.toString(), | ||
| name = name, | ||
| category = "", | ||
| address = address, | ||
| latitude = latitude, | ||
| longitude = longitude, | ||
| priority = Place.Priority.MIDDLE, | ||
| imageUrl = imageUrl, | ||
| operationHours = currentOperatingHours?.toDomain(), | ||
| facilities = campusPlaces.map { it.toDomain() }, | ||
| ) | ||
|
|
||
| internal fun PlaceCampusPlaceResponse.toDomain() = PlaceFacility( | ||
| name = name, | ||
| category = categoryKorName, | ||
| location = listOfNotNull(floor, locationDetail).joinToString(" ").ifBlank { null }, | ||
| operationHours = currentOperatingHours?.toDomain(), | ||
| id = id, | ||
| imageUrl = imageUrl, | ||
| quantity = quantity, | ||
| externalUrl = externalUrl, | ||
| ) | ||
|
|
||
| internal fun PlaceOperatingHoursResponse.toDomain() = PlaceOperationHours( | ||
| current = toDisplayText(), | ||
| ) | ||
|
|
||
| private fun PlaceOperatingHoursResponse.toDisplayText(): String = when (status) { | ||
| "OPEN_24_HOURS" -> "24시간 운영" | ||
| "CLOSED" -> "휴무" | ||
| else -> if (opensAt != null && closesAt != null) "$opensAt - $closesAt" else "-" | ||
| } | ||
|
|
||
| internal fun PlaceCategoryResponse.toDomain() = PlaceCategory( | ||
| name = name, | ||
| korName = korName, | ||
| displayOrder = displayOrder, | ||
| ) |
50 changes: 49 additions & 1 deletion
50
data/place/src/main/java/com/ku_stacks/ku_ring/place/repository/PlaceRepositoryImpl.kt
This file contains hidden or 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 |
|---|---|---|
| @@ -1,15 +1,63 @@ | ||
| package com.ku_stacks.ku_ring.place.repository | ||
|
|
||
| import com.ku_stacks.ku_ring.domain.Place | ||
| import com.ku_stacks.ku_ring.domain.PlaceCategory | ||
| import com.ku_stacks.ku_ring.domain.PlaceFacility | ||
| import com.ku_stacks.ku_ring.domain.place.repository.PlaceRepository | ||
| import com.ku_stacks.ku_ring.place.datasource.PlaceDataSource | ||
| import com.ku_stacks.ku_ring.place.mapper.toDomain | ||
| import com.ku_stacks.ku_ring.remote.place.PlaceClient | ||
| import com.ku_stacks.ku_ring.util.suspendRunCatching | ||
| import javax.inject.Inject | ||
|
|
||
| class PlaceRepositoryImpl @Inject constructor( | ||
| private val placeDataSource: PlaceDataSource, | ||
| ): PlaceRepository { | ||
| private val placeClient: PlaceClient, | ||
| ) : PlaceRepository { | ||
| override suspend fun getPlaces(): List<Place> { | ||
| return placeDataSource.getJsonPlaces().map { it.toDomain() } | ||
| } | ||
|
|
||
| override suspend fun getPlaceBuildingDetail(buildingId: Long): Result<Place> = | ||
| suspendRunCatching { | ||
| val response = placeClient.fetchBuildingDetail(buildingId) | ||
| when { | ||
| response.isSuccessAndDataExists -> response.data!!.toDomain() | ||
| else -> throw IllegalStateException(response.resultMsg) | ||
| } | ||
| } | ||
|
|
||
| override suspend fun searchPlaceBuildings(keyword: String): Result<List<Place>> = | ||
| suspendRunCatching { | ||
| val response = placeClient.searchBuildings(keyword) | ||
| when { | ||
| response.isSuccessAndDataExists -> response.data!!.buildings.map { it.toDomain() } | ||
| else -> throw IllegalStateException(response.resultMsg) | ||
| } | ||
| } | ||
|
|
||
| override suspend fun getPlaceBuildings(): Result<List<Place>> = suspendRunCatching { | ||
| val response = placeClient.fetchBuildings() | ||
| when { | ||
| response.isSuccessAndDataExists -> response.data!!.buildings.map { it.toDomain() } | ||
| else -> throw IllegalStateException(response.resultMsg) | ||
| } | ||
| } | ||
|
|
||
| override suspend fun getPlaceCampusPlaces(category: String): Result<List<PlaceFacility>> = | ||
| suspendRunCatching { | ||
| val response = placeClient.fetchCampusPlaces(category) | ||
| when { | ||
| response.isSuccessAndDataExists -> response.data!!.campusPlaces.map { it.toDomain() } | ||
| else -> throw IllegalStateException(response.resultMsg) | ||
| } | ||
| } | ||
|
|
||
| override suspend fun getPlaceCategories(): Result<List<PlaceCategory>> = suspendRunCatching { | ||
| val response = placeClient.fetchCategories() | ||
| when { | ||
| response.isSuccessAndDataExists -> response.data!!.categories.map { it.toDomain() } | ||
| else -> throw IllegalStateException(response.resultMsg) | ||
| } | ||
| } | ||
| } |
This file contains hidden or 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
27 changes: 27 additions & 0 deletions
27
data/remote/src/main/java/com/ku_stacks/ku_ring/remote/place/PlaceClient.kt
This file contains hidden or 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.ku_stacks.ku_ring.remote.place | ||
|
|
||
| import com.ku_stacks.ku_ring.remote.place.response.PlaceBuildingDetailResponse | ||
| import com.ku_stacks.ku_ring.remote.place.response.PlaceBuildingListResponse | ||
| import com.ku_stacks.ku_ring.remote.place.response.PlaceCampusPlaceListResponse | ||
| import com.ku_stacks.ku_ring.remote.place.response.PlaceCategoryListResponse | ||
| import com.ku_stacks.ku_ring.remote.util.DefaultResponse | ||
| import javax.inject.Inject | ||
|
|
||
| class PlaceClient @Inject constructor( | ||
| private val placeService: PlaceService, | ||
| ) { | ||
| suspend fun fetchBuildingDetail(buildingId: Long): DefaultResponse<PlaceBuildingDetailResponse> = | ||
| placeService.fetchBuildingDetail(buildingId) | ||
|
|
||
| suspend fun searchBuildings(keyword: String): DefaultResponse<PlaceBuildingListResponse> = | ||
| placeService.searchBuildings(keyword) | ||
|
|
||
| suspend fun fetchBuildings(): DefaultResponse<PlaceBuildingListResponse> = | ||
| placeService.fetchBuildings() | ||
|
|
||
| suspend fun fetchCampusPlaces(category: String): DefaultResponse<PlaceCampusPlaceListResponse> = | ||
| placeService.fetchCampusPlaces(category) | ||
|
|
||
| suspend fun fetchCategories(): DefaultResponse<PlaceCategoryListResponse> = | ||
| placeService.fetchCategories() | ||
| } |
33 changes: 33 additions & 0 deletions
33
data/remote/src/main/java/com/ku_stacks/ku_ring/remote/place/PlaceService.kt
This file contains hidden or 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,33 @@ | ||
| package com.ku_stacks.ku_ring.remote.place | ||
|
|
||
| import com.ku_stacks.ku_ring.remote.place.response.PlaceBuildingDetailResponse | ||
| import com.ku_stacks.ku_ring.remote.place.response.PlaceBuildingListResponse | ||
| import com.ku_stacks.ku_ring.remote.place.response.PlaceCampusPlaceListResponse | ||
| import com.ku_stacks.ku_ring.remote.place.response.PlaceCategoryListResponse | ||
| import com.ku_stacks.ku_ring.remote.util.DefaultResponse | ||
| import retrofit2.http.GET | ||
| import retrofit2.http.Path | ||
| import retrofit2.http.Query | ||
|
|
||
| interface PlaceService { | ||
| @GET("v2/maps/buildings/{buildingId}") | ||
| suspend fun fetchBuildingDetail( | ||
| @Path("buildingId") buildingId: Long, | ||
| ): DefaultResponse<PlaceBuildingDetailResponse> | ||
|
|
||
| @GET("v2/maps/buildings/search") | ||
| suspend fun searchBuildings( | ||
| @Query("keyword") keyword: String, | ||
| ): DefaultResponse<PlaceBuildingListResponse> | ||
|
|
||
| @GET("v2/maps/buildings") | ||
| suspend fun fetchBuildings(): DefaultResponse<PlaceBuildingListResponse> | ||
|
|
||
| @GET("v2/maps/campus-places") | ||
| suspend fun fetchCampusPlaces( | ||
| @Query("category") category: String, | ||
| ): DefaultResponse<PlaceCampusPlaceListResponse> | ||
|
|
||
| @GET("v2/maps/categories") | ||
| suspend fun fetchCategories(): DefaultResponse<PlaceCategoryListResponse> | ||
| } |
25 changes: 25 additions & 0 deletions
25
data/remote/src/main/java/com/ku_stacks/ku_ring/remote/place/di/PlaceModule.kt
This file contains hidden or 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,25 @@ | ||
| package com.ku_stacks.ku_ring.remote.place.di | ||
|
|
||
| import com.ku_stacks.ku_ring.remote.place.PlaceClient | ||
| import com.ku_stacks.ku_ring.remote.place.PlaceService | ||
| import com.ku_stacks.ku_ring.remote.util.Default | ||
| import dagger.Module | ||
| import dagger.Provides | ||
| import dagger.hilt.InstallIn | ||
| import dagger.hilt.components.SingletonComponent | ||
| import retrofit2.Retrofit | ||
| import javax.inject.Singleton | ||
|
|
||
| @Module | ||
| @InstallIn(SingletonComponent::class) | ||
| object PlaceModule { | ||
| @Provides | ||
| @Singleton | ||
| fun providePlaceService(@Default retrofit: Retrofit): PlaceService = | ||
| retrofit.create(PlaceService::class.java) | ||
|
|
||
| @Provides | ||
| @Singleton | ||
| fun providePlaceClient(placeService: PlaceService): PlaceClient = | ||
| PlaceClient(placeService) | ||
| } |
16 changes: 16 additions & 0 deletions
16
.../src/main/java/com/ku_stacks/ku_ring/remote/place/response/PlaceBuildingDetailResponse.kt
This file contains hidden or 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.ku_stacks.ku_ring.remote.place.response | ||
|
|
||
| import kotlinx.serialization.SerialName | ||
| import kotlinx.serialization.Serializable | ||
|
|
||
| @Serializable | ||
| data class PlaceBuildingDetailResponse( | ||
| @SerialName("id") val id: Long, | ||
| @SerialName("name") val name: String, | ||
| @SerialName("address") val address: String, | ||
| @SerialName("latitude") val latitude: Double, | ||
| @SerialName("longitude") val longitude: Double, | ||
| @SerialName("imageUrl") val imageUrl: String? = null, | ||
| @SerialName("currentOperatingHours") val currentOperatingHours: PlaceOperatingHoursResponse? = null, | ||
| @SerialName("campusPlaces") val campusPlaces: List<PlaceCampusPlaceResponse> = emptyList(), | ||
| ) |
9 changes: 9 additions & 0 deletions
9
...te/src/main/java/com/ku_stacks/ku_ring/remote/place/response/PlaceBuildingListResponse.kt
This file contains hidden or 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,9 @@ | ||
| package com.ku_stacks.ku_ring.remote.place.response | ||
|
|
||
| import kotlinx.serialization.SerialName | ||
| import kotlinx.serialization.Serializable | ||
|
|
||
| @Serializable | ||
| data class PlaceBuildingListResponse( | ||
| @SerialName("buildings") val buildings: List<PlaceBuildingResponse>, | ||
| ) |
13 changes: 13 additions & 0 deletions
13
...remote/src/main/java/com/ku_stacks/ku_ring/remote/place/response/PlaceBuildingResponse.kt
This file contains hidden or 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,13 @@ | ||
| package com.ku_stacks.ku_ring.remote.place.response | ||
|
|
||
| import kotlinx.serialization.SerialName | ||
| import kotlinx.serialization.Serializable | ||
|
|
||
| @Serializable | ||
| data class PlaceBuildingResponse( | ||
| @SerialName("id") val id: Long, | ||
| @SerialName("name") val name: String, | ||
| @SerialName("address") val address: String, | ||
| @SerialName("latitude") val latitude: Double, | ||
| @SerialName("longitude") val longitude: Double, | ||
| ) |
9 changes: 9 additions & 0 deletions
9
...src/main/java/com/ku_stacks/ku_ring/remote/place/response/PlaceCampusPlaceListResponse.kt
This file contains hidden or 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,9 @@ | ||
| package com.ku_stacks.ku_ring.remote.place.response | ||
|
|
||
| import kotlinx.serialization.SerialName | ||
| import kotlinx.serialization.Serializable | ||
|
|
||
| @Serializable | ||
| data class PlaceCampusPlaceListResponse( | ||
| @SerialName("campusPlaces") val campusPlaces: List<PlaceCampusPlaceResponse>, | ||
| ) |
19 changes: 19 additions & 0 deletions
19
...ote/src/main/java/com/ku_stacks/ku_ring/remote/place/response/PlaceCampusPlaceResponse.kt
This file contains hidden or 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,19 @@ | ||
| package com.ku_stacks.ku_ring.remote.place.response | ||
|
|
||
| import kotlinx.serialization.SerialName | ||
| import kotlinx.serialization.Serializable | ||
|
|
||
| @Serializable | ||
| data class PlaceCampusPlaceResponse( | ||
| @SerialName("id") val id: Long, | ||
| @SerialName("name") val name: String, | ||
| @SerialName("category") val category: String, | ||
| @SerialName("categoryKorName") val categoryKorName: String, | ||
| @SerialName("imageUrl") val imageUrl: String? = null, | ||
| @SerialName("locationType") val locationType: String, | ||
| @SerialName("floor") val floor: String? = null, | ||
| @SerialName("locationDetail") val locationDetail: String? = null, | ||
| @SerialName("quantity") val quantity: Int? = null, | ||
| @SerialName("currentOperatingHours") val currentOperatingHours: PlaceOperatingHoursResponse? = null, | ||
| @SerialName("externalUrl") val externalUrl: String? = null, | ||
| ) |
9 changes: 9 additions & 0 deletions
9
...te/src/main/java/com/ku_stacks/ku_ring/remote/place/response/PlaceCategoryListResponse.kt
This file contains hidden or 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,9 @@ | ||
| package com.ku_stacks.ku_ring.remote.place.response | ||
|
|
||
| import kotlinx.serialization.SerialName | ||
| import kotlinx.serialization.Serializable | ||
|
|
||
| @Serializable | ||
| data class PlaceCategoryListResponse( | ||
| @SerialName("categories") val categories: List<PlaceCategoryResponse>, | ||
| ) |
11 changes: 11 additions & 0 deletions
11
...remote/src/main/java/com/ku_stacks/ku_ring/remote/place/response/PlaceCategoryResponse.kt
This file contains hidden or 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.ku_stacks.ku_ring.remote.place.response | ||
|
|
||
| import kotlinx.serialization.SerialName | ||
| import kotlinx.serialization.Serializable | ||
|
|
||
| @Serializable | ||
| data class PlaceCategoryResponse( | ||
| @SerialName("name") val name: String, | ||
| @SerialName("korName") val korName: String, | ||
| @SerialName("displayOrder") val displayOrder: Int, | ||
| ) |
13 changes: 13 additions & 0 deletions
13
.../src/main/java/com/ku_stacks/ku_ring/remote/place/response/PlaceOperatingHoursResponse.kt
This file contains hidden or 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,13 @@ | ||
| package com.ku_stacks.ku_ring.remote.place.response | ||
|
|
||
| import kotlinx.serialization.SerialName | ||
| import kotlinx.serialization.Serializable | ||
|
|
||
| @Serializable | ||
| data class PlaceOperatingHoursResponse( | ||
| @SerialName("period") val period: String, | ||
| @SerialName("dayGroup") val dayGroup: String, | ||
| @SerialName("status") val status: String, | ||
| @SerialName("opensAt") val opensAt: String? = null, | ||
| @SerialName("closesAt") val closesAt: String? = null, | ||
| ) |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.