-
Notifications
You must be signed in to change notification settings - Fork 2
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
[faet] 기존단체입장 초대코드 api 통신 #108
Changes from 9 commits
0eeb106
7ca7341
79e2b4b
16768eb
6300593
3f79523
d9f531c
ffeadc2
6fbc26e
e00794d
b419ce8
e4db7be
aa1b8f5
bbc1948
7677a51
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
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, | ||
code: RequestJoinGroupCodeDto | ||
): BaseResponse<ResponseJoinGroupCodeDto> | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
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, | ||
code: RequestJoinGroupCodeDto | ||
): BaseResponse<ResponseJoinGroupCodeDto> = | ||
joinGroupService.postJoinGroupCode(teamId = teamId, code = code) | ||
} |
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. RequestJoinGroupCodeEntityMapper |
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 | ||
) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package org.sopt.pingle.data.model.remote.request | ||
|
||
import kotlinx.serialization.SerialName | ||
import kotlinx.serialization.Serializable | ||
import org.sopt.pingle.domain.model.RequestJoinGroupCodeEntity | ||
|
||
@Serializable | ||
data class RequestJoinGroupCodeDto( | ||
@SerialName("code") | ||
val code: String | ||
) { | ||
fun toRequestJoinGroupCode() = RequestJoinGroupCodeEntity( | ||
code = this.code | ||
) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 이거 사용 되나요? 사용되지 않는다면 지워줍시다 |
||
} |
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 | ||
) | ||
} |
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 | ||
) | ||
} |
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, | ||
code: RequestJoinGroupCodeEntity | ||
): Flow<ResponseJoinGroupCodeEntity> = flow { | ||
val result = runCatching { | ||
joinGroupRemoteDataSource.postJoinGroupCode( | ||
teamId = teamId, | ||
code = code.toRequestJoinGroupCode() | ||
).data.toResponseJoinGroupCode() | ||
} | ||
emit(result.getOrThrow()) | ||
} | ||
} |
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 code: RequestJoinGroupCodeDto | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
): BaseResponse<ResponseJoinGroupCodeDto> | ||||||
|
||||||
companion object { | ||||||
const val VERSION = "v1" | ||||||
const val TEAMS = "teams" | ||||||
const val TEAM_ID = "teamId" | ||||||
const val REGISTER = "register" | ||||||
} | ||||||
} |
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 아 이거 네이밍 기깔나는 거 없낭 ㅋ |
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 | ||
) |
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 | ||
) |
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, | ||
code: RequestJoinGroupCodeEntity | ||
): Flow<ResponseJoinGroupCodeEntity> | ||
} |
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) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
선생님 수정 부탁드려염 ~