-
Notifications
You must be signed in to change notification settings - Fork 0
[Refactor] Response Handler 적용 #224 #235
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
+108
−285
Merged
Changes from 4 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
29fe7a7
Refactor: #224 HealthService API 응답 타입 변경
ikseong00 dfda6de
Feat: #224 Response<T> 확장함수 추가
ikseong00 b933484
Refactor: #224 Repository에 handleResponse() 확장함수 적용
ikseong00 63c8b36
Docs: #224 리팩토링 분석 문서 추가
ikseong00 6f6c831
Refactor: #224 API 응답 핸들러 적용
ikseong00 ef604fb
Refactor: #224 Unit 반환 API에 handleNullableResponse 적용
ikseong00 56e7c5a
Chore: #224 리팩토링 분석 문서 제거
ikseong00 78cc412
Refactor: logout 함수 리턴값 수정 #224
ikseong00 9ee66f2
Fix: #224 HomeSummary API 호출 시 예외 처리 적용
ikseong00 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
Large diffs are not rendered by default.
Oops, something went wrong.
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
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
44 changes: 7 additions & 37 deletions
44
app/src/main/java/com/konkuk/medicarecall/data/repositoryimpl/HomeRepositoryImpl.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,55 +1,25 @@ | ||
| package com.konkuk.medicarecall.data.repositoryimpl | ||
|
|
||
| import android.util.Log | ||
| import com.konkuk.medicarecall.data.api.elders.HomeService | ||
| import com.konkuk.medicarecall.data.dto.request.ImmediateCallRequestDto | ||
| import com.konkuk.medicarecall.data.dto.response.HomeResponseDto | ||
| import com.konkuk.medicarecall.data.repository.HomeRepository | ||
| import com.konkuk.medicarecall.data.util.handleResponse | ||
| import org.koin.core.annotation.Single | ||
|
|
||
| @Single | ||
| class HomeRepositoryImpl( | ||
| private val homeService: HomeService, | ||
| ) : HomeRepository { | ||
| override suspend fun requestImmediateCareCall( | ||
| elderId: Int, careCallOption: String, | ||
| elderId: Int, | ||
| careCallOption: String, | ||
| ): Result<Unit> = runCatching { | ||
| val response = homeService.requestImmediateCareCall( | ||
| homeService.requestImmediateCareCall( | ||
| ImmediateCallRequestDto(elderId, careCallOption), | ||
| ) | ||
| if (response.isSuccessful) { | ||
| Log.d( | ||
| "httplog", | ||
| "전화 걸림, 어르신: $Int, 시간: $careCallOption", | ||
| ) | ||
| } else { | ||
| Log.e( | ||
| "httplog", | ||
| "전화 걸기 실패: ${response.code}", | ||
| ) | ||
| error("Immediate care call failed with code=${response.code}") | ||
| } | ||
| ).handleResponse() | ||
| } | ||
|
|
||
| override suspend fun getHomeSummary(elderId: Int): HomeResponseDto { | ||
| // DTO만 반환 | ||
| Log.d("HomeRepo", "[REQ] elderId=$elderId") | ||
| val response = homeService.getHomeSummary(elderId) | ||
|
|
||
| if (!response.isSuccessful) { | ||
| error("Home summary fetch failed with code=${response.code}") | ||
| } | ||
|
|
||
| val res = response.body() | ||
| ?: error("Home summary response body is null") | ||
|
|
||
| val medicationStatus = res.medicationStatus | ||
| val meds = medicationStatus?.medicationList.orEmpty() | ||
| Log.d( | ||
| "HomeRepo", | ||
| "[RES] elderName=${res.elderName}, medsCount=${meds.size}, " + | ||
| "totalTaken=${medicationStatus?.totalTaken}, totalGoal=${medicationStatus?.totalGoal}", | ||
| ) | ||
| return res | ||
| } | ||
| override suspend fun getHomeSummary(elderId: Int): HomeResponseDto = | ||
| homeService.getHomeSummary(elderId).handleResponse() | ||
ikseong00 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| } | ||
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.
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.
Uh oh!
There was an error while loading. Please reload this page.