generated from 37-dive-sopt-android/DIVE-SOPT-ANDROID-TEMPLATE
-
Notifications
You must be signed in to change notification settings - Fork 0
[Week6] 6주차 과제 #11
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
[Week6] 6주차 과제 #11
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
b48b67d
:sparkles: [FEAT] (#10) OpenApi url 추가
seungjae708 07be08e
:sparkles: [FEAT] (#10) FriendListModel 구현
seungjae708 2455305
:sparkles: [FEAT] (#10) OpenApiDataSource, OpenApiDataSourceImpl 구현
seungjae708 cf0eb65
:sparkles: [FEAT] (#10) OpenApiService 구현
seungjae708 150ed58
:sparkles: [FEAT] (#10) OpenApiRepository, OpenApiRepositoryImpl 구현
seungjae708 b4ae17d
:sparkles: [FEAT] (#10) UserService에서 제거
seungjae708 b49d5c8
:sparkles: [FEAT] (#10) ServicePool,RepositoryModule 연결
seungjae708 104ded1
:sparkles: [FEAT] (#10) ViewModelFactory 연결
seungjae708 cc36f4d
:sparkles: [FEAT] (#10) FriendUiModel 구현
seungjae708 237446e
:sparkles: [FEAT] (#10) HomeViewModel 구현
seungjae708 5276d4f
:sparkles: [FEAT] (#10) HomeUiState 수정
seungjae708 36cb0aa
:sparkles: [FEAT] (#10) HomeScreen에 반영
seungjae708 dd574ab
:sparkles: [FEAT] (#10) ViewModelFactory 수정으로 인해 추가
seungjae708 abf27b5
:sparkles: [FEAT] (#10) AsyncImage로 변경
seungjae708 9f23e81
:sparkles: [FEAT] (#10) SharedFlow (Side Effect) 사용
seungjae708 f137327
:recycle: [REFACTOR] (#10) 코드리뷰 반영
seungjae708 1dd1f4d
:recycle: [REFACTOR] (#10) FakeAuthDataSourceImpl 적용
seungjae708 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
9 changes: 9 additions & 0 deletions
9
app/src/main/java/com/sopt/dive/data/datasource/OpenApiDataSource.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,9 @@ | ||
| package com.sopt.dive.data.datasource | ||
|
|
||
| import com.sopt.dive.data.dto.response.UserListResponseDto | ||
|
|
||
| interface OpenApiDataSource { | ||
| suspend fun getUsers( | ||
| page: Int | ||
| ): UserListResponseDto | ||
| } |
32 changes: 32 additions & 0 deletions
32
app/src/main/java/com/sopt/dive/data/datasourceimpl/FakeAuthDataSourceImpl.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,32 @@ | ||
| package com.sopt.dive.data.datasourceimpl | ||
|
|
||
| import com.sopt.dive.data.datasource.AuthDataSource | ||
| import com.sopt.dive.data.dto.request.LogInRequestDto | ||
| import com.sopt.dive.data.dto.response.BaseResponseDto | ||
| import com.sopt.dive.data.dto.response.LoginResponseDto | ||
|
|
||
| class FakeAuthDataSourceImpl : AuthDataSource { | ||
| override suspend fun postLogin(request: LogInRequestDto): BaseResponseDto<LoginResponseDto> { | ||
|
|
||
| return if (request.username == "seungjae" && request.password == "seungjae1234!") { | ||
| // 성공 응답 | ||
| BaseResponseDto( | ||
| success = true, | ||
| code = "200", | ||
| message = "로그인 성공 (Fake)", | ||
| data = LoginResponseDto( | ||
| userId = 10L, | ||
| message = "로그인 성공 (Fake)" | ||
| ) | ||
| ) | ||
| } else { | ||
| // 실패 응답 | ||
| BaseResponseDto( | ||
| success = false, | ||
| code = "400", | ||
| message = "아이디 또는 비밀번호가 올바르지 않습니다. (Fake)", | ||
| data = null | ||
| ) | ||
| } | ||
| } | ||
| } |
12 changes: 12 additions & 0 deletions
12
app/src/main/java/com/sopt/dive/data/datasourceimpl/OpenApiDataSourceImpl.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,12 @@ | ||
| package com.sopt.dive.data.datasourceimpl | ||
|
|
||
| import com.sopt.dive.data.datasource.OpenApiDataSource | ||
| import com.sopt.dive.data.dto.response.UserListResponseDto | ||
| import com.sopt.dive.data.service.OpenApiService | ||
|
|
||
| class OpenApiDataSourceImpl( | ||
| private val openApiService: OpenApiService | ||
| ) : OpenApiDataSource { | ||
| override suspend fun getUsers(page: Int): UserListResponseDto = | ||
| openApiService.getUsers(page = page) | ||
| } |
31 changes: 31 additions & 0 deletions
31
app/src/main/java/com/sopt/dive/data/model/FriendListModel.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,31 @@ | ||
| package com.sopt.dive.data.model | ||
|
|
||
| import com.sopt.dive.data.dto.response.UserListResponseDto | ||
| import com.sopt.dive.data.dto.response.UserResponseDto | ||
|
|
||
| data class FriendListModel( | ||
| val friendList: List<FriendModel> | ||
| ) | ||
|
|
||
| data class FriendModel( | ||
| val id: Int, | ||
| val email: String, | ||
| val firstName: String, | ||
| val lastName: String, | ||
| val avatar: String | ||
| ) | ||
|
|
||
| fun UserListResponseDto.toModel() = | ||
| FriendListModel( | ||
| friendList = this.data.map { it.toModel() } | ||
| ) | ||
|
|
||
| fun UserResponseDto.toModel() = | ||
| FriendModel( | ||
| id = this.id, | ||
| email = this.email, | ||
| firstName = this.firstName, | ||
| lastName = this.lastName, | ||
| avatar = this.avatar | ||
| ) | ||
|
|
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
9 changes: 9 additions & 0 deletions
9
app/src/main/java/com/sopt/dive/data/repository/OpenApiRepository.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,9 @@ | ||
| package com.sopt.dive.data.repository | ||
|
|
||
| import com.sopt.dive.data.model.FriendListModel | ||
|
|
||
| interface OpenApiRepository { | ||
| suspend fun getUsers( | ||
| page: Int | ||
| ): Result<FriendListModel> | ||
| } |
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
16 changes: 16 additions & 0 deletions
16
app/src/main/java/com/sopt/dive/data/repositoryimpl/OpenApiRepositoryImpl.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.sopt.dive.data.repositoryimpl | ||
|
|
||
| import com.sopt.dive.core.util.suspendRunCatching | ||
| import com.sopt.dive.data.datasource.OpenApiDataSource | ||
| import com.sopt.dive.data.model.FriendListModel | ||
| import com.sopt.dive.data.model.toModel | ||
| import com.sopt.dive.data.repository.OpenApiRepository | ||
|
|
||
| class OpenApiRepositoryImpl( | ||
| private val openApiDataSource: OpenApiDataSource | ||
| ) : OpenApiRepository { | ||
| override suspend fun getUsers(page: Int): Result<FriendListModel> = | ||
| suspendRunCatching { | ||
| openApiDataSource.getUsers(page = page).toModel() | ||
| } | ||
| } | ||
12 changes: 12 additions & 0 deletions
12
app/src/main/java/com/sopt/dive/data/service/OpenApiService.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,12 @@ | ||
| package com.sopt.dive.data.service | ||
|
|
||
| import com.sopt.dive.data.dto.response.UserListResponseDto | ||
| import retrofit2.http.GET | ||
| import retrofit2.http.Query | ||
|
|
||
| interface OpenApiService { | ||
| @GET("/api/users") | ||
| suspend fun getUsers( | ||
| @Query("page") page: Int = 2 | ||
| ): UserListResponseDto | ||
| } |
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.
이번 세미나에서 배운 Impl까지 벌써 활용하셨네요 !! 🤩