-
Notifications
You must be signed in to change notification settings - Fork 0
[FEAT] 마이 프로필 및 회원 탈퇴 #33
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 52 commits
9b25c62
172e602
be8479c
61d1fd4
22c741b
717b0d4
ad971ef
c4ff3c9
262ded3
45513a1
7768d8f
846bbce
a053f43
18af35b
037f6d3
ffc32db
0e3ff5e
98a8d85
fa5cadc
25f2f20
22ec755
a99de45
2ae7148
1fa484d
508f2d5
5845e24
588a6a3
7360949
02458a5
6510ade
6f5853b
ade3245
c76569d
b1dc0b3
6cc6646
6e5b3d4
4beb928
1e45366
0cc546e
7fa85de
7ce6782
ee361dd
edcedd1
58f927e
175c29b
6e6b67a
3e6ea19
3dd19fe
6418d94
761beb1
b71d500
d515da3
567636c
5e1e55a
d7f9a59
18c3095
abc4337
5c245f4
427e766
5505311
47c1b92
634872a
08ad462
66a6488
b0fe6b1
3917c00
ad35f20
59d478a
fddabb7
f2ab07f
fb48a73
2fac627
ea7a2e1
0c22958
c536bf4
dcfd9ca
3396b74
48834cf
d3c08c5
d58d85d
9d1453b
7b59095
fc190f0
1577a75
1596dab
2834cc6
b749fcb
c19802b
e798851
5cf9a2f
dc46da1
66ac5a1
93ab1c3
b6577d0
f30d851
4d59fef
d8a4c99
cd47e30
b29e18c
38045f7
25b7bd9
a35fba3
3d9cb34
7be0ca9
3c9719e
a89f88e
00bb29d
c192e13
c186b40
2b1acb2
ce51d82
c389154
2b4c1d0
4522d0f
fc13f52
5ecc798
b652c3e
9e6aad2
dc3acc4
96dec0a
158ecc5
2b53a2c
0494397
3522577
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,26 @@ | ||
| package com.alarmy.near.data.mapper | ||
|
|
||
| import com.alarmy.near.model.member.MemberInfo | ||
| import com.alarmy.near.presentation.feature.myprofile.model.LoginType | ||
| import com.alarmy.near.presentation.feature.myprofile.model.MyProfileInfo | ||
|
|
||
| /** | ||
| * Member 관련 데이터 변환 매퍼 | ||
| * Data 계층 모델을 Presentation 계층 모델로 변환 | ||
| */ | ||
| fun MemberInfo.toMyProfileInfo(): MyProfileInfo = | ||
stopstone marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| MyProfileInfo( | ||
| nickname = nickname, | ||
| imageUrl = imageUrl, | ||
| notificationAgreedAt = notificationAgreedAt, | ||
| providerType = mapProviderType(providerType), | ||
| ) | ||
|
|
||
| /** | ||
| * ProviderType 문자열을 LoginType enum으로 변환 | ||
| */ | ||
| private fun mapProviderType(providerType: String): LoginType = | ||
| when (providerType.uppercase()) { | ||
| "KAKAO" -> LoginType.KAKAO | ||
| else -> LoginType.ETC | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| package com.alarmy.near.data.repository | ||
|
|
||
| import com.alarmy.near.model.member.MemberInfo | ||
| import com.alarmy.near.model.member.WithdrawRequest | ||
| import kotlinx.coroutines.flow.Flow | ||
|
|
||
| interface MemberRepository { | ||
| // 현재 로그인한 회원의 정보를 조회 | ||
| fun getMyInfo(): Flow<MemberInfo> | ||
|
|
||
| // 회원 탈퇴 | ||
| suspend fun withdraw(request: WithdrawRequest): Result<Unit> | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,58 @@ | ||
| package com.alarmy.near.data.repository | ||
|
|
||
| import com.alarmy.near.model.member.MemberInfo | ||
| import com.alarmy.near.model.member.WithdrawRequest | ||
| import com.alarmy.near.network.service.MemberApiService | ||
| import kotlinx.coroutines.flow.Flow | ||
| import kotlinx.coroutines.flow.flow | ||
| import javax.inject.Inject | ||
| import javax.inject.Singleton | ||
|
|
||
| /** | ||
| * 회원 정보 Repository 구현체 | ||
| */ | ||
| @Singleton | ||
| class MemberRepositoryImpl | ||
| @Inject | ||
| constructor( | ||
| private val memberApiService: MemberApiService, | ||
| ) : MemberRepository { | ||
| // 현재 로그인한 회원의 정보를 조회 | ||
| override fun getMyInfo(): Flow<MemberInfo> = | ||
| flow { | ||
| emit( | ||
| runCatching { | ||
stopstone marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| val response = memberApiService.getMyInfo() | ||
|
|
||
| if (response.isSuccessful) { | ||
| response.body() ?: throw Exception("회원 정보가 null입니다.") | ||
| } else { | ||
| val errorMessage = | ||
|
||
| when (response.code()) { | ||
| 404 -> "해당 회원을 찾을 수 없습니다." | ||
| 401 -> "인증이 필요합니다." | ||
| else -> "회원 정보 조회에 실패했습니다. (${response.code()})" | ||
| } | ||
| throw Exception(errorMessage) | ||
| } | ||
| }.getOrThrow(), | ||
| ) | ||
| } | ||
|
|
||
| // 회원 탈퇴 | ||
| override suspend fun withdraw(request: WithdrawRequest): Result<Unit> = | ||
| runCatching { | ||
| val response = memberApiService.withdraw(request) | ||
|
|
||
| if (response.isSuccessful) { | ||
| Unit | ||
| } else { | ||
| val errorMessage = when (response.code()) { | ||
| 401 -> "인증이 필요합니다." | ||
| 404 -> "해당 회원을 찾을 수 없습니다." | ||
| else -> "회원 탈퇴에 실패했습니다. (${response.code()})" | ||
| } | ||
| throw Exception(errorMessage) | ||
| } | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| package com.alarmy.near.model.member | ||
|
|
||
| import kotlinx.serialization.Serializable | ||
|
|
||
| /** | ||
| * 회원 정보 응답 모델 | ||
| */ | ||
| @Serializable | ||
| data class MemberInfo( | ||
| val memberId: String, | ||
| val username: String, | ||
| val nickname: String, | ||
| val imageUrl: String?, | ||
| val notificationAgreedAt: String?, | ||
| val providerType: String, | ||
| ) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| package com.alarmy.near.model.member | ||
|
|
||
| import kotlinx.serialization.Serializable | ||
|
|
||
| /** | ||
| * 회원 탈퇴 요청 데이터 모델 | ||
| */ | ||
| @Serializable | ||
| data class WithdrawRequest( | ||
| val reasonType: String, | ||
| val customReason: String? = null | ||
| ) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| package com.alarmy.near.network.service | ||
|
|
||
| import com.alarmy.near.model.member.MemberInfo | ||
| import com.alarmy.near.model.member.WithdrawRequest | ||
| import retrofit2.Response | ||
| import retrofit2.http.Body | ||
| import retrofit2.http.GET | ||
| import retrofit2.http.HTTP | ||
| import retrofit2.http.Header | ||
|
|
||
| /** | ||
| * 회원 관련 API 서비스 | ||
| */ | ||
| interface MemberApiService { | ||
| // 현재 로그인한 회원의 정보를 조회 | ||
| @GET("member/me") | ||
| suspend fun getMyInfo(): Response<MemberInfo> | ||
|
|
||
| // 회원 탈퇴 | ||
| @HTTP(method = "DELETE", path = "member/withdraw", hasBody = true) | ||
stopstone marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| suspend fun withdraw( | ||
| @Body request: WithdrawRequest, | ||
| ): Response<Unit> | ||
| } | ||
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.
release와debug빌드 유형 모두에서 동일한buildConfigField가 반복적으로 선언되고 있습니다. 코드를 더 간결하게 유지하고 중복을 줄이기 위해 이 필드들을defaultConfig블록으로 옮기는 것을 고려해 보세요.NEAR_URL과 같이 빌드 유형에 따라 다른 값을 가져야 하는 경우에만 각buildType에 남겨두는 것이 좋습니다.