-
Notifications
You must be signed in to change notification settings - Fork 0
[Feat] 온보딩 관련 API 연동 #81
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
20 commits
Select commit
Hold shift + click to select a range
5445bb0
Merge remote-tracking branch 'origin/feat-login' into feat-onboarding…
t1nm1ksun c33914c
[feat] #78: 닉네임 중복체크 서비스 구현
t1nm1ksun 799564c
[feat] #78: 닉네임 중복체크 DTO 구현
t1nm1ksun ba66a15
[feat] #78: 닉네임 중복체크 DataSource 구현
t1nm1ksun 1739860
[feat] #78: 닉네임 중복체크 Repository 구현
t1nm1ksun c3ca3bd
[feat] #78: 닉네임 중복체크 유스케이스 구현
t1nm1ksun a856963
[delete] #78: 기존 이메일 중복체크 로직 삭제
t1nm1ksun e5698ea
[feat] #78: SignUp 서비스 구현
t1nm1ksun cbbeb3b
[feat] #78: SignUp 데이터소스구현
t1nm1ksun 8d1f133
[feat] #78: SignUp 유저정보 매퍼 구현
t1nm1ksun d5f74ab
[feat] #78: SignUp Repository 구현
t1nm1ksun e5cd752
[feat] #78: SignUp 유스케이스 구현
t1nm1ksun 9f106d4
[feat] #78: SignUp 다음버튼상태 derivedState로 변경
t1nm1ksun e8892d1
[chore] #78: 변수명 URL 에서 URI로 수정
t1nm1ksun a225691
[feat] #78: DeviceId 로컬에서 관리
t1nm1ksun 91ccfa1
[feat] #78: 회원가입 body deviceId 추가
t1nm1ksun f6461b7
[feat] #78: 로그인 및 회원가입 API 응답 nullable 응답으로 수정
t1nm1ksun 3bad5b1
[chore] #78: 토큰 로그 제거
t1nm1ksun 966ff22
Merge remote-tracking branch 'origin/develop' into feat-onboarding-api
t1nm1ksun 8d428ef
[feat] #78: 멀티파트 매퍼 구현
t1nm1ksun 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
6 changes: 6 additions & 0 deletions
6
app/src/main/java/com/example/findu/data/datalocal/datasource/DeviceLocalDataSource.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,6 @@ | ||
| package com.example.findu.data.datalocal.datasource | ||
|
|
||
| interface DeviceLocalDataSource { | ||
| var deviceId: String | ||
| fun clear() | ||
| } |
28 changes: 28 additions & 0 deletions
28
...rc/main/java/com/example/findu/data/datalocal/datasourceimpl/DeviceLocalDataSourceImpl.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,28 @@ | ||
| package com.example.findu.data.datalocal.datasourceimpl | ||
|
|
||
| import android.content.Context | ||
| import android.content.SharedPreferences | ||
| import androidx.core.content.edit | ||
| import com.example.findu.data.datalocal.datasource.DeviceLocalDataSource | ||
| import dagger.hilt.android.qualifiers.ApplicationContext | ||
| import javax.inject.Inject | ||
|
|
||
| class DeviceLocalDataSourceImpl @Inject constructor( | ||
| @ApplicationContext context: Context | ||
| ) : DeviceLocalDataSource { | ||
|
|
||
| private val sharedPreferences: SharedPreferences = | ||
| context.getSharedPreferences(PREFERENCES_NAME, Context.MODE_PRIVATE) | ||
|
|
||
| override var deviceId: String | ||
| get() = sharedPreferences.getString(DEVICE_ID, INITIAL_VALUE).toString() | ||
| set(value) = sharedPreferences.edit { putString(DEVICE_ID, value) } | ||
|
|
||
| override fun clear() = sharedPreferences.edit { clear() } | ||
|
|
||
| companion object { | ||
| const val PREFERENCES_NAME = "device_preferences" | ||
| const val DEVICE_ID = "token" | ||
| const val INITIAL_VALUE = "" | ||
| } | ||
| } | ||
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
25 changes: 15 additions & 10 deletions
25
app/src/main/java/com/example/findu/data/dataremote/datasource/AuthRemoteDataSource.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,29 +1,34 @@ | ||
| package com.example.findu.data.dataremote.datasource | ||
|
|
||
| import com.example.findu.data.dataremote.model.base.BaseResponse | ||
| import com.example.findu.data.dataremote.model.base.NullableBaseResponse | ||
| import com.example.findu.data.dataremote.model.request.GuestLoginRequestDto | ||
| import com.example.findu.data.dataremote.model.request.LoginRequestDto | ||
| import com.example.findu.data.dataremote.model.response.CheckEmailResponseDto | ||
| import com.example.findu.data.dataremote.model.response.CheckNicknameResponseDto | ||
| import com.example.findu.data.dataremote.model.response.auth.GuestLoginResponseDto | ||
| import com.example.findu.data.dataremote.model.response.auth.LoginResponseDto | ||
| import com.example.findu.data.dataremote.model.response.auth.UserInfoDto | ||
| import retrofit2.Response | ||
| import java.io.File | ||
|
|
||
| interface AuthRemoteDataSource { | ||
| suspend fun postLogin( | ||
| loginRequestDto: LoginRequestDto | ||
| ): BaseResponse<LoginResponseDto> | ||
| ): NullableBaseResponse<LoginResponseDto> | ||
|
|
||
| suspend fun postGuestLogin( | ||
| guestLoginRequestDto: GuestLoginRequestDto | ||
| ): BaseResponse<GuestLoginResponseDto> | ||
| ): NullableBaseResponse<GuestLoginResponseDto> | ||
|
|
||
| suspend fun postCheckEmail( | ||
| email: String | ||
| ): BaseResponse<CheckEmailResponseDto> | ||
| suspend fun postCheckNickname( | ||
| nickname: String | ||
| ): BaseResponse<CheckNicknameResponseDto> | ||
|
|
||
| suspend fun postSignup( | ||
| email: String, | ||
| password: String, | ||
| nickname: String | ||
| ): Response<Unit> | ||
| profileImageFile: File?, | ||
| defaultImageName: String?, | ||
| nickname: String, | ||
| kakaoId: Long, | ||
| deviceId: String | ||
| ): NullableBaseResponse<UserInfoDto> | ||
| } |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -8,5 +8,5 @@ data class BaseResponse<T>( | |
| @SerialName("success") val success: Boolean, | ||
| @SerialName("code") val code: Int, | ||
| @SerialName("message") val message: String, | ||
| @SerialName("data") val data: T? = null | ||
| @SerialName("data") val data: T | ||
|
Collaborator
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. 👍 |
||
| ) | ||
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
33 changes: 22 additions & 11 deletions
33
app/src/main/java/com/example/findu/data/dataremote/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,38 +1,49 @@ | ||
| package com.example.findu.data.dataremote.service | ||
|
|
||
| import com.example.findu.data.dataremote.model.base.BaseResponse | ||
| import com.example.findu.data.dataremote.model.request.CheckEmailRequestDto | ||
| import com.example.findu.data.dataremote.model.base.NullableBaseResponse | ||
| import com.example.findu.data.dataremote.model.request.CheckNicknameRequestDto | ||
| import com.example.findu.data.dataremote.model.request.GuestLoginRequestDto | ||
| import com.example.findu.data.dataremote.model.request.LoginRequestDto | ||
| import com.example.findu.data.dataremote.model.request.SignupRequestDto | ||
| import com.example.findu.data.dataremote.model.response.CheckEmailResponseDto | ||
| import com.example.findu.data.dataremote.model.response.CheckNicknameResponseDto | ||
| import com.example.findu.data.dataremote.model.response.auth.GuestLoginResponseDto | ||
| import com.example.findu.data.dataremote.model.response.auth.LoginResponseDto | ||
| import com.example.findu.data.dataremote.model.response.auth.UserInfoDto | ||
| import com.example.findu.data.dataremote.util.ApiConstraints.API | ||
| import com.example.findu.data.dataremote.util.ApiConstraints.AUTH | ||
| import com.example.findu.data.dataremote.util.ApiConstraints.VERSION | ||
| import okhttp3.MultipartBody | ||
| import okhttp3.RequestBody | ||
| import retrofit2.Response | ||
| import retrofit2.http.Body | ||
| import retrofit2.http.Multipart | ||
| import retrofit2.http.POST | ||
| import retrofit2.http.Part | ||
|
|
||
| interface AuthService { | ||
| @POST("/$API/$VERSION/$AUTH/login/kakao") | ||
| suspend fun postLogin( | ||
| @Body loginRequestDto: LoginRequestDto | ||
| ): BaseResponse<LoginResponseDto> | ||
| ): NullableBaseResponse<LoginResponseDto> | ||
|
|
||
| @POST("/$API/$VERSION/$AUTH/login/guest") | ||
| suspend fun postGuestLogin( | ||
| @Body guestLoginRequestDto: GuestLoginRequestDto | ||
| ): BaseResponse<GuestLoginResponseDto> | ||
| ): NullableBaseResponse<GuestLoginResponseDto> | ||
|
|
||
| @POST("/$API/$VERSION/$AUTH/check/duplicate-email") | ||
| suspend fun postCheckEmail( | ||
| @Body checkEmailRequestDto: CheckEmailRequestDto | ||
| ): BaseResponse<CheckEmailResponseDto> | ||
| @POST("/$API/$VERSION/users/check/duplicate-nickname") | ||
| suspend fun postCheckNickname( | ||
| @Body checkNicknameRequestDto: CheckNicknameRequestDto | ||
| ): BaseResponse<CheckNicknameResponseDto> | ||
|
|
||
| @POST("/$API/$VERSION/$AUTH/signup") | ||
| @Multipart | ||
| @POST("/$API/$VERSION/users") | ||
| suspend fun postSignup( | ||
| @Body signupRequestBody: SignupRequestDto | ||
| ): Response<Unit> | ||
| @Part profileImage: MultipartBody.Part?, | ||
| @Part("defaultProfileImageName") defaultImageName: RequestBody?, | ||
| @Part("nickname") nickname: RequestBody, | ||
| @Part("kakaoId") kakaoId: RequestBody, | ||
| @Part("deviceId") deviceId: RequestBody | ||
| ): NullableBaseResponse<UserInfoDto> | ||
| } |
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
8 changes: 0 additions & 8 deletions
8
app/src/main/java/com/example/findu/data/mapper/toDomain/CheckEmailResponseDtoMapper.kt
This file was deleted.
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
11 changes: 11 additions & 0 deletions
11
app/src/main/java/com/example/findu/data/mapper/todomain/UserInfoDtoMapper.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,11 @@ | ||
| package com.example.findu.data.mapper.todomain | ||
|
|
||
| import com.example.findu.data.dataremote.model.response.auth.UserInfoDto | ||
| import com.example.findu.domain.model.UserInfo | ||
|
|
||
| fun UserInfoDto.toDomain(): UserInfo = | ||
| UserInfo( | ||
| userId = this.userId, | ||
| nickname = this.nickname, | ||
| accessToken = this.accessToken | ||
| ) |
18 changes: 18 additions & 0 deletions
18
app/src/main/java/com/example/findu/data/mapper/torequest/TextRequestBodyMapper.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,18 @@ | ||
| package com.example.findu.data.mapper.torequest | ||
|
|
||
| import okhttp3.MediaType.Companion.toMediaTypeOrNull | ||
| import okhttp3.MultipartBody | ||
| import okhttp3.RequestBody | ||
| import okhttp3.RequestBody.Companion.asRequestBody | ||
| import okhttp3.RequestBody.Companion.toRequestBody | ||
| import java.io.File | ||
|
|
||
| fun String.toPlainTextRequestBody(): RequestBody = | ||
| toRequestBody("text/plain".toMediaTypeOrNull()) | ||
|
|
||
| fun File.toImageMultipart(name: String): MultipartBody.Part = | ||
| MultipartBody.Part.createFormData( | ||
| name, | ||
| this.name, | ||
| asRequestBody("image/*".toMediaTypeOrNull()) | ||
| ) |
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.
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.
🛠️ Refactor suggestion
SharedPreferences DI로 주입 권장 (일관성/테스트 용이성)
직접 생성 대신 DI 모듈(예:
@DeviceIdPrefs또는@Named)로 주입하면 테스트/모킹이 쉬워지고, 동일 SP를 여러 곳에서 일관되게 사용할 수 있어요.추가로 DI 모듈에서 동일
PREFERENCES_NAME로 바인딩해 주세요.📝 Committable suggestion
🤖 Prompt for AI Agents
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.
저도 예 동의해서 Shared preference를 주입받아 Context를 몰라도되도록
하는 건어떨까요?
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.
@ikseong00 맞습니다! SharedPreferences를 주입받는 방식이 훨씬 좋은 접근법이에요.
Context 의존성을 제거하면:
PR을 보니
SharedPreferencesModule에 이미@DeviceIdPrefs한정자로 device용 SharedPreferences 제공자가 추가되어 있네요. 그러면 다음과 같이 리팩토링하면 될 것 같아요:이렇게 하면 Context를 전혀 알 필요가 없어지고, 테스트 시에도 훨씬 깔끔해질 거예요!