-
Notifications
You must be signed in to change notification settings - Fork 0
[FEAT/#76] 정보입력뷰 api 연결 #85
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
Changes from all commits
75793c9
dd39692
a765f39
fe0ce09
34ff267
fc7808c
6112d22
73f6fe3
f18c53f
37cec53
8686f6b
17f15dc
3fc46e7
3d173a3
7761fb6
2a72d45
5c4e32d
1eb0deb
8469849
86f78c8
1904cea
c5e3f98
5754243
671d003
bd235c7
7d2fba7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| package com.cherrish.android.data.model | ||
|
|
||
| import com.cherrish.android.data.remote.dto.request.OnboardingProfileRequestDto | ||
|
|
||
| data class OnboardingProfileRequestModel( | ||
| val name: String, | ||
| val age: Int | ||
| ) | ||
|
|
||
| fun OnboardingProfileRequestModel.toDto() = OnboardingProfileRequestDto( | ||
| name = this.name, | ||
| age = this.age | ||
| ) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| package com.cherrish.android.data.model | ||
|
|
||
| import com.cherrish.android.data.remote.dto.response.OnboardingProfileResponseDto | ||
|
|
||
| data class OnboardingProfileResponseModel( | ||
| val id: Long, | ||
| val name: String, | ||
| val date: String | ||
| ) | ||
|
|
||
| fun OnboardingProfileResponseDto.toModel() = OnboardingProfileResponseModel( | ||
| id = this.id, | ||
| name = this.name, | ||
| date = this.date | ||
| ) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| package com.cherrish.android.data.remote.datasource | ||
|
|
||
| import com.cherrish.android.core.network.BaseResponse | ||
| import com.cherrish.android.data.remote.dto.request.OnboardingProfileRequestDto | ||
| import com.cherrish.android.data.remote.dto.response.OnboardingProfileResponseDto | ||
|
|
||
| interface OnboardingProfileDataSource { | ||
| suspend fun postOnboardingProfile( | ||
| request: OnboardingProfileRequestDto | ||
| ): BaseResponse<OnboardingProfileResponseDto> | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| package com.cherrish.android.data.remote.datasourceimpl | ||
|
|
||
| import com.cherrish.android.core.network.BaseResponse | ||
| import com.cherrish.android.data.remote.datasource.OnboardingProfileDataSource | ||
| import com.cherrish.android.data.remote.dto.request.OnboardingProfileRequestDto | ||
| import com.cherrish.android.data.remote.dto.response.OnboardingProfileResponseDto | ||
| import com.cherrish.android.data.remote.service.OnboardingProfileService | ||
| import javax.inject.Inject | ||
|
|
||
| class OnboardingProfileDataSourceImpl @Inject constructor( | ||
| private val onboardingProfileService: OnboardingProfileService | ||
| ) : OnboardingProfileDataSource { | ||
| override suspend fun postOnboardingProfile( | ||
| request: OnboardingProfileRequestDto | ||
| ): BaseResponse<OnboardingProfileResponseDto> { | ||
| return onboardingProfileService.postOnboardingProfile(request) | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| package com.cherrish.android.data.remote.dto.request | ||
|
|
||
| import kotlinx.serialization.SerialName | ||
| import kotlinx.serialization.Serializable | ||
|
|
||
| @Serializable | ||
| data class OnboardingProfileRequestDto( | ||
| @SerialName("name") | ||
| val name: String, | ||
| @SerialName("age") | ||
| val age: Int | ||
| ) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| package com.cherrish.android.data.remote.dto.response | ||
|
|
||
| import kotlinx.serialization.SerialName | ||
| import kotlinx.serialization.Serializable | ||
|
|
||
| @Serializable | ||
| data class OnboardingProfileResponseDto( | ||
| @SerialName("id") | ||
| val id: Long, | ||
| @SerialName("name") | ||
| val name: String, | ||
| @SerialName("date") | ||
| val date: String | ||
| ) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| package com.cherrish.android.data.remote.service | ||
|
|
||
| import com.cherrish.android.core.network.BaseResponse | ||
| import com.cherrish.android.data.remote.dto.request.OnboardingProfileRequestDto | ||
| import com.cherrish.android.data.remote.dto.response.OnboardingProfileResponseDto | ||
| import retrofit2.http.Body | ||
| import retrofit2.http.POST | ||
|
|
||
| interface OnboardingProfileService { | ||
| @POST("api/onboarding/profiles") | ||
| suspend fun postOnboardingProfile( | ||
| @Body request: OnboardingProfileRequestDto | ||
| ): BaseResponse<OnboardingProfileResponseDto> | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| package com.cherrish.android.data.repository | ||
|
|
||
| import com.cherrish.android.data.model.OnboardingProfileRequestModel | ||
| import com.cherrish.android.data.model.OnboardingProfileResponseModel | ||
|
|
||
| interface OnboardingProfileRepository { | ||
| suspend fun postOnboardingProfile( | ||
| request: OnboardingProfileRequestModel | ||
| ): Result<OnboardingProfileResponseModel> | ||
| } |
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,23 @@ | ||||||||||||||||||||||||
| package com.cherrish.android.data.repositoryimpl | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| import com.cherrish.android.core.util.suspendRunCatching | ||||||||||||||||||||||||
| import com.cherrish.android.data.model.OnboardingProfileRequestModel | ||||||||||||||||||||||||
| import com.cherrish.android.data.model.OnboardingProfileResponseModel | ||||||||||||||||||||||||
| import com.cherrish.android.data.model.toDto | ||||||||||||||||||||||||
| import com.cherrish.android.data.model.toModel | ||||||||||||||||||||||||
| import com.cherrish.android.data.remote.datasource.OnboardingProfileDataSource | ||||||||||||||||||||||||
| import com.cherrish.android.data.repository.OnboardingProfileRepository | ||||||||||||||||||||||||
| import javax.inject.Inject | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| class OnboardingProfileRepositoryImpl @Inject constructor( | ||||||||||||||||||||||||
| private val onboardingProfileDataSource: OnboardingProfileDataSource | ||||||||||||||||||||||||
| ) : OnboardingProfileRepository { | ||||||||||||||||||||||||
| override suspend fun postOnboardingProfile( | ||||||||||||||||||||||||
| request: OnboardingProfileRequestModel | ||||||||||||||||||||||||
| ): Result<OnboardingProfileResponseModel> = | ||||||||||||||||||||||||
| suspendRunCatching { | ||||||||||||||||||||||||
| onboardingProfileDataSource.postOnboardingProfile( | ||||||||||||||||||||||||
| request = request.toDto() | ||||||||||||||||||||||||
| ).data!!.toModel() | ||||||||||||||||||||||||
| } | ||||||||||||||||||||||||
|
Comment on lines
+18
to
+22
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
API 응답이 성공적으로 반환되더라도 🛠️ 제안하는 수정 방안 override suspend fun postOnboardingProfile(
request: OnboardingProfileRequestModel
): Result<OnboardingProfileResponseModel> =
suspendRunCatching {
onboardingProfileDataSource.postOnboardingProfile(
request = request.toDto()
- ).data!!.toModel()
+ ).data?.toModel()
+ ?: throw IllegalStateException("Onboarding profile response data is null")
}또는 API 응답 구조에서 📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||
| } | ||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,6 @@ | ||
| package com.cherrish.android.presentation.main | ||
|
|
||
| import android.content.pm.ActivityInfo | ||
| import android.graphics.Color | ||
| import android.os.Bundle | ||
| import androidx.activity.ComponentActivity | ||
|
|
@@ -13,11 +14,11 @@ import dagger.hilt.android.AndroidEntryPoint | |
| class MainActivity : ComponentActivity() { | ||
| override fun onCreate(savedInstanceState: Bundle?) { | ||
| super.onCreate(savedInstanceState) | ||
|
|
||
| enableEdgeToEdge( | ||
| statusBarStyle = SystemBarStyle.dark(Color.TRANSPARENT), | ||
| navigationBarStyle = SystemBarStyle.dark(Color.TRANSPARENT) | ||
| ) | ||
| requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 넵넵!! |
||
| setContent { | ||
| CherrishTheme { | ||
| val appState = rememberMainAppState() | ||
|
|
||

Uh oh!
There was an error while loading. Please reload this page.