-
Notifications
You must be signed in to change notification settings - Fork 0
feat: 유저 프로필 조회 API 연동 #30
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
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
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 hidden or 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
7 changes: 7 additions & 0 deletions
7
.../data/api/src/main/kotlin/com/ninecraft/booket/core/data/api/repository/UserRepository.kt
This file contains hidden or 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,7 @@ | ||
| package com.ninecraft.booket.core.data.api.repository | ||
|
|
||
| import com.ninecraft.booket.core.model.UserProfileModel | ||
|
|
||
| interface UserRepository { | ||
| suspend fun getUserProfile(): Result<UserProfileModel> | ||
| } |
This file contains hidden or 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
core/data/impl/src/main/kotlin/com/ninecraft/booket/core/data/impl/mapper/ResponseToModel.kt
This file contains hidden or 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,11 +1,22 @@ | ||
| package com.ninecraft.booket.core.data.impl.mapper | ||
|
|
||
| import com.ninecraft.booket.core.model.LoginModel | ||
| import com.ninecraft.booket.core.model.UserProfileModel | ||
| import com.ninecraft.booket.core.network.response.LoginResponse | ||
| import com.ninecraft.booket.core.network.response.UserProfileResponse | ||
|
|
||
| internal fun LoginResponse.toModel(): LoginModel { | ||
| return LoginModel( | ||
| accessToken = accessToken, | ||
| refreshToken = refreshToken, | ||
| ) | ||
| } | ||
|
|
||
| internal fun UserProfileResponse.toModel(): UserProfileModel { | ||
| return UserProfileModel( | ||
| id = id, | ||
| email = email, | ||
| nickname = nickname, | ||
| provider = provider, | ||
| ) | ||
| } |
15 changes: 15 additions & 0 deletions
15
...l/src/main/kotlin/com/ninecraft/booket/core/data/impl/repository/DefaultUserRepository.kt
This file contains hidden or 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 com.ninecraft.booket.core.data.impl.repository | ||
|
|
||
| import com.ninecraft.booket.core.common.utils.runSuspendCatching | ||
| import com.ninecraft.booket.core.data.api.repository.UserRepository | ||
| import com.ninecraft.booket.core.data.impl.mapper.toModel | ||
| import com.ninecraft.booket.core.network.service.AuthService | ||
| import javax.inject.Inject | ||
|
|
||
| internal class DefaultUserRepository @Inject constructor( | ||
| private val authService: AuthService, | ||
| ) : UserRepository { | ||
| override suspend fun getUserProfile() = runSuspendCatching { | ||
| authService.getUserProfile().toModel() | ||
| } | ||
| } |
8 changes: 8 additions & 0 deletions
8
core/model/src/main/kotlin/com/ninecraft/booket/core/model/UserProfileModel.kt
This file contains hidden or 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 com.ninecraft.booket.core.model | ||
|
|
||
| data class UserProfileModel( | ||
| val id: String, | ||
| val email: String, | ||
| val nickname: String, | ||
| val provider: String, | ||
| ) |
16 changes: 16 additions & 0 deletions
16
...network/src/main/kotlin/com/ninecraft/booket/core/network/response/UserProfileResponse.kt
This file contains hidden or 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,16 @@ | ||
| package com.ninecraft.booket.core.network.response | ||
|
|
||
| import kotlinx.serialization.SerialName | ||
| import kotlinx.serialization.Serializable | ||
|
|
||
| @Serializable | ||
| data class UserProfileResponse( | ||
| @SerialName("id") | ||
| val id: String, | ||
| @SerialName("email") | ||
| val email: String, | ||
| @SerialName("nickname") | ||
| val nickname: String, | ||
| @SerialName("provider") | ||
| val provider: String, | ||
| ) |
5 changes: 5 additions & 0 deletions
5
core/network/src/main/kotlin/com/ninecraft/booket/core/network/service/AuthService.kt
This file contains hidden or 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,8 +1,13 @@ | ||
| package com.ninecraft.booket.core.network.service | ||
|
|
||
| import com.ninecraft.booket.core.network.response.UserProfileResponse | ||
| import retrofit2.http.GET | ||
| import retrofit2.http.POST | ||
|
|
||
| interface AuthService { | ||
| @POST("api/v1/auth/signout") | ||
| suspend fun logout() | ||
|
|
||
| @GET("api/v1/auth/me") | ||
| suspend fun getUserProfile(): UserProfileResponse | ||
| } |
This file contains hidden or 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 hidden or 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 hidden or 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.
로그인/로그아웃 관련 비즈니스 로직을
DefaultAuthRepository내부에서 처리하는건 어떻게 생각해? 개인적으로 서버통신&로컬토큰 처리까지 캡슐화하고 Presenter에서는 logout()/login()만 호출하는게 나을 것 같아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.
좋은 방향 같구만
Uh oh!
There was an error while loading. Please reload this page.
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.
@seoyoon513 근데 관련해서 고민을 해봐야할게
repository 에서 토큰 제거 처리를 한다는 것은 현재 구현 로직상
api 성공/실패 여부와 상관없이 로그아웃을 진행한다는 의미라, 로그아웃 기능 정책이 달라지는 거거든사실 로그아웃를 눌렀을때 API 호출이 실패(accessToken, refreshToken이 다 만료)하여 로그인 화면으로 이동하든, API 호출이 성공하여 로그인 화면으로 이동하든 결과만 놓고 보면 같은 것이라 기획적인 문제라고도 볼 수 있을 것 같은데(서버에서 토큰을 블랙리스트에 추가하는 여부만 다름), 이건 서버랑도 같이 얘기 나눠보면 좋을 것 같은 주제인것 같네
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.
오키 이건 이번주 팀세션 때 회원탈퇴랑 같이 얘기해보자