-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'feat/group_select' into develop
- Loading branch information
Showing
30 changed files
with
729 additions
and
63 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
10 changes: 10 additions & 0 deletions
10
data/src/main/java/org/gdsc/data/datasource/GroupDataSource.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,10 @@ | ||
package org.gdsc.data.datasource | ||
|
||
import org.gdsc.domain.model.response.Group | ||
|
||
|
||
interface GroupDataSource { | ||
suspend fun getMyGroups(): List<Group> | ||
|
||
suspend fun selectGroup(groupId: Int): String | ||
} |
32 changes: 32 additions & 0 deletions
32
data/src/main/java/org/gdsc/data/datasource/GroupDataSourceImpl.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,32 @@ | ||
package org.gdsc.data.datasource | ||
|
||
import android.util.Log | ||
import org.gdsc.data.network.GroupAPI | ||
import org.gdsc.domain.model.response.Group | ||
import javax.inject.Inject | ||
|
||
class GroupDataSourceImpl @Inject constructor( | ||
private val groupAPI: GroupAPI, | ||
): GroupDataSource { | ||
override suspend fun getMyGroups(): List<Group> { | ||
runCatching { | ||
groupAPI.getMyGroups() | ||
}.onSuccess { | ||
return it.data | ||
}.onFailure { | ||
return emptyList() | ||
} | ||
return emptyList() | ||
} | ||
|
||
override suspend fun selectGroup(groupId: Int): String { | ||
runCatching { | ||
groupAPI.selectGroup(groupId) | ||
}.onSuccess { | ||
return it.data | ||
}.onFailure { | ||
return "" | ||
} | ||
return "" | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package org.gdsc.data.di | ||
|
||
import dagger.Binds | ||
import dagger.Module | ||
import dagger.hilt.InstallIn | ||
import dagger.hilt.components.SingletonComponent | ||
import org.gdsc.data.datasource.GroupDataSource | ||
import org.gdsc.data.datasource.GroupDataSourceImpl | ||
import org.gdsc.data.repository.GroupRepositoryImpl | ||
import org.gdsc.domain.repository.GroupRepository | ||
import javax.inject.Singleton | ||
|
||
|
||
@Module | ||
@InstallIn(SingletonComponent::class) | ||
abstract class GroupModule { | ||
|
||
@Singleton | ||
@Binds | ||
abstract fun bindGroupDataSource(groupDataSourceImpl: GroupDataSourceImpl): GroupDataSource | ||
|
||
@Singleton | ||
@Binds | ||
abstract fun bindGroupRepository(groupRepositoryImpl: GroupRepositoryImpl): GroupRepository | ||
} |
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 org.gdsc.data.model | ||
|
||
import com.google.gson.annotations.SerializedName | ||
|
||
data class Group( | ||
@SerializedName("groupId") val groupId: Int, | ||
@SerializedName("groupIntroduce") val groupIntroduce: String, | ||
@SerializedName("groupProfileImageUrl") val groupProfileImageUrl: String, | ||
@SerializedName("groupBackgroundImageUrl") val groupBackgroundImageUrl: String, | ||
@SerializedName("memberCnt") val memberCnt: Int, | ||
@SerializedName("restaurantCnt") val restaurantCnt: Int, | ||
@SerializedName("privateGroup") val privateGroup: Boolean, | ||
@SerializedName("isSelected") val isSelected: Boolean, | ||
) |
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,19 @@ | ||
package org.gdsc.data.network | ||
|
||
import org.gdsc.data.model.Response | ||
import org.gdsc.domain.model.response.Group | ||
import retrofit2.http.GET | ||
import retrofit2.http.POST | ||
import retrofit2.http.Path | ||
|
||
interface GroupAPI { | ||
|
||
@GET("api/v1/group/my") | ||
suspend fun getMyGroups(): Response<List<Group>> | ||
|
||
@POST("api/v1/group/{groupId}/select") | ||
suspend fun selectGroup( | ||
@Path("groupId") groupId: Int | ||
): Response<String> | ||
|
||
} |
18 changes: 18 additions & 0 deletions
18
data/src/main/java/org/gdsc/data/repository/GroupRepositoryImpl.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,18 @@ | ||
package org.gdsc.data.repository | ||
|
||
import org.gdsc.data.datasource.GroupDataSource | ||
import org.gdsc.domain.model.response.Group | ||
import org.gdsc.domain.repository.GroupRepository | ||
import javax.inject.Inject | ||
|
||
class GroupRepositoryImpl @Inject constructor( | ||
private val groupDataSource: GroupDataSource | ||
): GroupRepository { | ||
override suspend fun getMyGroups(): List<Group> { | ||
return groupDataSource.getMyGroups() | ||
} | ||
|
||
override suspend fun selectGroup(groupId: Int): String { | ||
return groupDataSource.selectGroup(groupId) | ||
} | ||
} |
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,6 @@ | ||
package org.gdsc.domain.model | ||
|
||
data class ScreenLocation( | ||
val startLocation: Location, | ||
val endLocation: 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
13 changes: 13 additions & 0 deletions
13
domain/src/main/java/org/gdsc/domain/model/response/Group.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 org.gdsc.domain.model.response | ||
|
||
data class Group( | ||
val groupId: Int, | ||
val groupName: String, | ||
val groupIntroduce: String, | ||
val groupProfileImageUrl: String, | ||
val groupBackgroundImageUrl: String, | ||
val memberCnt: Int, | ||
val restaurantCnt: Int, | ||
val privateGroup: Boolean, | ||
val isSelected: Boolean, | ||
) |
9 changes: 9 additions & 0 deletions
9
domain/src/main/java/org/gdsc/domain/repository/GroupRepository.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 org.gdsc.domain.repository | ||
|
||
import org.gdsc.domain.model.response.Group | ||
|
||
interface GroupRepository { | ||
suspend fun getMyGroups(): List<Group> | ||
|
||
suspend fun selectGroup(groupId: Int): String | ||
} |
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
10 changes: 10 additions & 0 deletions
10
domain/src/main/java/org/gdsc/domain/usecase/GetMyGroupUseCase.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,10 @@ | ||
package org.gdsc.domain.usecase | ||
|
||
import org.gdsc.domain.repository.GroupRepository | ||
import javax.inject.Inject | ||
|
||
class GetMyGroupUseCase @Inject constructor( | ||
private val groupRepository: GroupRepository | ||
){ | ||
suspend operator fun invoke() = groupRepository.getMyGroups() | ||
} |
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
12 changes: 12 additions & 0 deletions
12
domain/src/main/java/org/gdsc/domain/usecase/PostSelectGroupUseCase.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 org.gdsc.domain.usecase | ||
|
||
import org.gdsc.domain.repository.GroupRepository | ||
import javax.inject.Inject | ||
|
||
class PostSelectGroupUseCase @Inject constructor( | ||
private val groupRepository: GroupRepository | ||
) { | ||
suspend operator fun invoke(groupId: Int): String { | ||
return groupRepository.selectGroup(groupId) | ||
} | ||
} |
Oops, something went wrong.