-
Notifications
You must be signed in to change notification settings - Fork 0
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
[TNT-115] 트레이너, 트레이니 연결 기능 구현 #65
Merged
Merged
Changes from 19 commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
4e552e6
[TNT-115] feat: 트레이너 초대코드 확인 API 호출 구현
SeonJeongk 6324b6e
[TNT-115] feat: 트레이너 초대코드 확인 API 연동
SeonJeongk 47beeb2
[TNT-115] feat: 트레이너 초대코드 재발급 API 호출 구현
SeonJeongk e81fc46
[TNT-115] feat: 트레이너 초대코드 재발급 API 연동
SeonJeongk edc4ec2
[TNT-115] feat: 트레이너 초대코드 인증 API 호출 구현
SeonJeongk 6aaebac
[TNT-115] feat: 트레이너 초대코드 인증 API 연동
SeonJeongk acc2217
[TNT-115] design: Dialog 버튼 색 수정
SeonJeongk ae0ef96
[TNT-115] fix: OnNextClick으로 통일
SeonJeongk c4c13f2
[TNT-115] feat: PT 수업정보 에러 문구 추가
SeonJeongk 53f5651
[TNT-115] feat: 트레이너 연결 요청 API 호출 구현
SeonJeongk 71aa9ba
[TNT-115] feat: 트레이너 연결 요청 API 연동
SeonJeongk 6ce837f
[TNT-115] design: 트레이니 프로필 확인 화면 UI 수정
SeonJeongk 2a3cadd
[TNT-115] chore: read, write timeout 시간 연장
SeonJeongk e4bb950
[TNT-115] feat: UserLocalDataSource 생성
SeonJeongk e2c69a4
[TNT-115] feat: 연결된 트레이니 정보 최초로 불러오기 API 호출 구현
SeonJeongk b99dc86
[TNT-115] feat: 연결된 트레이니 정보 최초로 불러오기 API 연동
SeonJeongk 8ed2f4a
[TNT-115] fix: 화면 레이아웃 및 유효 조건 수정
SeonJeongk b23c0cc
[TNT-115] fix: 스트링 리소스명 겹치지 않도록 수정
SeonJeongk 510b623
[TNT-115] fix: LaunchEffect 의존성 변경
SeonJeongk b153325
[TNT-115] refactor: 구성 변경 시에도 트레이니 연결 상태가 유지되도록 개선
hoyahozz 8f4d833
[TNT-115] refactor: UserLocalDataSource 삭제 및 apiService 네이밍 수정
SeonJeongk 91f4f14
[TNT-115] refactor: 트레이너 초대 코드 불러오기 화면 trainer:invite 모듈로 분리
SeonJeongk 53f1096
[TNT-115] feat: 트레이니의 트레이너 연결 중단 Dialog 구현
SeonJeongk File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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 verifyInviteCode( | ||
@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 verifyInviteCode(code: String): VerifyCodeResponse = networkHandler { | ||
apiService.verifyInviteCode(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, | ||
) | ||
} | ||
} |
63 changes: 63 additions & 0 deletions
63
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,63 @@ | ||
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.data.storage.source.UserLocalDataSource | ||
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, | ||
private val userLocalDataSource: UserLocalDataSource, | ||
) : 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 verifyInviteCode(code: String): Boolean { | ||
val response = connectRemoteDataSource.verifyInviteCode(code = code) | ||
|
||
return response.isVerified | ||
} | ||
|
||
override suspend fun connectRequest( | ||
invitationCode: String, | ||
startDate: String, | ||
totalPtCount: Int, | ||
finishedPtCount: Int, | ||
): ConnectRequestResult { | ||
val response = connectRemoteDataSource.connectRequest( | ||
connectRequest = ConnectRequest( | ||
invitationCode = invitationCode, | ||
startDate = startDate, | ||
totalPtCount = totalPtCount, | ||
finishedPtCount = finishedPtCount, | ||
), | ||
) | ||
return response.toDomain() | ||
} | ||
|
||
override suspend fun getConnectedTraineeInfo(): ConnectedResult { | ||
// TODO trainerId, traineeId 저장하기 (FCM, 알림 화면) | ||
val trainerId = userLocalDataSource.getTrainerId() | ||
val traineeId = userLocalDataSource.getTraineeId() | ||
|
||
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
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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
접두사로 HTTP 메소드 적어두면 한 눈에 알아볼 수 있을 것 같습니다~