-
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.
- Loading branch information
Showing
22 changed files
with
839 additions
and
5 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
7 changes: 7 additions & 0 deletions
7
3days/core/model/src/main/java/com/weave/model/domain/myprofile/Location.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.weave.model.domain.myprofile | ||
|
||
data class Location( | ||
val id: java.util.UUID, | ||
val region: String, | ||
val subRegion: String | ||
) |
11 changes: 11 additions & 0 deletions
11
3days/data/src/main/java/com/weave/data/datasource/LocationRemoteDataSource.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.weave.data.datasource | ||
|
||
import com.weave.model.network.NetworkResult | ||
import com.weave.network.model.Location | ||
|
||
interface LocationRemoteDataSource { | ||
|
||
suspend fun getLocationRegions(): NetworkResult<List<String>> | ||
|
||
suspend fun getLocationsByRegion(regionName: String): NetworkResult<List<Location>> | ||
} |
24 changes: 24 additions & 0 deletions
24
3days/data/src/main/java/com/weave/data/datasource/LocationRemoteDataSourceImpl.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,24 @@ | ||
package com.weave.data.datasource | ||
|
||
import com.weave.data.extension.handleApiResponse | ||
import com.weave.model.network.NetworkResult | ||
import com.weave.network.api.LocationsApi | ||
import com.weave.network.model.Location | ||
import javax.inject.Inject | ||
|
||
class LocationRemoteDataSourceImpl @Inject constructor( | ||
private val service: LocationsApi | ||
) : LocationRemoteDataSource { | ||
|
||
override suspend fun getLocationRegions(): NetworkResult<List<String>> { | ||
return handleApiResponse { | ||
service.getLocationRegions() | ||
} | ||
} | ||
|
||
override suspend fun getLocationsByRegion(regionName: String): NetworkResult<List<Location>> { | ||
return handleApiResponse { | ||
service.getLocationsByRegion(regionName) | ||
} | ||
} | ||
} |
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: 9 additions & 0 deletions
9
3days/data/src/main/java/com/weave/data/mapper/LocationMapper.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,9 @@ | ||
package com.weave.data.mapper | ||
|
||
import com.weave.network.model.Location | ||
import com.weave.model.domain.myprofile.Location as LocationEntity | ||
|
||
val Location.toDomain | ||
get() = LocationEntity( | ||
id = id, region = region, subRegion = subRegion | ||
) |
31 changes: 31 additions & 0 deletions
31
3days/data/src/main/java/com/weave/data/repository/LocationRepositoryImpl.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,31 @@ | ||
package com.weave.data.repository | ||
|
||
import com.weave.data.datasource.LocationRemoteDataSource | ||
import com.weave.data.extension.handleNetworkCall | ||
import com.weave.data.mapper.toDomain | ||
import com.weave.domain.repository.LocationRepository | ||
import com.weave.model.domain.myprofile.Location | ||
import com.weave.model.network.NetworkResult | ||
import kotlinx.coroutines.flow.Flow | ||
import javax.inject.Inject | ||
|
||
class LocationRepositoryImpl @Inject constructor( | ||
private val dataSource: LocationRemoteDataSource | ||
) : LocationRepository { | ||
|
||
override suspend fun getLocationRegions(): Flow<NetworkResult<List<String>>> = | ||
handleNetworkCall( | ||
networkCall = { | ||
dataSource.getLocationRegions() | ||
}, | ||
mapToDomain = { it.map { regionName -> regionName } } | ||
) | ||
|
||
override suspend fun getLocationsByRegion(regionName: String): Flow<NetworkResult<List<Location>>> = | ||
handleNetworkCall( | ||
networkCall = { | ||
dataSource.getLocationsByRegion(regionName = regionName) | ||
}, | ||
mapToDomain = { it.map { data -> data.toDomain } } | ||
) | ||
} |
2 changes: 1 addition & 1 deletion
2
...om/moon/company/SearchCompaniesUseCase.kt → ...m/weave/company/SearchCompaniesUseCase.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
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 @@ | ||
/build |
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 @@ | ||
plugins { | ||
id("java-library") | ||
alias(libs.plugins.jetbrains.kotlin.jvm) | ||
} | ||
|
||
java { | ||
sourceCompatibility = JavaVersion.VERSION_17 | ||
targetCompatibility = JavaVersion.VERSION_17 | ||
} | ||
|
||
dependencies { | ||
implementation(project(":domain")) | ||
implementation(project(":core:model")) | ||
implementation(libs.kotlinx.coroutines.core) | ||
implementation(libs.javax.inject) | ||
} |
13 changes: 13 additions & 0 deletions
13
3days/domain/location/src/main/java/com/weave/location/GetLocationRegionsUseCase.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,13 @@ | ||
package com.weave.location | ||
|
||
import com.weave.domain.repository.LocationRepository | ||
import com.weave.model.network.NetworkResult | ||
import kotlinx.coroutines.flow.Flow | ||
import javax.inject.Inject | ||
|
||
class GetLocationRegionsUseCase @Inject constructor( | ||
private val repository: LocationRepository | ||
) { | ||
suspend operator fun invoke(): Flow<NetworkResult<List<String>>> = | ||
repository.getLocationRegions() | ||
} |
14 changes: 14 additions & 0 deletions
14
3days/domain/location/src/main/java/com/weave/location/GetLocationsByRegionUseCase.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.weave.location | ||
|
||
import com.weave.domain.repository.LocationRepository | ||
import com.weave.model.domain.myprofile.Location | ||
import com.weave.model.network.NetworkResult | ||
import kotlinx.coroutines.flow.Flow | ||
import javax.inject.Inject | ||
|
||
class GetLocationsByRegionUseCase @Inject constructor( | ||
private val repository: LocationRepository | ||
) { | ||
suspend operator fun invoke(regionName: String): Flow<NetworkResult<List<Location>>> = | ||
repository.getLocationsByRegion(regionName) | ||
} |
12 changes: 12 additions & 0 deletions
12
3days/domain/src/main/java/com/weave/domain/repository/LocationRepository.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.weave.domain.repository | ||
|
||
import com.weave.model.domain.myprofile.Location | ||
import com.weave.model.network.NetworkResult | ||
import kotlinx.coroutines.flow.Flow | ||
|
||
interface LocationRepository { | ||
|
||
suspend fun getLocationRegions(): Flow<NetworkResult<List<String>>> | ||
|
||
suspend fun getLocationsByRegion(regionName: String): Flow<NetworkResult<List<Location>>> | ||
} |
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
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
Oops, something went wrong.