Skip to content
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

Feature/boolti 287 프로필 조회 및 편집 #289

Merged
merged 26 commits into from
Sep 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
274137d
Boolti-287 feat: 프로필 화면으로 이동
mangbaam Aug 20, 2024
2e52031
Boolti-287 feat: 프로필 편집 화면 이동
mangbaam Aug 25, 2024
642d117
Boolti-287 feat: 링크 편집, 프로필 편집 화면 스케폴딩
mangbaam Aug 25, 2024
8e8f08c
Boolti-287 feat: 링크 추가, 수정 구현
mangbaam Aug 25, 2024
874bc7d
Boolti-287 feat: 링크 삭제 구현
mangbaam Aug 25, 2024
b6a7ba5
Boolti-287 feat: 프로필 업데이트 구현
mangbaam Aug 25, 2024
39d265d
Boolti-287 feat: 프로필 업데이트 후 최신화
mangbaam Aug 25, 2024
cb877be
Boolti-287 feat: 이미지 파일 업로드 임시 커밋
mangbaam Aug 25, 2024
b231f1f
Boolti-287 style: 닉네임 error 텍스트 추가
mangbaam Aug 26, 2024
56927e8
Boolti-287 feat: 파일 업로드 구현 중
Sep 5, 2024
5cbc581
Boolti-287 feat: BTTextField 개선 및 프로필 편집 닉네임 에러 처리
Sep 5, 2024
b4d949e
Merge remote-tracking branch 'origin/feature/Boolti-287' into feature…
mangbaam Sep 5, 2024
738f650
Boolti-287 feat: 머지 충돌 해결 및 프로필 수정 완료 버튼 활성화 처리
mangbaam Sep 5, 2024
c9bc8a9
Boolti-287 feat: 글자 길이 제한 텍스트 필드 구현
mangbaam Sep 5, 2024
bcf008d
Boolti-287 feat: 링크 열기 구현
mangbaam Sep 5, 2024
d6a605a
Boolti-287 feat: 프로필 편집 중 뒤로가기 상황 처리
mangbaam Sep 5, 2024
dc620f4
Boolti-287 feat: 프로필 화면 스크롤 추가
mangbaam Sep 5, 2024
002afb9
Boolti-287 feat: 프로필 저장 중 로딩 추가
Sep 6, 2024
443b16b
Boolti-287 refactor: 불필요 파일 제거
Sep 6, 2024
5bf0d68
Boolti-287 feat: 프로필 수정 다이얼로그 x 버튼 추가
mangbaam Sep 6, 2024
51ef8db
Boolti-287 feat: 프로필 섬네일 변경 완료
mangbaam Sep 9, 2024
48b231b
Boolti-287 feat: QA 해결
mangbaam Sep 9, 2024
6dbc717
Merge branch 'refs/heads/develop' into feature/Boolti-287
mangbaam Sep 9, 2024
0465703
Boolti-287 style: 마이 페이지 섬네일 센터크롭
mangbaam Sep 9, 2024
74647e5
Boolti-287 feat: 링크 편집 포커즈 있을 때만 클리어 버튼 노출
mangbaam Sep 9, 2024
afe1aec
Boolti-287 refactor: URL 보정
mangbaam Sep 9, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -112,5 +112,18 @@
<action android:name="com.google.firebase.MESSAGING_EVENT" />
</intent-filter>
</service>

