-
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 pull request #108 from TeamPINGLE/faet-join-group-code-api
[faet] 기존단체입장 초대코드 api 통신
- Loading branch information
Showing
23 changed files
with
396 additions
and
71 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
14 changes: 14 additions & 0 deletions
14
app/src/main/java/org/sopt/pingle/data/datasource/remote/JoinGroupRemoteDataSource.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 org.sopt.pingle.data.datasource.remote | ||
|
||
import org.sopt.pingle.data.model.remote.request.RequestJoinGroupCodeDto | ||
import org.sopt.pingle.data.model.remote.response.ResponseJoinGroupCodeDto | ||
import org.sopt.pingle.data.model.remote.response.ResponseJoinGroupInfoDto | ||
import org.sopt.pingle.util.base.BaseResponse | ||
|
||
interface JoinGroupRemoteDataSource { | ||
suspend fun getJoinGroupInfo(teamId: Int): BaseResponse<ResponseJoinGroupInfoDto> | ||
suspend fun postJoinGroupCode( | ||
teamId: Int, | ||
requestJoinGroupCode: RequestJoinGroupCodeDto | ||
): BaseResponse<ResponseJoinGroupCodeDto> | ||
} |
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
25 changes: 25 additions & 0 deletions
25
...src/main/java/org/sopt/pingle/data/datasourceimpl/remote/JoinGroupRemoteDataSourceImpl.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,25 @@ | ||
package org.sopt.pingle.data.datasourceimpl.remote | ||
|
||
import javax.inject.Inject | ||
import org.sopt.pingle.data.datasource.remote.JoinGroupRemoteDataSource | ||
import org.sopt.pingle.data.model.remote.request.RequestJoinGroupCodeDto | ||
import org.sopt.pingle.data.model.remote.response.ResponseJoinGroupCodeDto | ||
import org.sopt.pingle.data.model.remote.response.ResponseJoinGroupInfoDto | ||
import org.sopt.pingle.data.service.JoinGroupService | ||
import org.sopt.pingle.util.base.BaseResponse | ||
|
||
class JoinGroupRemoteDataSourceImpl @Inject constructor( | ||
private val joinGroupService: JoinGroupService | ||
) : JoinGroupRemoteDataSource { | ||
override suspend fun getJoinGroupInfo(teamId: Int): BaseResponse<ResponseJoinGroupInfoDto> = | ||
joinGroupService.getJoinGroupInfo(teamId = teamId) | ||
|
||
override suspend fun postJoinGroupCode( | ||
teamId: Int, | ||
requestJoinGroupCode: RequestJoinGroupCodeDto | ||
): BaseResponse<ResponseJoinGroupCodeDto> = | ||
joinGroupService.postJoinGroupCode( | ||
teamId = teamId, | ||
requestJoinGroupCode = requestJoinGroupCode | ||
) | ||
} |
8 changes: 8 additions & 0 deletions
8
app/src/main/java/org/sopt/pingle/data/mapper/RequestJoinGroupCodeEntityMapper.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,8 @@ | ||
package org.sopt.pingle.data.mapper | ||
|
||
import org.sopt.pingle.data.model.remote.request.RequestJoinGroupCodeDto | ||
import org.sopt.pingle.domain.model.RequestJoinGroupCodeEntity | ||
|
||
fun RequestJoinGroupCodeEntity.toRequestJoinGroupCode() = RequestJoinGroupCodeDto( | ||
code = code | ||
) |
10 changes: 10 additions & 0 deletions
10
app/src/main/java/org/sopt/pingle/data/model/remote/request/RequestJoinGroupCodeDto.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.sopt.pingle.data.model.remote.request | ||
|
||
import kotlinx.serialization.SerialName | ||
import kotlinx.serialization.Serializable | ||
|
||
@Serializable | ||
data class RequestJoinGroupCodeDto( | ||
@SerialName("code") | ||
val code: String | ||
) |
38 changes: 11 additions & 27 deletions
38
app/src/main/java/org/sopt/pingle/data/model/remote/response/ResponseJoinGroupCodeDto.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 |
---|---|---|
@@ -1,34 +1,18 @@ | ||
package org.sopt.pingle.data.model.remote.response | ||
|
||
import kotlinx.serialization.SerialName | ||
import org.sopt.pingle.domain.model.JoinGroupCodeEntity | ||
import kotlinx.serialization.Serializable | ||
import org.sopt.pingle.domain.model.ResponseJoinGroupCodeEntity | ||
|
||
@Serializable | ||
data class ResponseJoinGroupCodeDto( | ||
@SerialName("code") | ||
val code: Int, | ||
@SerialName("message") | ||
val message: String, | ||
@SerialName("data") | ||
val data: Data | ||
@SerialName("id") | ||
val id: Int, | ||
@SerialName("name") | ||
val name: String | ||
) { | ||
data class Data( | ||
@SerialName("id") | ||
val id: Int, | ||
@SerialName("keyword") | ||
val keyword: String, | ||
@SerialName("name") | ||
val name: String, | ||
@SerialName("meetingCount") | ||
val meetingCount: Int, | ||
@SerialName("participantCount") | ||
val participantCount: Int | ||
) { | ||
fun toJoinGroupCodeEntity() = JoinGroupCodeEntity( | ||
id = this.id, | ||
keyword = this.keyword, | ||
name = this.name, | ||
meetingCount = this.meetingCount, | ||
participantCount = this.participantCount | ||
) | ||
} | ||
fun toResponseJoinGroupCode() = ResponseJoinGroupCodeEntity( | ||
id = id, | ||
name = name | ||
) | ||
} |
27 changes: 27 additions & 0 deletions
27
app/src/main/java/org/sopt/pingle/data/model/remote/response/ResponseJoinGroupInfoDto.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 org.sopt.pingle.data.model.remote.response | ||
|
||
import kotlinx.serialization.SerialName | ||
import kotlinx.serialization.Serializable | ||
import org.sopt.pingle.domain.model.JoinGroupInfoEntity | ||
|
||
@Serializable | ||
data class ResponseJoinGroupInfoDto( | ||
@SerialName("id") | ||
val id: Int, | ||
@SerialName("keyword") | ||
val keyword: String, | ||
@SerialName("name") | ||
val name: String, | ||
@SerialName("meetingCount") | ||
val meetingCount: Int, | ||
@SerialName("participantCount") | ||
val participantCount: Int | ||
) { | ||
fun toJoinGroupCodeEntity() = JoinGroupInfoEntity( | ||
id = this.id, | ||
keyword = this.keyword, | ||
name = this.name, | ||
meetingCount = this.meetingCount, | ||
participantCount = this.participantCount | ||
) | ||
} |
35 changes: 35 additions & 0 deletions
35
app/src/main/java/org/sopt/pingle/data/repository/JoinGroupRepositoryImpl.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,35 @@ | ||
package org.sopt.pingle.data.repository | ||
|
||
import javax.inject.Inject | ||
import kotlinx.coroutines.flow.Flow | ||
import kotlinx.coroutines.flow.flow | ||
import org.sopt.pingle.data.datasource.remote.JoinGroupRemoteDataSource | ||
import org.sopt.pingle.data.mapper.toRequestJoinGroupCode | ||
import org.sopt.pingle.domain.model.JoinGroupInfoEntity | ||
import org.sopt.pingle.domain.model.RequestJoinGroupCodeEntity | ||
import org.sopt.pingle.domain.model.ResponseJoinGroupCodeEntity | ||
import org.sopt.pingle.domain.repository.JoinGroupRepository | ||
|
||
class JoinGroupRepositoryImpl @Inject constructor( | ||
private val joinGroupRemoteDataSource: JoinGroupRemoteDataSource | ||
) : JoinGroupRepository { | ||
override fun getJoinGroupInfo(teamId: Int): Flow<JoinGroupInfoEntity> = flow { | ||
val result = runCatching { | ||
joinGroupRemoteDataSource.getJoinGroupInfo(teamId = teamId).data.toJoinGroupCodeEntity() | ||
} | ||
emit(result.getOrThrow()) | ||
} | ||
|
||
override fun postJoinGroupCode( | ||
teamId: Int, | ||
requestJoinGroupCode: RequestJoinGroupCodeEntity | ||
): Flow<ResponseJoinGroupCodeEntity> = flow { | ||
val result = runCatching { | ||
joinGroupRemoteDataSource.postJoinGroupCode( | ||
teamId = teamId, | ||
requestJoinGroupCode = requestJoinGroupCode.toRequestJoinGroupCode() | ||
).data.toResponseJoinGroupCode() | ||
} | ||
emit(result.getOrThrow()) | ||
} | ||
} |
30 changes: 30 additions & 0 deletions
30
app/src/main/java/org/sopt/pingle/data/service/JoinGroupService.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,30 @@ | ||
package org.sopt.pingle.data.service | ||
|
||
import org.sopt.pingle.data.model.remote.request.RequestJoinGroupCodeDto | ||
import org.sopt.pingle.data.model.remote.response.ResponseJoinGroupCodeDto | ||
import org.sopt.pingle.data.model.remote.response.ResponseJoinGroupInfoDto | ||
import org.sopt.pingle.util.base.BaseResponse | ||
import retrofit2.http.Body | ||
import retrofit2.http.GET | ||
import retrofit2.http.POST | ||
import retrofit2.http.Path | ||
|
||
interface JoinGroupService { | ||
@GET("$VERSION/$TEAMS/{$TEAM_ID}") | ||
suspend fun getJoinGroupInfo( | ||
@Path("$TEAM_ID") teamId: Int | ||
): BaseResponse<ResponseJoinGroupInfoDto> | ||
|
||
@POST("$VERSION/$TEAMS/{$TEAM_ID}/$REGISTER") | ||
suspend fun postJoinGroupCode( | ||
@Path("$TEAM_ID") teamId: Int, | ||
@Body requestJoinGroupCode: RequestJoinGroupCodeDto | ||
): BaseResponse<ResponseJoinGroupCodeDto> | ||
|
||
companion object { | ||
const val VERSION = "v1" | ||
const val TEAMS = "teams" | ||
const val TEAM_ID = "teamId" | ||
const val REGISTER = "register" | ||
} | ||
} |
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
2 changes: 1 addition & 1 deletion
2
...ingle/domain/model/JoinGroupCodeEntity.kt → ...ingle/domain/model/JoinGroupInfoEntity.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
5 changes: 5 additions & 0 deletions
5
app/src/main/java/org/sopt/pingle/domain/model/RequestJoinGroupCodeEntity.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,5 @@ | ||
package org.sopt.pingle.domain.model | ||
|
||
class RequestJoinGroupCodeEntity( | ||
val code: String | ||
) |
6 changes: 6 additions & 0 deletions
6
app/src/main/java/org/sopt/pingle/domain/model/ResponseJoinGroupCodeEntity.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,6 @@ | ||
package org.sopt.pingle.domain.model | ||
|
||
data class ResponseJoinGroupCodeEntity( | ||
val id: Int, | ||
val name: String | ||
) |
14 changes: 14 additions & 0 deletions
14
app/src/main/java/org/sopt/pingle/domain/repository/JoinGroupRepository.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 org.sopt.pingle.domain.repository | ||
|
||
import kotlinx.coroutines.flow.Flow | ||
import org.sopt.pingle.domain.model.JoinGroupInfoEntity | ||
import org.sopt.pingle.domain.model.RequestJoinGroupCodeEntity | ||
import org.sopt.pingle.domain.model.ResponseJoinGroupCodeEntity | ||
|
||
interface JoinGroupRepository { | ||
fun getJoinGroupInfo(teamId: Int): Flow<JoinGroupInfoEntity> | ||
fun postJoinGroupCode( | ||
teamId: Int, | ||
requestJoinGroupCode: RequestJoinGroupCodeEntity | ||
): Flow<ResponseJoinGroupCodeEntity> | ||
} |
12 changes: 12 additions & 0 deletions
12
app/src/main/java/org/sopt/pingle/domain/usecase/GetJoinGroupInfoUseCase.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.sopt.pingle.domain.usecase | ||
|
||
import kotlinx.coroutines.flow.Flow | ||
import org.sopt.pingle.domain.model.JoinGroupInfoEntity | ||
import org.sopt.pingle.domain.repository.JoinGroupRepository | ||
|
||
class GetJoinGroupInfoUseCase( | ||
private val joinGroupRepository: JoinGroupRepository | ||
) { | ||
operator fun invoke(teamId: Int): Flow<JoinGroupInfoEntity> = | ||
joinGroupRepository.getJoinGroupInfo(teamId = teamId) | ||
} |
Oops, something went wrong.