-
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.
Merge pull request #65 from YAPP-Github/feature/TNT-115
[TNT-115] 트레이너, 트레이니 연결 기능 구현
- Loading branch information
Showing
55 changed files
with
945 additions
and
368 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
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
11 changes: 11 additions & 0 deletions
11
data/network/src/main/java/co/kr/data/network/model/ConnectRequest.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 co.kr.data.network.model | ||
|
||
import kotlinx.serialization.Serializable | ||
|
||
@Serializable | ||
data class ConnectRequest( | ||
val invitationCode: String, | ||
val startDate: String, | ||
val totalPtCount: Int, | ||
val finishedPtCount: Int, | ||
) |
20 changes: 20 additions & 0 deletions
20
data/network/src/main/java/co/kr/data/network/model/ConnectRequestResponse.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,20 @@ | ||
package co.kr.data.network.model | ||
|
||
import co.kr.tnt.domain.model.ConnectRequestResult | ||
import kotlinx.serialization.Serializable | ||
|
||
@Serializable | ||
data class ConnectRequestResponse( | ||
val trainerName: String, | ||
val traineeName: String, | ||
val trainerProfileImageUrl: String, | ||
val traineeProfileImageUrl: String, | ||
) | ||
|
||
fun ConnectRequestResponse.toDomain(): ConnectRequestResult = | ||
ConnectRequestResult( | ||
trainerName = trainerName, | ||
traineeName = traineeName, | ||
trainerImage = trainerProfileImageUrl, | ||
traineeImage = traineeProfileImageUrl, | ||
) |
30 changes: 30 additions & 0 deletions
30
data/network/src/main/java/co/kr/data/network/model/ConnectedTraineeResponse.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 co.kr.data.network.model | ||
|
||
import co.kr.tnt.domain.model.ConnectedResult | ||
import kotlinx.serialization.Serializable | ||
|
||
@Serializable | ||
data class ConnectedTraineeResponse( | ||
val trainerName: String, | ||
val traineeName: String, | ||
val trainerProfileImageUrl: String?, | ||
val traineeProfileImageUrl: String?, | ||
val traineeAge: Int, | ||
val height: Double, | ||
val weight: Double, | ||
val ptGoal: String, | ||
val cautionNote: String?, | ||
) | ||
|
||
fun ConnectedTraineeResponse.toDomain(): ConnectedResult = | ||
ConnectedResult( | ||
trainerName = trainerName, | ||
traineeName = traineeName, | ||
trainerImage = trainerProfileImageUrl, | ||
traineeImage = traineeProfileImageUrl, | ||
age = traineeAge, | ||
height = height, | ||
weight = weight, | ||
ptGoal = ptGoal, | ||
cautionNote = cautionNote, | ||
) |
15 changes: 15 additions & 0 deletions
15
data/network/src/main/java/co/kr/data/network/model/InviteCodeResponse.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,15 @@ | ||
package co.kr.data.network.model | ||
|
||
import co.kr.tnt.domain.model.InviteCodeResult | ||
import kotlinx.serialization.Serializable | ||
|
||
@Serializable | ||
data class InviteCodeResponse( | ||
val invitationCode: String, | ||
) | ||
|
||
fun InviteCodeResponse.toDomain(): InviteCodeResult { | ||
return InviteCodeResult( | ||
invitationCode = invitationCode, | ||
) | ||
} |
8 changes: 8 additions & 0 deletions
8
data/network/src/main/java/co/kr/data/network/model/VerifyCodeResponse.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 co.kr.data.network.model | ||
|
||
import kotlinx.serialization.Serializable | ||
|
||
@Serializable | ||
data class VerifyCodeResponse( | ||
val isVerified: Boolean, | ||
) |
33 changes: 33 additions & 0 deletions
33
data/network/src/main/java/co/kr/data/network/service/ApiService.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,31 +1,64 @@ | ||
package co.kr.data.network.service | ||
|
||
import co.kr.data.network.model.CheckSessionResponse | ||
import co.kr.data.network.model.ConnectRequest | ||
import co.kr.data.network.model.ConnectRequestResponse | ||
import co.kr.data.network.model.ConnectedTraineeResponse | ||
import co.kr.data.network.model.InviteCodeResponse | ||
import co.kr.data.network.model.LoginRequest | ||
import co.kr.data.network.model.LoginResponse | ||
import co.kr.data.network.model.SignUpResponse | ||
import co.kr.data.network.model.VerifyCodeResponse | ||
import co.kr.data.network.util.WithoutSessionCheckPath.CHECK_SESSION_PATH | ||
import okhttp3.MultipartBody | ||
import okhttp3.RequestBody | ||
import retrofit2.http.Body | ||
import retrofit2.http.GET | ||
import retrofit2.http.Multipart | ||
import retrofit2.http.POST | ||
import retrofit2.http.PUT | ||
import retrofit2.http.Part | ||
import retrofit2.http.Path | ||
import retrofit2.http.Query | ||
|
||
interface ApiService { | ||
@GET(CHECK_SESSION_PATH) | ||
suspend fun getCheckSession(): CheckSessionResponse | ||
|
||
// Login | ||
@POST("/login") | ||
suspend fun postLogin( | ||
@Body request: LoginRequest, | ||
): LoginResponse | ||
|
||
// SignUp | ||
@Multipart | ||
@POST("/members/sign-up") | ||
suspend fun postSignUp( | ||
@Part profileImage: MultipartBody.Part?, | ||
@Part("request") request: RequestBody, | ||
): SignUpResponse | ||
|
||
// Connect | ||
@GET("/trainers/invitation-code") | ||
suspend fun getInviteCode(): InviteCodeResponse | ||
|
||
@PUT("/trainers/invitation-code/reissue") | ||
suspend fun regenerateInviteCode(): InviteCodeResponse | ||
|
||
@GET("/trainers/invitation-code/verify/{code}") | ||
suspend fun getVerifyInviteCode( | ||
@Path("code") code: String, | ||
): VerifyCodeResponse | ||
|
||
@POST("/trainees/connect-trainer") | ||
suspend fun postConnectRequest( | ||
@Body request: ConnectRequest, | ||
): ConnectRequestResponse | ||
|
||
@GET("/trainers/first-connected-trainee") | ||
suspend fun getConnectedTraineeInfo( | ||
@Query("trainerId") trainerId: String, | ||
@Query("traineeId") traineeId: String, | ||
): ConnectedTraineeResponse | ||
} |
43 changes: 43 additions & 0 deletions
43
data/network/src/main/java/co/kr/data/network/source/ConnectRemoteDataSource.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,43 @@ | ||
package co.kr.data.network.source | ||
|
||
import co.kr.data.network.model.ConnectRequest | ||
import co.kr.data.network.model.ConnectRequestResponse | ||
import co.kr.data.network.model.ConnectedTraineeResponse | ||
import co.kr.data.network.model.InviteCodeResponse | ||
import co.kr.data.network.model.VerifyCodeResponse | ||
import co.kr.data.network.service.ApiService | ||
import co.kr.data.network.util.networkHandler | ||
import javax.inject.Inject | ||
import javax.inject.Singleton | ||
|
||
@Singleton | ||
class ConnectRemoteDataSource @Inject constructor( | ||
private val apiService: ApiService, | ||
) { | ||
suspend fun getInviteCode(): InviteCodeResponse = networkHandler { | ||
apiService.getInviteCode() | ||
} | ||
|
||
suspend fun regenerateInviteCode(): InviteCodeResponse = networkHandler { | ||
apiService.regenerateInviteCode() | ||
} | ||
|
||
suspend fun getVerifyInviteCode(code: String): VerifyCodeResponse = networkHandler { | ||
apiService.getVerifyInviteCode(code = code) | ||
} | ||
|
||
suspend fun connectRequest(connectRequest: ConnectRequest): ConnectRequestResponse = | ||
networkHandler { | ||
apiService.postConnectRequest(request = connectRequest) | ||
} | ||
|
||
suspend fun getConnectedTraineeInfo( | ||
trainerId: String, | ||
traineeId: String, | ||
): ConnectedTraineeResponse = networkHandler { | ||
apiService.getConnectedTraineeInfo( | ||
trainerId = trainerId, | ||
traineeId = traineeId, | ||
) | ||
} | ||
} |
60 changes: 60 additions & 0 deletions
60
data/repository/src/main/java/co/kr/data/repository/ConnectRepositoryImpl.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,60 @@ | ||
package co.kr.data.repository | ||
|
||
import co.kr.data.network.model.ConnectRequest | ||
import co.kr.data.network.model.toDomain | ||
import co.kr.data.network.source.ConnectRemoteDataSource | ||
import co.kr.tnt.domain.model.ConnectRequestResult | ||
import co.kr.tnt.domain.model.ConnectedResult | ||
import co.kr.tnt.domain.model.InviteCodeResult | ||
import co.kr.tnt.domain.repository.ConnectRepository | ||
import javax.inject.Inject | ||
|
||
class ConnectRepositoryImpl @Inject constructor( | ||
private val connectRemoteDataSource: ConnectRemoteDataSource, | ||
) : ConnectRepository { | ||
override suspend fun getInviteCode(): InviteCodeResult { | ||
val response = connectRemoteDataSource.getInviteCode() | ||
|
||
return response.toDomain() | ||
} | ||
|
||
override suspend fun regenerateInviteCode(): InviteCodeResult { | ||
val response = connectRemoteDataSource.regenerateInviteCode() | ||
|
||
return response.toDomain() | ||
} | ||
|
||
override suspend fun getVerifyInviteCode(code: String): Boolean { | ||
val response = connectRemoteDataSource.getVerifyInviteCode(code = code) | ||
|
||
return response.isVerified | ||
} | ||
|
||
override suspend fun connectRequest( | ||
invitationCode: String, | ||
startDate: String, | ||
totalSession: Int, | ||
completedSession: Int, | ||
): ConnectRequestResult { | ||
val response = connectRemoteDataSource.connectRequest( | ||
connectRequest = ConnectRequest( | ||
invitationCode = invitationCode, | ||
startDate = startDate, | ||
totalPtCount = totalSession, | ||
finishedPtCount = completedSession, | ||
), | ||
) | ||
return response.toDomain() | ||
} | ||
|
||
override suspend fun getConnectedTraineeInfo( | ||
trainerId: String, | ||
traineeId: String, | ||
): ConnectedResult { | ||
val response = connectRemoteDataSource.getConnectedTraineeInfo( | ||
trainerId = trainerId, | ||
traineeId = traineeId, | ||
) | ||
return response.toDomain() | ||
} | ||
} |
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
8 changes: 8 additions & 0 deletions
8
domain/src/main/java/co/kr/tnt/domain/model/ConnectRequestResult.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 co.kr.tnt.domain.model | ||
|
||
data class ConnectRequestResult( | ||
val trainerName: String, | ||
val traineeName: String, | ||
val trainerImage: String, | ||
val traineeImage: String, | ||
) |
Oops, something went wrong.