<service
android:name="com.google.android.gms.metadata.ModuleDependencies"
android:enabled="false"
android:exported="false"
tools:ignore="MissingClass">
<intent-filter>
<action android:name="com.google.android.gms.metadata.MODULE_DEPENDENCIES" />
</intent-filter>
<meta-data
android:name="photopicker_activity:0:required"
android:value="" />
</service>
</application>
</manifest>
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,13 @@ internal class AuthDataSource @Inject constructor(
null
} else {
UserResponse(
id = it.userId ?: "",
id = it.userId,
nickname = it.nickname ?: "",
email = it.email ?: "",
imgPath = it.photo,
userCode = it.userCode,
introduction = it.profileIntroduction,
link = it.profileLink,
)
}
}
Expand Down Expand Up @@ -68,6 +70,8 @@ internal class AuthDataSource @Inject constructor(
phoneNumber = null,
photo = null,
userCode = null,
profileIntroduction = "",
profileLink = emptyList(),
accessToken = "",
refreshToken = "",
)
Expand All @@ -89,6 +93,8 @@ internal class AuthDataSource @Inject constructor(
email = user.email,
photo = user.imgPath,
userCode = user.userCode,
profileIntroduction = user.introduction,
profileLink = user.link,
)
}
Firebase.analytics.apply {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package com.nexters.boolti.data.datasource

import android.content.Context
import com.nexters.boolti.data.network.api.AuthFileService
import com.nexters.boolti.data.network.api.FileService
import com.nexters.boolti.data.network.response.UploadUrlsDto
import dagger.hilt.android.qualifiers.ApplicationContext
import okhttp3.MediaType.Companion.toMediaType
import okhttp3.RequestBody.Companion.asRequestBody
import java.io.File
import javax.inject.Inject

internal class FileDataSource @Inject constructor(
@ApplicationContext private val context: Context,
private val authFileService: AuthFileService,
private val fileService: FileService,
) {
suspend fun requestUploadUrls(file: File): Result<UploadUrlsDto> = runCatching {
authFileService.requestUploadUrls().also {
val url = it.uploadUrl
fileService.requestUploadImage(
contentType = "image/jpeg",
url = url,
file = file.asRequestBody("image/jpeg".toMediaType()),
)
}
}.onFailure {
it.printStackTrace()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package com.nexters.boolti.data.datasource

import com.nexters.boolti.data.network.api.UserService
import com.nexters.boolti.data.network.response.UserResponse
import com.nexters.boolti.domain.request.EditProfileRequest
import com.nexters.boolti.domain.request.SignoutRequest
import javax.inject.Inject

Expand All @@ -14,4 +15,6 @@ internal class UserDataSource @Inject constructor(
}

suspend fun signout(request: SignoutRequest) = userService.signout(request)

suspend fun edit(request: EditProfileRequest): UserResponse = userService.editProfile(request)
}
3 changes: 3 additions & 0 deletions data/src/main/java/com/nexters/boolti/data/db/AppSettings.kt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.nexters.boolti.data.db

import androidx.datastore.core.Serializer
import com.nexters.boolti.domain.request.EditProfileRequest
import kotlinx.serialization.Serializable
import kotlinx.serialization.SerializationException
import kotlinx.serialization.json.Json
Expand All @@ -16,6 +17,8 @@ internal data class AppSettings(
val phoneNumber: String? = null,
val photo: String? = null,
val userCode: String? = null,
val profileIntroduction: String = "",
val profileLink: List<EditProfileRequest.LinkDto> = emptyList(),
val accessToken: String = "",
val refreshToken: String = "",
val refundPolicy: List<String> = emptyList(),
Expand Down
49 changes: 47 additions & 2 deletions data/src/main/java/com/nexters/boolti/data/di/NetworkModule.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,16 @@ package com.nexters.boolti.data.di

import com.jakewharton.retrofit2.converter.kotlinx.serialization.asConverterFactory
import com.nexters.boolti.data.BuildConfig
import com.nexters.boolti.data.datasource.AuthDataSource
import com.nexters.boolti.data.datasource.TokenDataSource
import com.nexters.boolti.data.network.api.LoginService
import com.nexters.boolti.data.network.AuthAuthenticator
import com.nexters.boolti.data.datasource.AuthDataSource
import com.nexters.boolti.data.network.AuthInterceptor
import com.nexters.boolti.data.network.api.AuthFileService
import com.nexters.boolti.data.network.api.DeviceTokenService
import com.nexters.boolti.data.network.api.FileService
import com.nexters.boolti.data.network.api.GiftService
import com.nexters.boolti.data.network.api.HostService
import com.nexters.boolti.data.network.api.LoginService
import com.nexters.boolti.data.network.api.ReservationService
import com.nexters.boolti.data.network.api.ShowService
import com.nexters.boolti.data.network.api.SignUpService
Expand Down Expand Up @@ -50,6 +52,23 @@ internal object NetworkModule {
.build()
}

@Singleton
@Provides
@Named("non-auth")
fun provideNonAuthRetrofit(@Named("non-auth") okHttpClient: OkHttpClient): Retrofit {
val json = Json {
isLenient = true
prettyPrint = true
ignoreUnknownKeys = true
coerceInputValues = true
}
return Retrofit.Builder()
.baseUrl(BuildConfig.BASE_URL)
.client(okHttpClient)
.addConverterFactory(json.asConverterFactory("application/json".toMediaType()))
.build()
}

@Singleton
@Provides
fun provideRetrofit(okHttpClient: OkHttpClient): Retrofit {
Expand Down Expand Up @@ -112,6 +131,14 @@ internal object NetworkModule {
@Provides
fun provideHostService(@Named("auth") retrofit: Retrofit): HostService = retrofit.create()

@Singleton
@Provides
fun provideAuthFileService(@Named("auth") retrofit: Retrofit): AuthFileService = retrofit.create()

@Singleton
@Provides
fun provideFileService(@Named("non-auth") retrofit: Retrofit): FileService = retrofit.create()

@Singleton
@Provides
@Named("auth")
Expand Down Expand Up @@ -150,6 +177,24 @@ internal object NetworkModule {
.build()
}

@Singleton
@Provides
@Named("non-auth")
fun provideNoneAuthOkHttpClient(): OkHttpClient {
val loggingInterceptor = HttpLoggingInterceptor().apply {
level = if (BuildConfig.DEBUG) {
HttpLoggingInterceptor.Level.BODY
} else {
HttpLoggingInterceptor.Level.NONE
}
}
return OkHttpClient.Builder()
.connectTimeout(10, TimeUnit.SECONDS)
.readTimeout(10, TimeUnit.SECONDS)
.addInterceptor(loggingInterceptor)
.build()
}

@Singleton
@Provides
fun provideAuthInterceptor(tokenDataSource: TokenDataSource): AuthInterceptor = AuthInterceptor(tokenDataSource)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
package com.nexters.boolti.data.di

import com.nexters.boolti.data.repository.TicketingRepositoryImpl
import com.nexters.boolti.data.repository.AuthRepositoryImpl
import com.nexters.boolti.data.repository.ConfigRepositoryImpl
import com.nexters.boolti.data.repository.FileRepositoryImpl
import com.nexters.boolti.data.repository.GiftRepositoryImpl
import com.nexters.boolti.data.repository.ReservationRepositoryImpl
import com.nexters.boolti.data.repository.HostRepositoryImpl
import com.nexters.boolti.data.repository.ReservationRepositoryImpl
import com.nexters.boolti.data.repository.ShowRepositoryImpl
import com.nexters.boolti.data.repository.TicketRepositoryImpl
import com.nexters.boolti.data.repository.TicketingRepositoryImpl
import com.nexters.boolti.domain.repository.AuthRepository
import com.nexters.boolti.domain.repository.ConfigRepository
import com.nexters.boolti.domain.repository.FileRepository
import com.nexters.boolti.domain.repository.GiftRepository
import com.nexters.boolti.domain.repository.ReservationRepository
import com.nexters.boolti.domain.repository.HostRepository
import com.nexters.boolti.domain.repository.ReservationRepository
import com.nexters.boolti.domain.repository.ShowRepository
import com.nexters.boolti.domain.repository.TicketRepository
import com.nexters.boolti.domain.repository.TicketingRepository
Expand Down Expand Up @@ -47,4 +49,7 @@ internal abstract class RepositoryModule {

@Binds
abstract fun bindHostRepository(repository: HostRepositoryImpl): HostRepository

@Binds
abstract fun bindFileRepository(repository: FileRepositoryImpl): FileRepository
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package com.nexters.boolti.data.network.api

import com.nexters.boolti.data.network.response.UploadUrlsDto
import retrofit2.http.POST

interface AuthFileService {
@POST("/app/api/v1/user/profile-images/upload-urls")
suspend fun requestUploadUrls(): UploadUrlsDto
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package com.nexters.boolti.data.network.api

import okhttp3.RequestBody
import retrofit2.http.Body
import retrofit2.http.Header
import retrofit2.http.PUT
import retrofit2.http.Url

internal interface FileService {
@PUT
suspend fun requestUploadImage(
@Header("Content-Type") contentType: String,
@Url url: String,
@Body file: RequestBody,
)
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.nexters.boolti.data.network.api

import com.nexters.boolti.data.network.response.UserResponse
import com.nexters.boolti.domain.request.EditProfileRequest
import com.nexters.boolti.domain.request.SignoutRequest
import retrofit2.Response
import retrofit2.http.Body
Expand All @@ -15,4 +16,9 @@ internal interface UserService {
suspend fun signout(
@Body request: SignoutRequest,
)

@HTTP(method = "PATCH", path = "/app/api/v1/user", hasBody = true)
suspend fun editProfile(
@Body request: EditProfileRequest,
): UserResponse
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package com.nexters.boolti.data.network.response

import kotlinx.serialization.Serializable

@Serializable
data class UploadUrlsDto(
val uploadUrl: String,
val expectedUrl: String,
)
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
package com.nexters.boolti.data.network.response

import com.nexters.boolti.domain.model.Link
import com.nexters.boolti.domain.model.User
import com.nexters.boolti.domain.request.EditProfileRequest
import kotlinx.serialization.Serializable
import java.util.UUID

@Serializable
internal data class UserResponse(
Expand All @@ -10,6 +13,8 @@ internal data class UserResponse(
val email: String? = null,
val imgPath: String? = null,
val userCode: String? = null,
val introduction: String = "",
val link: List<EditProfileRequest.LinkDto> = emptyList(),
) {
fun toDomain(): User {
return User(
Expand All @@ -18,6 +23,8 @@ internal data class UserResponse(
email = email ?: "",
photo = imgPath,
userCode = userCode ?: "",
introduction = introduction,
link = link.map { Link(id = UUID.randomUUID().toString(), it.title, it.link) },
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import com.nexters.boolti.data.network.response.LoginResponse
import com.nexters.boolti.domain.model.LoginUserState
import com.nexters.boolti.domain.model.User
import com.nexters.boolti.domain.repository.AuthRepository
import com.nexters.boolti.domain.request.EditProfileRequest
import com.nexters.boolti.domain.request.LoginRequest
import com.nexters.boolti.domain.request.SignUpRequest
import com.nexters.boolti.domain.request.SignoutRequest
Expand Down Expand Up @@ -64,4 +65,9 @@ internal class AuthRepositoryImpl @Inject constructor(
}

override suspend fun sendFcmToken(): Result<Unit> = deviceTokenDataSource.sendFcmToken()

override suspend fun editProfile(editProfileRequest: EditProfileRequest) =
runCatching { userDateSource.edit(editProfileRequest) }
.onSuccess { authDataSource.updateUser(it) }
.mapCatching {}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package com.nexters.boolti.data.repository

import com.nexters.boolti.data.datasource.FileDataSource
import com.nexters.boolti.domain.repository.FileRepository
import java.io.File
import javax.inject.Inject

internal class FileRepositoryImpl @Inject constructor(
private val dataSource: FileDataSource,
) : FileRepository {
override suspend fun requestUrlForUpload(file: File): Result<String> =
dataSource.requestUploadUrls(file).map { it.expectedUrl }
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ package com.nexters.boolti.data.util

import com.nexters.boolti.domain.model.PaymentType
import com.nexters.boolti.domain.model.ReservationState
import okhttp3.MediaType.Companion.toMediaType
import okhttp3.MultipartBody
import okhttp3.RequestBody.Companion.asRequestBody
import java.io.File
import java.time.LocalDate
import java.time.LocalDateTime
import java.time.format.DateTimeFormatter
Expand Down Expand Up @@ -34,3 +38,9 @@ internal fun String?.toPaymentType(): PaymentType {
else -> PaymentType.UNDEFINED
}
}

internal fun File.toImageMultipartBody(): MultipartBody.Part = MultipartBody.Part.createFormData(
name = "image",
filename = name,
body = asRequestBody("image/*".toMediaType())
)
7 changes: 7 additions & 0 deletions domain/src/main/java/com/nexters/boolti/domain/model/Link.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package com.nexters.boolti.domain.model

data class Link(
val id: String,
val name: String,
val url: String,
)
2 changes: 2 additions & 0 deletions domain/src/main/java/com/nexters/boolti/domain/model/User.kt
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,6 @@ data class User(
val email: String = "",
val photo: String? = null,
val userCode: String = "",
val introduction: String = "",
val link: List<Link> = emptyList(),
)
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package com.nexters.boolti.domain.repository

import com.nexters.boolti.domain.model.LoginUserState
import com.nexters.boolti.domain.model.User
import com.nexters.boolti.domain.request.EditProfileRequest
import com.nexters.boolti.domain.request.LoginRequest
import com.nexters.boolti.domain.request.SignUpRequest
import com.nexters.boolti.domain.request.SignoutRequest
Expand All @@ -25,4 +26,6 @@ interface AuthRepository {

val loggedIn: Flow<Boolean>
val cachedUser: Flow<User?>

suspend fun editProfile(editProfileRequest: EditProfileRequest): Result<Unit>
}
Loading
Loading