From aa1b084f911ae8f128bf76812db237aa24fe58c1 Mon Sep 17 00:00:00 2001 From: JI HUN LEE <51016231+easyhooon@users.noreply.github.com> Date: Wed, 1 May 2024 16:30:06 +0900 Subject: [PATCH 01/12] =?UTF-8?q?refactor:=20data=20=EB=AA=A8=EB=93=88=20?= =?UTF-8?q?=EC=A0=91=EA=B7=BC=20=EC=A0=9C=ED=95=9C=EC=9E=90=20Internal=20?= =?UTF-8?q?=EB=A1=9C=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../eggeum/android/data/database/OrmConverter.kt | 14 +++++++------- .../eggeum/android/data/database/PlaceSearchDao.kt | 8 ++++---- .../android/data/database/PlaceSearchDatabase.kt | 4 ++-- .../android/data/datasource/file/FileDataSource.kt | 4 ++-- .../data/datasource/file/FileDataSourceImpl.kt | 2 +- .../data/datasource/login/LoginLocalDataSource.kt | 12 ++++++------ .../datasource/login/LoginLocalDataSourceImpl.kt | 2 +- .../data/datasource/login/LoginRemoteDataSource.kt | 6 +++--- .../datasource/login/LoginRemoteDataSourceImpl.kt | 6 +++--- .../data/datasource/notice/NoticeDataSource.kt | 6 +++--- .../data/datasource/notice/NoticeDataSourceImpl.kt | 2 +- .../datasource/place/local/PlaceLocalDataSource.kt | 8 ++++---- .../place/local/PlaceLocalDataSourceImpl.kt | 2 +- .../place/remote/PlaceRemoteDataSource.kt | 8 ++++---- .../place/remote/PlaceRemoteDataSourceImpl.kt | 2 +- .../data/datasource/report/ReportDataSource.kt | 10 +++++----- .../data/datasource/report/ReportDataSourceImpl.kt | 8 ++++---- .../data/datasource/token/TokenDataSource.kt | 4 ++-- .../data/datasource/token/TokenDataSourceImpl.kt | 4 ++-- .../android/data/datasource/user/UserDataSource.kt | 12 ++++++------ .../data/datasource/user/UserDataSourceImpl.kt | 2 +- .../eggeum/android/data/di/DatabaseModule.kt | 4 ++-- .../eggeum/android/data/di/FileManagerModule.kt | 4 ++-- .../eggeum/android/data/mapper/FileMapper.kt | 10 +++++----- .../eggeum/android/data/mapper/PlaceMapper.kt | 12 ++++++------ .../android/data/paging/NoticePagingSource.kt | 6 +++--- .../android/data/paging/PlacePagingSource.kt | 2 +- .../android/data/paging/ReportPagingSource.kt | 2 +- .../android/data/repository/EnumRepositoryImpl.kt | 2 +- .../android/data/repository/FileRepositoryImpl.kt | 2 +- .../android/data/repository/LoginRepositoryImpl.kt | 6 +++--- .../data/repository/NoticeRepositoryImpl.kt | 2 +- .../android/data/repository/PlaceRepositoryImpl.kt | 2 +- .../data/repository/ReportRepositoryImpl.kt | 6 +++--- .../android/data/repository/UserRepositoryImpl.kt | 2 +- .../eggeum/android/data/service/FileService.kt | 4 ++-- .../eggeum/android/data/service/LoginService.kt | 6 +++--- .../eggeum/android/data/service/NoticeService.kt | 6 +++--- .../eggeum/android/data/service/PlaceService.kt | 8 ++++---- .../eggeum/android/data/service/ReportService.kt | 10 +++++----- .../android/data/service/TokenAuthenticator.kt | 4 ++-- .../android/data/service/TokenInterceptor.kt | 2 +- .../eggeum/android/data/service/TokenService.kt | 4 ++-- .../eggeum/android/data/service/UserService.kt | 12 ++++++------ .../wedemy/eggeum/android/data/util/Constants.kt | 8 ++++---- 45 files changed, 126 insertions(+), 126 deletions(-) diff --git a/data/src/main/kotlin/us/wedemy/eggeum/android/data/database/OrmConverter.kt b/data/src/main/kotlin/us/wedemy/eggeum/android/data/database/OrmConverter.kt index 182e9064..901a15d8 100644 --- a/data/src/main/kotlin/us/wedemy/eggeum/android/data/database/OrmConverter.kt +++ b/data/src/main/kotlin/us/wedemy/eggeum/android/data/database/OrmConverter.kt @@ -14,36 +14,36 @@ import us.wedemy.eggeum.android.data.model.place.Image import us.wedemy.eggeum.android.data.model.place.Info import us.wedemy.eggeum.android.data.model.place.Menu -public class OrmConverter { +internal class OrmConverter { private val json = Json @TypeConverter - public fun fromImage(image: Image?): String? { + fun fromImage(image: Image?): String? { return image?.let { json.encodeToString(it) } } @TypeConverter - public fun toImage(imageString: String?): Image? { + fun toImage(imageString: String?): Image? { return imageString?.let { json.decodeFromString(it) } } @TypeConverter - public fun fromInfo(info: Info?): String? { + fun fromInfo(info: Info?): String? { return info?.let { json.encodeToString(it) } } @TypeConverter - public fun toInfo(infoString: String?): Info? { + fun toInfo(infoString: String?): Info? { return infoString?.let { json.decodeFromString(it) } } @TypeConverter - public fun fromMenu(menu: Menu?): String? { + fun fromMenu(menu: Menu?): String? { return menu?.let { json.encodeToString(it) } } @TypeConverter - public fun toMenu(menuString: String?): Menu? { + fun toMenu(menuString: String?): Menu? { return menuString?.let { json.decodeFromString(it) } } } diff --git a/data/src/main/kotlin/us/wedemy/eggeum/android/data/database/PlaceSearchDao.kt b/data/src/main/kotlin/us/wedemy/eggeum/android/data/database/PlaceSearchDao.kt index 2ec7d6e9..686dd65c 100644 --- a/data/src/main/kotlin/us/wedemy/eggeum/android/data/database/PlaceSearchDao.kt +++ b/data/src/main/kotlin/us/wedemy/eggeum/android/data/database/PlaceSearchDao.kt @@ -16,13 +16,13 @@ import androidx.room.Query import us.wedemy.eggeum.android.data.model.place.PlaceResponse @Dao -public interface PlaceSearchDao { +internal interface PlaceSearchDao { @Insert(onConflict = OnConflictStrategy.REPLACE) - public suspend fun insertRecentSearchPlace(place: PlaceResponse) + suspend fun insertRecentSearchPlace(place: PlaceResponse) @Delete - public suspend fun deleteRecentSearchPlace(place: PlaceResponse) + suspend fun deleteRecentSearchPlace(place: PlaceResponse) @Query("SELECT * FROM places") - public fun getRecentSearchPlaceList(): PagingSource + fun getRecentSearchPlaceList(): PagingSource } diff --git a/data/src/main/kotlin/us/wedemy/eggeum/android/data/database/PlaceSearchDatabase.kt b/data/src/main/kotlin/us/wedemy/eggeum/android/data/database/PlaceSearchDatabase.kt index eb58fd00..b572f707 100644 --- a/data/src/main/kotlin/us/wedemy/eggeum/android/data/database/PlaceSearchDatabase.kt +++ b/data/src/main/kotlin/us/wedemy/eggeum/android/data/database/PlaceSearchDatabase.kt @@ -18,6 +18,6 @@ import us.wedemy.eggeum.android.data.model.place.PlaceResponse exportSchema = false, ) @TypeConverters(OrmConverter::class) -public abstract class PlaceSearchDatabase : RoomDatabase() { - public abstract fun placeSearchDao(): PlaceSearchDao +internal abstract class PlaceSearchDatabase : RoomDatabase() { + abstract fun placeSearchDao(): PlaceSearchDao } diff --git a/data/src/main/kotlin/us/wedemy/eggeum/android/data/datasource/file/FileDataSource.kt b/data/src/main/kotlin/us/wedemy/eggeum/android/data/datasource/file/FileDataSource.kt index aca8adc3..7b833de9 100644 --- a/data/src/main/kotlin/us/wedemy/eggeum/android/data/datasource/file/FileDataSource.kt +++ b/data/src/main/kotlin/us/wedemy/eggeum/android/data/datasource/file/FileDataSource.kt @@ -9,6 +9,6 @@ package us.wedemy.eggeum.android.data.datasource.file import us.wedemy.eggeum.android.data.model.file.FileResponse -public interface FileDataSource { - public suspend fun uploadImageFile(uri: String): FileResponse +internal interface FileDataSource { + suspend fun uploadImageFile(uri: String): FileResponse } diff --git a/data/src/main/kotlin/us/wedemy/eggeum/android/data/datasource/file/FileDataSourceImpl.kt b/data/src/main/kotlin/us/wedemy/eggeum/android/data/datasource/file/FileDataSourceImpl.kt index 8471943b..143a4991 100644 --- a/data/src/main/kotlin/us/wedemy/eggeum/android/data/datasource/file/FileDataSourceImpl.kt +++ b/data/src/main/kotlin/us/wedemy/eggeum/android/data/datasource/file/FileDataSourceImpl.kt @@ -17,7 +17,7 @@ import us.wedemy.eggeum.android.data.model.file.FileResponse import us.wedemy.eggeum.android.data.service.FileService import us.wedemy.eggeum.android.data.util.FileManager -public class FileDataSourceImpl @Inject constructor( +internal class FileDataSourceImpl @Inject constructor( private val context: Context, private val service: FileService, private val fileManager: FileManager, diff --git a/data/src/main/kotlin/us/wedemy/eggeum/android/data/datasource/login/LoginLocalDataSource.kt b/data/src/main/kotlin/us/wedemy/eggeum/android/data/datasource/login/LoginLocalDataSource.kt index c4b83b4d..5f726d5f 100644 --- a/data/src/main/kotlin/us/wedemy/eggeum/android/data/datasource/login/LoginLocalDataSource.kt +++ b/data/src/main/kotlin/us/wedemy/eggeum/android/data/datasource/login/LoginLocalDataSource.kt @@ -7,14 +7,14 @@ package us.wedemy.eggeum.android.data.datasource.login -public interface LoginLocalDataSource { - public suspend fun setAccessToken(accessToken: String) +internal interface LoginLocalDataSource { + suspend fun setAccessToken(accessToken: String) - public suspend fun setRefreshToken(refreshToken: String) + suspend fun setRefreshToken(refreshToken: String) - public suspend fun getAccessToken(): String + suspend fun getAccessToken(): String - public suspend fun getRefreshToken(): String + suspend fun getRefreshToken(): String - public suspend fun deleteAuthToken() + suspend fun deleteAuthToken() } diff --git a/data/src/main/kotlin/us/wedemy/eggeum/android/data/datasource/login/LoginLocalDataSourceImpl.kt b/data/src/main/kotlin/us/wedemy/eggeum/android/data/datasource/login/LoginLocalDataSourceImpl.kt index bd253e86..b649fa69 100644 --- a/data/src/main/kotlin/us/wedemy/eggeum/android/data/datasource/login/LoginLocalDataSourceImpl.kt +++ b/data/src/main/kotlin/us/wedemy/eggeum/android/data/datasource/login/LoginLocalDataSourceImpl.kt @@ -10,7 +10,7 @@ package us.wedemy.eggeum.android.data.datasource.login import javax.inject.Inject import us.wedemy.eggeum.android.data.datastore.TokenDataStoreProvider -public class LoginLocalDataSourceImpl @Inject constructor( +internal class LoginLocalDataSourceImpl @Inject constructor( private val dataStore: TokenDataStoreProvider, ) : LoginLocalDataSource { override suspend fun setAccessToken(accessToken: String) { diff --git a/data/src/main/kotlin/us/wedemy/eggeum/android/data/datasource/login/LoginRemoteDataSource.kt b/data/src/main/kotlin/us/wedemy/eggeum/android/data/datasource/login/LoginRemoteDataSource.kt index e1f38f63..48835ff1 100644 --- a/data/src/main/kotlin/us/wedemy/eggeum/android/data/datasource/login/LoginRemoteDataSource.kt +++ b/data/src/main/kotlin/us/wedemy/eggeum/android/data/datasource/login/LoginRemoteDataSource.kt @@ -12,8 +12,8 @@ import us.wedemy.eggeum.android.data.model.login.LoginResponse import us.wedemy.eggeum.android.data.model.login.SignUpRequest import us.wedemy.eggeum.android.data.model.login.SignUpResponse -public interface LoginRemoteDataSource { - public suspend fun login(loginRequest: LoginRequest): LoginResponse +internal interface LoginRemoteDataSource { + suspend fun login(loginRequest: LoginRequest): LoginResponse - public suspend fun signUp(signUpRequest: SignUpRequest): SignUpResponse + suspend fun signUp(signUpRequest: SignUpRequest): SignUpResponse } diff --git a/data/src/main/kotlin/us/wedemy/eggeum/android/data/datasource/login/LoginRemoteDataSourceImpl.kt b/data/src/main/kotlin/us/wedemy/eggeum/android/data/datasource/login/LoginRemoteDataSourceImpl.kt index 8912325a..c91049f7 100644 --- a/data/src/main/kotlin/us/wedemy/eggeum/android/data/datasource/login/LoginRemoteDataSourceImpl.kt +++ b/data/src/main/kotlin/us/wedemy/eggeum/android/data/datasource/login/LoginRemoteDataSourceImpl.kt @@ -14,14 +14,14 @@ import us.wedemy.eggeum.android.data.model.login.SignUpRequest import us.wedemy.eggeum.android.data.model.login.SignUpResponse import us.wedemy.eggeum.android.data.service.LoginService -public class LoginRemoteDataSourceImpl @Inject constructor( +internal class LoginRemoteDataSourceImpl @Inject constructor( private val service: LoginService, ) : LoginRemoteDataSource { - public override suspend fun login(loginRequest: LoginRequest): LoginResponse { + override suspend fun login(loginRequest: LoginRequest): LoginResponse { return service.login(loginRequest) } - public override suspend fun signUp( + override suspend fun signUp( signUpRequest: SignUpRequest, ): SignUpResponse { return service.signUp(signUpRequest) diff --git a/data/src/main/kotlin/us/wedemy/eggeum/android/data/datasource/notice/NoticeDataSource.kt b/data/src/main/kotlin/us/wedemy/eggeum/android/data/datasource/notice/NoticeDataSource.kt index 736f371f..93b6b0e7 100644 --- a/data/src/main/kotlin/us/wedemy/eggeum/android/data/datasource/notice/NoticeDataSource.kt +++ b/data/src/main/kotlin/us/wedemy/eggeum/android/data/datasource/notice/NoticeDataSource.kt @@ -11,10 +11,10 @@ import androidx.paging.PagingData import kotlinx.coroutines.flow.Flow import us.wedemy.eggeum.android.data.model.notice.NoticeResponse -public interface NoticeDataSource { - public suspend fun getNotice(noticeId: Long): NoticeResponse +internal interface NoticeDataSource { + suspend fun getNotice(noticeId: Long): NoticeResponse - public fun getNoticeList( + fun getNoticeList( search: String?, page: Int?, size: Int?, diff --git a/data/src/main/kotlin/us/wedemy/eggeum/android/data/datasource/notice/NoticeDataSourceImpl.kt b/data/src/main/kotlin/us/wedemy/eggeum/android/data/datasource/notice/NoticeDataSourceImpl.kt index 3807075a..c0b86b3f 100644 --- a/data/src/main/kotlin/us/wedemy/eggeum/android/data/datasource/notice/NoticeDataSourceImpl.kt +++ b/data/src/main/kotlin/us/wedemy/eggeum/android/data/datasource/notice/NoticeDataSourceImpl.kt @@ -17,7 +17,7 @@ import us.wedemy.eggeum.android.data.paging.NoticePagingSource import us.wedemy.eggeum.android.data.service.NoticeService import us.wedemy.eggeum.android.data.util.Constants -public class NoticeDataSourceImpl @Inject constructor( +internal class NoticeDataSourceImpl @Inject constructor( private val service: NoticeService, ) : NoticeDataSource { override suspend fun getNotice(noticeId: Long): NoticeResponse { diff --git a/data/src/main/kotlin/us/wedemy/eggeum/android/data/datasource/place/local/PlaceLocalDataSource.kt b/data/src/main/kotlin/us/wedemy/eggeum/android/data/datasource/place/local/PlaceLocalDataSource.kt index 28f326ab..9a1ce2f1 100644 --- a/data/src/main/kotlin/us/wedemy/eggeum/android/data/datasource/place/local/PlaceLocalDataSource.kt +++ b/data/src/main/kotlin/us/wedemy/eggeum/android/data/datasource/place/local/PlaceLocalDataSource.kt @@ -12,10 +12,10 @@ import kotlinx.coroutines.flow.Flow import us.wedemy.eggeum.android.data.model.place.PlaceResponse import us.wedemy.eggeum.android.domain.model.place.PlaceEntity -public interface PlaceLocalDataSource { - public suspend fun insertRecentSearchPlace(placeEntity: PlaceEntity) +internal interface PlaceLocalDataSource { + suspend fun insertRecentSearchPlace(placeEntity: PlaceEntity) - public suspend fun deleteRecentSearchPlace(placeEntity: PlaceEntity) + suspend fun deleteRecentSearchPlace(placeEntity: PlaceEntity) - public fun getRecentSearchPlaceList(): Flow> + fun getRecentSearchPlaceList(): Flow> } diff --git a/data/src/main/kotlin/us/wedemy/eggeum/android/data/datasource/place/local/PlaceLocalDataSourceImpl.kt b/data/src/main/kotlin/us/wedemy/eggeum/android/data/datasource/place/local/PlaceLocalDataSourceImpl.kt index 09e89d8e..a7a53c81 100644 --- a/data/src/main/kotlin/us/wedemy/eggeum/android/data/datasource/place/local/PlaceLocalDataSourceImpl.kt +++ b/data/src/main/kotlin/us/wedemy/eggeum/android/data/datasource/place/local/PlaceLocalDataSourceImpl.kt @@ -18,7 +18,7 @@ import us.wedemy.eggeum.android.data.model.place.PlaceResponse import us.wedemy.eggeum.android.data.util.Constants import us.wedemy.eggeum.android.domain.model.place.PlaceEntity -public class PlaceLocalDataSourceImpl @Inject constructor( +internal class PlaceLocalDataSourceImpl @Inject constructor( private val placeSearchDatabase: PlaceSearchDatabase, ) : PlaceLocalDataSource { override suspend fun insertRecentSearchPlace(placeEntity: PlaceEntity) { diff --git a/data/src/main/kotlin/us/wedemy/eggeum/android/data/datasource/place/remote/PlaceRemoteDataSource.kt b/data/src/main/kotlin/us/wedemy/eggeum/android/data/datasource/place/remote/PlaceRemoteDataSource.kt index 18963cea..21f83c2e 100644 --- a/data/src/main/kotlin/us/wedemy/eggeum/android/data/datasource/place/remote/PlaceRemoteDataSource.kt +++ b/data/src/main/kotlin/us/wedemy/eggeum/android/data/datasource/place/remote/PlaceRemoteDataSource.kt @@ -12,10 +12,10 @@ import kotlinx.coroutines.flow.Flow import us.wedemy.eggeum.android.data.model.place.PlaceResponse import us.wedemy.eggeum.android.data.model.place.UpsertPlaceRequest -public interface PlaceRemoteDataSource { - public suspend fun getPlace(placeId: Long): PlaceResponse +internal interface PlaceRemoteDataSource { + suspend fun getPlace(placeId: Long): PlaceResponse - public fun getPlaceList( + fun getPlaceList( distance: Double?, endDate: String?, latitude: Double?, @@ -28,5 +28,5 @@ public interface PlaceRemoteDataSource { type: String?, ): Flow> - public suspend fun upsertPlace(upsertPlaceRequest: UpsertPlaceRequest) + suspend fun upsertPlace(upsertPlaceRequest: UpsertPlaceRequest) } diff --git a/data/src/main/kotlin/us/wedemy/eggeum/android/data/datasource/place/remote/PlaceRemoteDataSourceImpl.kt b/data/src/main/kotlin/us/wedemy/eggeum/android/data/datasource/place/remote/PlaceRemoteDataSourceImpl.kt index 7e595412..4e5e7c87 100644 --- a/data/src/main/kotlin/us/wedemy/eggeum/android/data/datasource/place/remote/PlaceRemoteDataSourceImpl.kt +++ b/data/src/main/kotlin/us/wedemy/eggeum/android/data/datasource/place/remote/PlaceRemoteDataSourceImpl.kt @@ -25,7 +25,7 @@ import us.wedemy.eggeum.android.data.paging.PlacePagingSource import us.wedemy.eggeum.android.data.service.PlaceService import us.wedemy.eggeum.android.data.util.Constants -public class PlaceRemoteDataSourceImpl @Inject constructor( +internal class PlaceRemoteDataSourceImpl @Inject constructor( private val service: PlaceService, ) : PlaceRemoteDataSource { override suspend fun getPlace(placeId: Long): PlaceResponse { diff --git a/data/src/main/kotlin/us/wedemy/eggeum/android/data/datasource/report/ReportDataSource.kt b/data/src/main/kotlin/us/wedemy/eggeum/android/data/datasource/report/ReportDataSource.kt index 0930b3c1..3d244ca2 100644 --- a/data/src/main/kotlin/us/wedemy/eggeum/android/data/datasource/report/ReportDataSource.kt +++ b/data/src/main/kotlin/us/wedemy/eggeum/android/data/datasource/report/ReportDataSource.kt @@ -13,16 +13,16 @@ import us.wedemy.eggeum.android.data.model.report.CreateReportRequest import us.wedemy.eggeum.android.data.model.report.UpdateReportRequest import us.wedemy.eggeum.android.data.model.report.ReportResponse -public interface ReportDataSource { - public suspend fun getReport(reportId: Long): ReportResponse +internal interface ReportDataSource { + suspend fun getReport(reportId: Long): ReportResponse - public fun getReportList( + fun getReportList( page: Int?, size: Int?, sort: String?, ): Flow> - public suspend fun createReport(createReportRequest: CreateReportRequest) + suspend fun createReport(createReportRequest: CreateReportRequest) - public suspend fun updateReport(reportId: Long, updateReportRequest: UpdateReportRequest) + suspend fun updateReport(reportId: Long, updateReportRequest: UpdateReportRequest) } diff --git a/data/src/main/kotlin/us/wedemy/eggeum/android/data/datasource/report/ReportDataSourceImpl.kt b/data/src/main/kotlin/us/wedemy/eggeum/android/data/datasource/report/ReportDataSourceImpl.kt index 26b885ee..5188097d 100644 --- a/data/src/main/kotlin/us/wedemy/eggeum/android/data/datasource/report/ReportDataSourceImpl.kt +++ b/data/src/main/kotlin/us/wedemy/eggeum/android/data/datasource/report/ReportDataSourceImpl.kt @@ -19,11 +19,11 @@ import us.wedemy.eggeum.android.data.paging.ReportPagingSource import us.wedemy.eggeum.android.data.service.ReportService import us.wedemy.eggeum.android.data.util.Constants -public class ReportDataSourceImpl @Inject constructor( +internal class ReportDataSourceImpl @Inject constructor( private val service: ReportService, ) : ReportDataSource { - public override suspend fun getReport(reportId: Long): ReportResponse { + override suspend fun getReport(reportId: Long): ReportResponse { return service.getReport(reportId) } @@ -43,13 +43,13 @@ public class ReportDataSourceImpl @Inject constructor( ).flow } - public override suspend fun createReport(createReportRequest: CreateReportRequest) { + override suspend fun createReport(createReportRequest: CreateReportRequest) { service.createReport( createReportRequest = createReportRequest, ) } - public override suspend fun updateReport(reportId: Long, updateReportRequest: UpdateReportRequest) { + override suspend fun updateReport(reportId: Long, updateReportRequest: UpdateReportRequest) { service.updateReport( reportId = reportId, updateReportRequest = updateReportRequest, diff --git a/data/src/main/kotlin/us/wedemy/eggeum/android/data/datasource/token/TokenDataSource.kt b/data/src/main/kotlin/us/wedemy/eggeum/android/data/datasource/token/TokenDataSource.kt index ba9e2a27..a4579026 100644 --- a/data/src/main/kotlin/us/wedemy/eggeum/android/data/datasource/token/TokenDataSource.kt +++ b/data/src/main/kotlin/us/wedemy/eggeum/android/data/datasource/token/TokenDataSource.kt @@ -10,6 +10,6 @@ package us.wedemy.eggeum.android.data.datasource.token import us.wedemy.eggeum.android.data.model.token.TokenRequest import us.wedemy.eggeum.android.data.model.token.TokenResponse -public interface TokenDataSource { - public suspend fun getRefreshToken(tokenRequest: TokenRequest): Result +internal interface TokenDataSource { + suspend fun getNewAccessToken(tokenRequest: TokenRequest): Result } diff --git a/data/src/main/kotlin/us/wedemy/eggeum/android/data/datasource/token/TokenDataSourceImpl.kt b/data/src/main/kotlin/us/wedemy/eggeum/android/data/datasource/token/TokenDataSourceImpl.kt index 49ae695b..7e2835a3 100644 --- a/data/src/main/kotlin/us/wedemy/eggeum/android/data/datasource/token/TokenDataSourceImpl.kt +++ b/data/src/main/kotlin/us/wedemy/eggeum/android/data/datasource/token/TokenDataSourceImpl.kt @@ -13,11 +13,11 @@ import us.wedemy.eggeum.android.data.model.token.TokenResponse import us.wedemy.eggeum.android.data.service.TokenService import us.wedemy.eggeum.android.domain.util.runSuspendCatching -public class TokenDataSourceImpl @Inject constructor( +internal class TokenDataSourceImpl @Inject constructor( private val service: TokenService, ) : TokenDataSource { - override suspend fun getRefreshToken(tokenRequest: TokenRequest): Result = + override suspend fun getNewAccessToken(tokenRequest: TokenRequest): Result = runSuspendCatching { service.getRefreshToken(tokenRequest) } diff --git a/data/src/main/kotlin/us/wedemy/eggeum/android/data/datasource/user/UserDataSource.kt b/data/src/main/kotlin/us/wedemy/eggeum/android/data/datasource/user/UserDataSource.kt index c03b8679..7d3a1e5e 100644 --- a/data/src/main/kotlin/us/wedemy/eggeum/android/data/datasource/user/UserDataSource.kt +++ b/data/src/main/kotlin/us/wedemy/eggeum/android/data/datasource/user/UserDataSource.kt @@ -10,14 +10,14 @@ package us.wedemy.eggeum.android.data.datasource.user import us.wedemy.eggeum.android.data.model.user.UpdateUserInfoRequest import us.wedemy.eggeum.android.data.model.user.UserInfoResponse -public interface UserDataSource { - public suspend fun getUserInfo(): UserInfoResponse +internal interface UserDataSource { + suspend fun getUserInfo(): UserInfoResponse - public suspend fun updateUserInfo(updateUserInfoRequest: UpdateUserInfoRequest) + suspend fun updateUserInfo(updateUserInfoRequest: UpdateUserInfoRequest) - public suspend fun withdraw() + suspend fun withdraw() - public suspend fun updateUserNickname(nickname: String) + suspend fun updateUserNickname(nickname: String) - public suspend fun checkNicknameExist(nickname: String): Boolean + suspend fun checkNicknameExist(nickname: String): Boolean } diff --git a/data/src/main/kotlin/us/wedemy/eggeum/android/data/datasource/user/UserDataSourceImpl.kt b/data/src/main/kotlin/us/wedemy/eggeum/android/data/datasource/user/UserDataSourceImpl.kt index 4241d223..f2e8cb8f 100644 --- a/data/src/main/kotlin/us/wedemy/eggeum/android/data/datasource/user/UserDataSourceImpl.kt +++ b/data/src/main/kotlin/us/wedemy/eggeum/android/data/datasource/user/UserDataSourceImpl.kt @@ -14,7 +14,7 @@ import us.wedemy.eggeum.android.data.model.user.UserInfoResponse import us.wedemy.eggeum.android.data.service.UserService @Singleton -public class UserDataSourceImpl @Inject constructor( +internal class UserDataSourceImpl @Inject constructor( private val service: UserService, ) : UserDataSource { override suspend fun getUserInfo(): UserInfoResponse { diff --git a/data/src/main/kotlin/us/wedemy/eggeum/android/data/di/DatabaseModule.kt b/data/src/main/kotlin/us/wedemy/eggeum/android/data/di/DatabaseModule.kt index be104aa2..5ef2ff73 100644 --- a/data/src/main/kotlin/us/wedemy/eggeum/android/data/di/DatabaseModule.kt +++ b/data/src/main/kotlin/us/wedemy/eggeum/android/data/di/DatabaseModule.kt @@ -19,11 +19,11 @@ import us.wedemy.eggeum.android.data.database.PlaceSearchDatabase @Module @InstallIn(SingletonComponent::class) -public object DatabaseModule { +internal object DatabaseModule { @Singleton @Provides - public fun providePlaceSearchDatabase(@ApplicationContext context: Context): PlaceSearchDatabase = + fun providePlaceSearchDatabase(@ApplicationContext context: Context): PlaceSearchDatabase = Room.databaseBuilder( context.applicationContext, PlaceSearchDatabase::class.java, diff --git a/data/src/main/kotlin/us/wedemy/eggeum/android/data/di/FileManagerModule.kt b/data/src/main/kotlin/us/wedemy/eggeum/android/data/di/FileManagerModule.kt index 8e178540..d09d516f 100644 --- a/data/src/main/kotlin/us/wedemy/eggeum/android/data/di/FileManagerModule.kt +++ b/data/src/main/kotlin/us/wedemy/eggeum/android/data/di/FileManagerModule.kt @@ -9,11 +9,11 @@ import us.wedemy.eggeum.android.data.util.FileManager @Module @InstallIn(SingletonComponent::class) -public object FileManagerModule { +internal object FileManagerModule { @Provides @Singleton - public fun provideFileManager(): FileManager { + fun provideFileManager(): FileManager { return FileManager } } diff --git a/data/src/main/kotlin/us/wedemy/eggeum/android/data/mapper/FileMapper.kt b/data/src/main/kotlin/us/wedemy/eggeum/android/data/mapper/FileMapper.kt index 4ceea122..58dec1d5 100644 --- a/data/src/main/kotlin/us/wedemy/eggeum/android/data/mapper/FileMapper.kt +++ b/data/src/main/kotlin/us/wedemy/eggeum/android/data/mapper/FileMapper.kt @@ -16,31 +16,31 @@ import us.wedemy.eggeum.android.domain.model.FileEntity import us.wedemy.eggeum.android.domain.model.file.FileResponseEntity import us.wedemy.eggeum.android.domain.model.place.ImageEntity -public fun FileResponse.toEntity(): FileResponseEntity = +internal fun FileResponse.toEntity(): FileResponseEntity = FileResponseEntity( name = name, uploadFileId = uploadFileId, url = url, ) -public fun File.toEntity(): FileEntity = +internal fun File.toEntity(): FileEntity = FileEntity( uploadFileId = uploadFileId, url = url, ) -public fun FileEntity.toModel(): File = +internal fun FileEntity.toModel(): File = File( uploadFileId = uploadFileId, url = url, ) -public fun Image.toEntity(): ImageEntity = +internal fun Image.toEntity(): ImageEntity = ImageEntity( files = files?.map { it.toEntity() }, ) -public fun ImageEntity.toModel(): Image = +internal fun ImageEntity.toModel(): Image = Image( files = files?.map { it.toModel() }, ) diff --git a/data/src/main/kotlin/us/wedemy/eggeum/android/data/mapper/PlaceMapper.kt b/data/src/main/kotlin/us/wedemy/eggeum/android/data/mapper/PlaceMapper.kt index e47d8f72..04eab207 100644 --- a/data/src/main/kotlin/us/wedemy/eggeum/android/data/mapper/PlaceMapper.kt +++ b/data/src/main/kotlin/us/wedemy/eggeum/android/data/mapper/PlaceMapper.kt @@ -71,7 +71,7 @@ internal fun UpsertPlaceEntity.toModel() = type = type, ) -public fun Info.toEntity(): InfoEntity = +internal fun Info.toEntity(): InfoEntity = InfoEntity( areaSize = areaSize, blogUri = blogUri, @@ -90,7 +90,7 @@ public fun Info.toEntity(): InfoEntity = websiteUri = websiteUri, ) -public fun InfoEntity.toModel(): Info = +internal fun InfoEntity.toModel(): Info = Info( areaSize = areaSize, blogUri = blogUri, @@ -109,23 +109,23 @@ public fun InfoEntity.toModel(): Info = websiteUri = websiteUri, ) -public fun Menu.toEntity(): MenuEntity = +internal fun Menu.toEntity(): MenuEntity = MenuEntity( products = products?.map { it.toEntity() }, ) -public fun MenuEntity.toModel(): Menu = +internal fun MenuEntity.toModel(): Menu = Menu( products = products?.map { it.toModel() }, ) -public fun Product.toEntity(): ProductEntity = +internal fun Product.toEntity(): ProductEntity = ProductEntity( name = name, price = price, ) -public fun ProductEntity.toModel(): Product = +internal fun ProductEntity.toModel(): Product = Product( name = name, price = price, diff --git a/data/src/main/kotlin/us/wedemy/eggeum/android/data/paging/NoticePagingSource.kt b/data/src/main/kotlin/us/wedemy/eggeum/android/data/paging/NoticePagingSource.kt index 457fcec6..a6cf16bc 100644 --- a/data/src/main/kotlin/us/wedemy/eggeum/android/data/paging/NoticePagingSource.kt +++ b/data/src/main/kotlin/us/wedemy/eggeum/android/data/paging/NoticePagingSource.kt @@ -17,19 +17,19 @@ import us.wedemy.eggeum.android.data.service.NoticeService import us.wedemy.eggeum.android.data.util.Constants.PAGING_SIZE import us.wedemy.eggeum.android.data.util.Constants.STARTING_PAGE_INDEX -public class NoticePagingSource( +internal class NoticePagingSource( private val service: NoticeService, private val query: String? = null, ) : PagingSource() { - public override fun getRefreshKey(state: PagingState): Int? { + override fun getRefreshKey(state: PagingState): Int? { return state.anchorPosition?.let { anchorPosition -> state.closestPageToPosition(anchorPosition)?.prevKey?.plus(1) ?: state.closestPageToPosition(anchorPosition)?.nextKey?.minus(1) } } - public override suspend fun load(params: LoadParams): LoadResult { + override suspend fun load(params: LoadParams): LoadResult { return try { val pageNumber = params.key ?: STARTING_PAGE_INDEX val response = service.getNoticeList(page = pageNumber, search = query, size = params.loadSize) diff --git a/data/src/main/kotlin/us/wedemy/eggeum/android/data/paging/PlacePagingSource.kt b/data/src/main/kotlin/us/wedemy/eggeum/android/data/paging/PlacePagingSource.kt index f23bd172..07e94df7 100644 --- a/data/src/main/kotlin/us/wedemy/eggeum/android/data/paging/PlacePagingSource.kt +++ b/data/src/main/kotlin/us/wedemy/eggeum/android/data/paging/PlacePagingSource.kt @@ -17,7 +17,7 @@ import us.wedemy.eggeum.android.data.service.PlaceService import us.wedemy.eggeum.android.data.util.Constants.PAGING_SIZE import us.wedemy.eggeum.android.data.util.Constants.STARTING_PAGE_INDEX -public class PlacePagingSource( +internal class PlacePagingSource( private val service: PlaceService, private val query: String? = null, private val distance: Double? = null, diff --git a/data/src/main/kotlin/us/wedemy/eggeum/android/data/paging/ReportPagingSource.kt b/data/src/main/kotlin/us/wedemy/eggeum/android/data/paging/ReportPagingSource.kt index a2eec0e4..2b9e14b5 100644 --- a/data/src/main/kotlin/us/wedemy/eggeum/android/data/paging/ReportPagingSource.kt +++ b/data/src/main/kotlin/us/wedemy/eggeum/android/data/paging/ReportPagingSource.kt @@ -17,7 +17,7 @@ import us.wedemy.eggeum.android.data.service.ReportService import us.wedemy.eggeum.android.data.util.Constants.PAGING_SIZE import us.wedemy.eggeum.android.data.util.Constants.STARTING_PAGE_INDEX -public class ReportPagingSource( +internal class ReportPagingSource( private val service: ReportService, ) : PagingSource() { diff --git a/data/src/main/kotlin/us/wedemy/eggeum/android/data/repository/EnumRepositoryImpl.kt b/data/src/main/kotlin/us/wedemy/eggeum/android/data/repository/EnumRepositoryImpl.kt index b4c2c1ee..dd0d45e9 100644 --- a/data/src/main/kotlin/us/wedemy/eggeum/android/data/repository/EnumRepositoryImpl.kt +++ b/data/src/main/kotlin/us/wedemy/eggeum/android/data/repository/EnumRepositoryImpl.kt @@ -24,7 +24,7 @@ import us.wedemy.eggeum.android.domain.repository.EnumRepository // 추후 방법을 알아내어 Ktor 로 이를 구현할 예정 @Singleton -public class EnumRepositoryImpl @Inject constructor( +internal class EnumRepositoryImpl @Inject constructor( @Named("KtorHttpClient") private val client: HttpClient, moshi: Moshi, diff --git a/data/src/main/kotlin/us/wedemy/eggeum/android/data/repository/FileRepositoryImpl.kt b/data/src/main/kotlin/us/wedemy/eggeum/android/data/repository/FileRepositoryImpl.kt index 4f23715a..2cb6bbca 100644 --- a/data/src/main/kotlin/us/wedemy/eggeum/android/data/repository/FileRepositoryImpl.kt +++ b/data/src/main/kotlin/us/wedemy/eggeum/android/data/repository/FileRepositoryImpl.kt @@ -13,7 +13,7 @@ import us.wedemy.eggeum.android.data.mapper.toEntity import us.wedemy.eggeum.android.domain.model.file.FileResponseEntity import us.wedemy.eggeum.android.domain.repository.FileRepository -public class FileRepositoryImpl @Inject constructor( +internal class FileRepositoryImpl @Inject constructor( private val fileDataSource: FileDataSource, ) : FileRepository { override suspend fun uploadImageFile(uri: String): FileResponseEntity { diff --git a/data/src/main/kotlin/us/wedemy/eggeum/android/data/repository/LoginRepositoryImpl.kt b/data/src/main/kotlin/us/wedemy/eggeum/android/data/repository/LoginRepositoryImpl.kt index 31737c50..1cd19b83 100644 --- a/data/src/main/kotlin/us/wedemy/eggeum/android/data/repository/LoginRepositoryImpl.kt +++ b/data/src/main/kotlin/us/wedemy/eggeum/android/data/repository/LoginRepositoryImpl.kt @@ -20,15 +20,15 @@ import us.wedemy.eggeum.android.domain.model.login.SignUpResponseEntity import us.wedemy.eggeum.android.domain.repository.LoginRepository @Singleton -public class LoginRepositoryImpl @Inject constructor( +internal class LoginRepositoryImpl @Inject constructor( private val remoteDataSource: LoginRemoteDataSource, private val localDataSource: LoginLocalDataSource, ) : LoginRepository { - public override suspend fun login(loginRequestEntity: LoginRequestEntity): LoginResponseEntity { + override suspend fun login(loginRequestEntity: LoginRequestEntity): LoginResponseEntity { return remoteDataSource.login(loginRequestEntity.toModel()).toEntity() } - public override suspend fun signUp( + override suspend fun signUp( signUpRequestEntity: SignUpRequestEntity, ): SignUpResponseEntity { return remoteDataSource.signUp(signUpRequestEntity.toModel()).toEntity() diff --git a/data/src/main/kotlin/us/wedemy/eggeum/android/data/repository/NoticeRepositoryImpl.kt b/data/src/main/kotlin/us/wedemy/eggeum/android/data/repository/NoticeRepositoryImpl.kt index 93961e46..4ab142b1 100644 --- a/data/src/main/kotlin/us/wedemy/eggeum/android/data/repository/NoticeRepositoryImpl.kt +++ b/data/src/main/kotlin/us/wedemy/eggeum/android/data/repository/NoticeRepositoryImpl.kt @@ -17,7 +17,7 @@ import us.wedemy.eggeum.android.data.mapper.toEntity import us.wedemy.eggeum.android.domain.model.notice.NoticeEntity import us.wedemy.eggeum.android.domain.repository.NoticeRepository -public class NoticeRepositoryImpl @Inject constructor( +internal class NoticeRepositoryImpl @Inject constructor( private val dataSource: NoticeDataSource, ) : NoticeRepository { override suspend fun getNotice(noticeId: Long): NoticeEntity { diff --git a/data/src/main/kotlin/us/wedemy/eggeum/android/data/repository/PlaceRepositoryImpl.kt b/data/src/main/kotlin/us/wedemy/eggeum/android/data/repository/PlaceRepositoryImpl.kt index 8f8a9792..1dea0b3f 100644 --- a/data/src/main/kotlin/us/wedemy/eggeum/android/data/repository/PlaceRepositoryImpl.kt +++ b/data/src/main/kotlin/us/wedemy/eggeum/android/data/repository/PlaceRepositoryImpl.kt @@ -20,7 +20,7 @@ import us.wedemy.eggeum.android.domain.model.place.PlaceEntity import us.wedemy.eggeum.android.domain.model.place.UpsertPlaceEntity import us.wedemy.eggeum.android.domain.repository.PlaceRepository -public class PlaceRepositoryImpl @Inject constructor( +internal class PlaceRepositoryImpl @Inject constructor( private val remoteDataSource: PlaceRemoteDataSource, private val localDataSource: PlaceLocalDataSource, ) : PlaceRepository { diff --git a/data/src/main/kotlin/us/wedemy/eggeum/android/data/repository/ReportRepositoryImpl.kt b/data/src/main/kotlin/us/wedemy/eggeum/android/data/repository/ReportRepositoryImpl.kt index a7cc9407..7afaced1 100644 --- a/data/src/main/kotlin/us/wedemy/eggeum/android/data/repository/ReportRepositoryImpl.kt +++ b/data/src/main/kotlin/us/wedemy/eggeum/android/data/repository/ReportRepositoryImpl.kt @@ -20,7 +20,7 @@ import us.wedemy.eggeum.android.domain.model.report.ReportEntity import us.wedemy.eggeum.android.domain.model.report.UpdateReportEntity import us.wedemy.eggeum.android.domain.repository.ReportRepository -public class ReportRepositoryImpl @Inject constructor( +internal class ReportRepositoryImpl @Inject constructor( private val dataSource: ReportDataSource, ) : ReportRepository { override suspend fun getReport(reportId: Long): ReportEntity { @@ -43,11 +43,11 @@ public class ReportRepositoryImpl @Inject constructor( } } - public override suspend fun createReport(createReportEntity: CreateReportEntity) { + override suspend fun createReport(createReportEntity: CreateReportEntity) { dataSource.createReport(createReportEntity.toModel()) } - public override suspend fun updateReport(reportId: Long, updateReportEntity: UpdateReportEntity) { + override suspend fun updateReport(reportId: Long, updateReportEntity: UpdateReportEntity) { dataSource.updateReport(reportId, updateReportEntity.toModel()) } } diff --git a/data/src/main/kotlin/us/wedemy/eggeum/android/data/repository/UserRepositoryImpl.kt b/data/src/main/kotlin/us/wedemy/eggeum/android/data/repository/UserRepositoryImpl.kt index d7fbdb06..39ceec3b 100644 --- a/data/src/main/kotlin/us/wedemy/eggeum/android/data/repository/UserRepositoryImpl.kt +++ b/data/src/main/kotlin/us/wedemy/eggeum/android/data/repository/UserRepositoryImpl.kt @@ -17,7 +17,7 @@ import us.wedemy.eggeum.android.domain.model.user.UserInfoEntity import us.wedemy.eggeum.android.domain.repository.UserRepository @Singleton -public class UserRepositoryImpl @Inject constructor( +internal class UserRepositoryImpl @Inject constructor( private val dataSource: UserDataSource, ) : UserRepository { override suspend fun getUserInfo(): UserInfoEntity { diff --git a/data/src/main/kotlin/us/wedemy/eggeum/android/data/service/FileService.kt b/data/src/main/kotlin/us/wedemy/eggeum/android/data/service/FileService.kt index 76a26d90..290ca874 100644 --- a/data/src/main/kotlin/us/wedemy/eggeum/android/data/service/FileService.kt +++ b/data/src/main/kotlin/us/wedemy/eggeum/android/data/service/FileService.kt @@ -13,11 +13,11 @@ import retrofit2.http.POST import retrofit2.http.Part import us.wedemy.eggeum.android.data.model.file.FileResponse -public interface FileService { +internal interface FileService { @Multipart @POST("files/images") - public suspend fun uploadImageFile( + suspend fun uploadImageFile( @Part file: MultipartBody.Part, ): FileResponse } diff --git a/data/src/main/kotlin/us/wedemy/eggeum/android/data/service/LoginService.kt b/data/src/main/kotlin/us/wedemy/eggeum/android/data/service/LoginService.kt index b4150380..eb67ecd0 100644 --- a/data/src/main/kotlin/us/wedemy/eggeum/android/data/service/LoginService.kt +++ b/data/src/main/kotlin/us/wedemy/eggeum/android/data/service/LoginService.kt @@ -14,15 +14,15 @@ import us.wedemy.eggeum.android.data.model.login.LoginResponse import us.wedemy.eggeum.android.data.model.login.SignUpRequest import us.wedemy.eggeum.android.data.model.login.SignUpResponse -public interface LoginService { +internal interface LoginService { @POST("app/sns-sign-in") - public suspend fun login( + suspend fun login( @Body loginRequest: LoginRequest, ): LoginResponse @POST("app/sns-sign-up") - public suspend fun signUp( + suspend fun signUp( @Body signUpRequest: SignUpRequest, ): SignUpResponse } diff --git a/data/src/main/kotlin/us/wedemy/eggeum/android/data/service/NoticeService.kt b/data/src/main/kotlin/us/wedemy/eggeum/android/data/service/NoticeService.kt index 9e2fe442..2970e393 100644 --- a/data/src/main/kotlin/us/wedemy/eggeum/android/data/service/NoticeService.kt +++ b/data/src/main/kotlin/us/wedemy/eggeum/android/data/service/NoticeService.kt @@ -13,15 +13,15 @@ import retrofit2.http.Query import us.wedemy.eggeum.android.data.model.notice.NoticeListResponse import us.wedemy.eggeum.android.data.model.notice.NoticeResponse -public interface NoticeService { +internal interface NoticeService { @GET("app/notice/{noticeId}") - public suspend fun getNotice( + suspend fun getNotice( @Path("noticeId") noticeId: Long, ): NoticeResponse @GET("app/notice/all") - public suspend fun getNoticeList( + suspend fun getNoticeList( @Query("search") search: String? = null, @Query("page") page: Int? = null, @Query("size") size: Int? = null, diff --git a/data/src/main/kotlin/us/wedemy/eggeum/android/data/service/PlaceService.kt b/data/src/main/kotlin/us/wedemy/eggeum/android/data/service/PlaceService.kt index 8a8ecab0..2de0285d 100644 --- a/data/src/main/kotlin/us/wedemy/eggeum/android/data/service/PlaceService.kt +++ b/data/src/main/kotlin/us/wedemy/eggeum/android/data/service/PlaceService.kt @@ -16,15 +16,15 @@ import us.wedemy.eggeum.android.data.model.place.PlaceListResponse import us.wedemy.eggeum.android.data.model.place.PlaceResponse import us.wedemy.eggeum.android.data.model.place.UpsertPlaceRequest -public interface PlaceService { +internal interface PlaceService { @GET("app/place/{placeId}") - public suspend fun getPlace( + suspend fun getPlace( @Path("placeId") placeId: Long, ): PlaceResponse @GET("app/place") - public suspend fun getPlaceList( + suspend fun getPlaceList( @Query("distance") distance: Double? = null, @Query("endDate") endDate: String? = null, @Query("latitude") latitude: Double? = null, @@ -38,7 +38,7 @@ public interface PlaceService { ): PlaceListResponse @POST("app/place/edits") - public suspend fun upsertPlace( + suspend fun upsertPlace( @Body upsertPlaceRequest: UpsertPlaceRequest, ) } diff --git a/data/src/main/kotlin/us/wedemy/eggeum/android/data/service/ReportService.kt b/data/src/main/kotlin/us/wedemy/eggeum/android/data/service/ReportService.kt index fc1d76fa..9118d9a2 100644 --- a/data/src/main/kotlin/us/wedemy/eggeum/android/data/service/ReportService.kt +++ b/data/src/main/kotlin/us/wedemy/eggeum/android/data/service/ReportService.kt @@ -18,27 +18,27 @@ import us.wedemy.eggeum.android.data.model.report.ReportListResponse import us.wedemy.eggeum.android.data.model.report.ReportResponse import us.wedemy.eggeum.android.data.model.report.UpdateReportRequest -public interface ReportService { +internal interface ReportService { @GET("app/report/{reportId}") - public suspend fun getReport( + suspend fun getReport( @Path("reportId") reportId: Long, ): ReportResponse @GET("app/report/list") - public suspend fun getReportList( + suspend fun getReportList( @Query("page") page: Int? = null, @Query("size") size: Int? = null, @Query("sort") sort: String? = null, ): ReportListResponse @POST("app/report/set") - public suspend fun createReport( + suspend fun createReport( @Body createReportRequest: CreateReportRequest, ) @PATCH("app/report/update/{reportId}") - public suspend fun updateReport( + suspend fun updateReport( @Path("reportId") reportId: Long, @Body updateReportRequest: UpdateReportRequest, ) diff --git a/data/src/main/kotlin/us/wedemy/eggeum/android/data/service/TokenAuthenticator.kt b/data/src/main/kotlin/us/wedemy/eggeum/android/data/service/TokenAuthenticator.kt index d727a434..7f32765e 100644 --- a/data/src/main/kotlin/us/wedemy/eggeum/android/data/service/TokenAuthenticator.kt +++ b/data/src/main/kotlin/us/wedemy/eggeum/android/data/service/TokenAuthenticator.kt @@ -11,13 +11,13 @@ import us.wedemy.eggeum.android.data.datasource.token.TokenDataSource import us.wedemy.eggeum.android.data.datastore.TokenDataStoreProvider import us.wedemy.eggeum.android.data.model.token.TokenRequest -public class TokenAuthenticator @Inject constructor( +internal class TokenAuthenticator @Inject constructor( private val dataStoreProvider: TokenDataStoreProvider, private val tokenDataSource: TokenDataSource, ) : Authenticator { override fun authenticate(route: Route?, response: Response): Request? { return runBlocking { - tokenDataSource.getRefreshToken(TokenRequest(dataStoreProvider.getRefreshToken())) + tokenDataSource.getNewAccessToken(TokenRequest(dataStoreProvider.getRefreshToken())) .onSuccess { tokenResponse -> dataStoreProvider.setAccessToken(tokenResponse.accessToken) dataStoreProvider.setRefreshToken(tokenResponse.refreshToken) diff --git a/data/src/main/kotlin/us/wedemy/eggeum/android/data/service/TokenInterceptor.kt b/data/src/main/kotlin/us/wedemy/eggeum/android/data/service/TokenInterceptor.kt index 9a9ff4a5..492000aa 100644 --- a/data/src/main/kotlin/us/wedemy/eggeum/android/data/service/TokenInterceptor.kt +++ b/data/src/main/kotlin/us/wedemy/eggeum/android/data/service/TokenInterceptor.kt @@ -7,7 +7,7 @@ import okhttp3.Response import javax.inject.Inject import us.wedemy.eggeum.android.data.datastore.TokenDataStoreProvider -public class TokenInterceptor @Inject constructor( +internal class TokenInterceptor @Inject constructor( private val dataStoreProvider: TokenDataStoreProvider, ) : Interceptor { override fun intercept(chain: Interceptor.Chain): Response { diff --git a/data/src/main/kotlin/us/wedemy/eggeum/android/data/service/TokenService.kt b/data/src/main/kotlin/us/wedemy/eggeum/android/data/service/TokenService.kt index 13145445..8adee994 100644 --- a/data/src/main/kotlin/us/wedemy/eggeum/android/data/service/TokenService.kt +++ b/data/src/main/kotlin/us/wedemy/eggeum/android/data/service/TokenService.kt @@ -12,10 +12,10 @@ import retrofit2.http.POST import us.wedemy.eggeum.android.data.model.token.TokenRequest import us.wedemy.eggeum.android.data.model.token.TokenResponse -public interface TokenService { +internal interface TokenService { @POST("app/token/refresh") - public suspend fun getRefreshToken( + suspend fun getRefreshToken( @Body tokenRequest: TokenRequest, ): TokenResponse } diff --git a/data/src/main/kotlin/us/wedemy/eggeum/android/data/service/UserService.kt b/data/src/main/kotlin/us/wedemy/eggeum/android/data/service/UserService.kt index b8942f3f..c8dcf080 100644 --- a/data/src/main/kotlin/us/wedemy/eggeum/android/data/service/UserService.kt +++ b/data/src/main/kotlin/us/wedemy/eggeum/android/data/service/UserService.kt @@ -15,25 +15,25 @@ import retrofit2.http.Query import us.wedemy.eggeum.android.data.model.user.UpdateUserInfoRequest import us.wedemy.eggeum.android.data.model.user.UserInfoResponse -public interface UserService { +internal interface UserService { @GET("app/users/me") - public suspend fun getUserInfo(): UserInfoResponse + suspend fun getUserInfo(): UserInfoResponse @PUT("app/users/me") - public suspend fun updateUserInfo( + suspend fun updateUserInfo( @Body updateUserInfoRequest: UpdateUserInfoRequest, ) @DELETE("app/users/me") - public suspend fun withdraw() + suspend fun withdraw() @PUT("app/users/me/nickname") - public suspend fun updateUserNickname( + suspend fun updateUserNickname( @Body nickname: String, ) @GET("app/users/nickname/exists") - public suspend fun checkNicknameExist( + suspend fun checkNicknameExist( @Query("nickname") nickname: String, ): Boolean } diff --git a/data/src/main/kotlin/us/wedemy/eggeum/android/data/util/Constants.kt b/data/src/main/kotlin/us/wedemy/eggeum/android/data/util/Constants.kt index 6ee75ea2..0e2a608a 100644 --- a/data/src/main/kotlin/us/wedemy/eggeum/android/data/util/Constants.kt +++ b/data/src/main/kotlin/us/wedemy/eggeum/android/data/util/Constants.kt @@ -7,8 +7,8 @@ package us.wedemy.eggeum.android.data.util -public object Constants { - public const val SORT_TYPE: String = "sort_type" - public const val STARTING_PAGE_INDEX: Int = 1 - public const val PAGING_SIZE: Int = 10 +internal object Constants { + const val SORT_TYPE: String = "sort_type" + const val STARTING_PAGE_INDEX: Int = 1 + const val PAGING_SIZE: Int = 10 } From 0e67c6cbc45b879f51f199974cc3caa6d3fe712f Mon Sep 17 00:00:00 2001 From: JI HUN LEE <51016231+easyhooon@users.noreply.github.com> Date: Wed, 1 May 2024 17:13:38 +0900 Subject: [PATCH 02/12] =?UTF-8?q?refactor:=20TokenDataSoure=20=ED=86=B5?= =?UTF-8?q?=ED=95=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit data 모듈 접근 제한자 Internal 로 수정 --- .../eggeum/android/data/client/moshi.kt | 4 +- .../login/LoginLocalDataSourceImpl.kt | 4 +- .../data/datasource/token/TokenDataSource.kt | 17 +++++++ .../datasource/token/TokenDataSourceImpl.kt | 44 ++++++++++++++++ .../android/data/datastore/TokenDataStore.kt | 20 -------- .../data/datastore/TokenDataStoreProvider.kt | 51 ------------------- .../eggeum/android/data/di/DataStoreModule.kt | 7 +-- .../eggeum/android/data/di/NetworkModule.kt | 13 +++-- .../wedemy/eggeum/android/data/model/File.kt | 2 +- .../eggeum/android/data/model/ProfileImage.kt | 2 +- .../data/model/enums/EnumListResponse.kt | 2 +- .../android/data/model/file/FileResponse.kt | 2 +- .../android/data/model/login/LoginRequest.kt | 2 +- .../android/data/model/login/LoginResponse.kt | 2 +- .../android/data/model/login/SignUpRequest.kt | 2 +- .../data/model/login/SignUpResponse.kt | 2 +- .../data/model/notice/NoticeListResponse.kt | 2 +- .../data/model/notice/NoticeResponse.kt | 2 +- .../eggeum/android/data/model/place/Image.kt | 2 +- .../eggeum/android/data/model/place/Info.kt | 2 +- .../eggeum/android/data/model/place/Menu.kt | 2 +- .../data/model/place/PlaceListResponse.kt | 2 +- .../android/data/model/place/PlaceResponse.kt | 2 +- .../android/data/model/place/Product.kt | 2 +- .../data/model/place/UpsertPlaceRequest.kt | 2 +- .../data/model/report/CreateReportRequest.kt | 2 +- .../data/model/report/ReportListResponse.kt | 2 +- .../data/model/report/ReportResponse.kt | 2 +- .../data/model/report/UpdateReportRequest.kt | 2 +- .../android/data/model/token/TokenRequest.kt | 2 +- .../android/data/model/token/TokenResponse.kt | 2 +- .../data/model/user/UpdateUserInfoRequest.kt | 2 +- .../model/user/UpdateUserNicknameRequest.kt | 2 +- .../eggeum/android/data/model/user/User.kt | 2 +- .../data/model/user/UserInfoResponse.kt | 2 +- .../data/service/TokenAuthenticator.kt | 8 ++- .../android/data/service/TokenInterceptor.kt | 8 +-- 37 files changed, 106 insertions(+), 124 deletions(-) delete mode 100644 data/src/main/kotlin/us/wedemy/eggeum/android/data/datastore/TokenDataStore.kt delete mode 100644 data/src/main/kotlin/us/wedemy/eggeum/android/data/datastore/TokenDataStoreProvider.kt diff --git a/data/src/main/kotlin/us/wedemy/eggeum/android/data/client/moshi.kt b/data/src/main/kotlin/us/wedemy/eggeum/android/data/client/moshi.kt index 9957eac6..66ccb31d 100644 --- a/data/src/main/kotlin/us/wedemy/eggeum/android/data/client/moshi.kt +++ b/data/src/main/kotlin/us/wedemy/eggeum/android/data/client/moshi.kt @@ -17,9 +17,9 @@ import dagger.hilt.components.SingletonComponent @Suppress("unused") @Module @InstallIn(SingletonComponent::class) -public object MoshiProvider { +internal object MoshiProvider { @Provides - public fun defaultMoshi(): Moshi = Moshi.Builder() + fun defaultMoshi(): Moshi = Moshi.Builder() .add(KotlinJsonAdapterFactory()) .build() } diff --git a/data/src/main/kotlin/us/wedemy/eggeum/android/data/datasource/login/LoginLocalDataSourceImpl.kt b/data/src/main/kotlin/us/wedemy/eggeum/android/data/datasource/login/LoginLocalDataSourceImpl.kt index b649fa69..ef7f4f68 100644 --- a/data/src/main/kotlin/us/wedemy/eggeum/android/data/datasource/login/LoginLocalDataSourceImpl.kt +++ b/data/src/main/kotlin/us/wedemy/eggeum/android/data/datasource/login/LoginLocalDataSourceImpl.kt @@ -8,10 +8,10 @@ package us.wedemy.eggeum.android.data.datasource.login import javax.inject.Inject -import us.wedemy.eggeum.android.data.datastore.TokenDataStoreProvider +import us.wedemy.eggeum.android.data.datasource.token.TokenDataSourceImpl internal class LoginLocalDataSourceImpl @Inject constructor( - private val dataStore: TokenDataStoreProvider, + private val dataStore: TokenDataSourceImpl, ) : LoginLocalDataSource { override suspend fun setAccessToken(accessToken: String) { dataStore.setAccessToken(accessToken) diff --git a/data/src/main/kotlin/us/wedemy/eggeum/android/data/datasource/token/TokenDataSource.kt b/data/src/main/kotlin/us/wedemy/eggeum/android/data/datasource/token/TokenDataSource.kt index a4579026..a71c140b 100644 --- a/data/src/main/kotlin/us/wedemy/eggeum/android/data/datasource/token/TokenDataSource.kt +++ b/data/src/main/kotlin/us/wedemy/eggeum/android/data/datasource/token/TokenDataSource.kt @@ -5,11 +5,28 @@ * Please see full license: https://github.com/Wedemy/eggeum-android/blob/main/LICENSE */ +/* + * Designed and developed by Wedemy 2023. + * + * Licensed under the MIT. + * Please see full license: https://github.com/Wedemy/eggeum-android/blob/main/LICENSE + */ + package us.wedemy.eggeum.android.data.datasource.token import us.wedemy.eggeum.android.data.model.token.TokenRequest import us.wedemy.eggeum.android.data.model.token.TokenResponse internal interface TokenDataSource { + suspend fun setAccessToken(accessToken: String) + + suspend fun setRefreshToken(refreshToken: String) + + suspend fun getAccessToken(): String + + suspend fun getRefreshToken(): String + + suspend fun clear() + suspend fun getNewAccessToken(tokenRequest: TokenRequest): Result } diff --git a/data/src/main/kotlin/us/wedemy/eggeum/android/data/datasource/token/TokenDataSourceImpl.kt b/data/src/main/kotlin/us/wedemy/eggeum/android/data/datasource/token/TokenDataSourceImpl.kt index 7e2835a3..14692374 100644 --- a/data/src/main/kotlin/us/wedemy/eggeum/android/data/datasource/token/TokenDataSourceImpl.kt +++ b/data/src/main/kotlin/us/wedemy/eggeum/android/data/datasource/token/TokenDataSourceImpl.kt @@ -5,17 +5,61 @@ * Please see full license: https://github.com/Wedemy/eggeum-android/blob/main/LICENSE */ +/* + * Designed and developed by Wedemy 2023. + * + * Licensed under the MIT. + * Please see full license: https://github.com/Wedemy/eggeum-android/blob/main/LICENSE + */ + package us.wedemy.eggeum.android.data.datasource.token +import androidx.datastore.core.DataStore +import androidx.datastore.preferences.core.Preferences +import androidx.datastore.preferences.core.edit +import androidx.datastore.preferences.core.emptyPreferences +import androidx.datastore.preferences.core.stringPreferencesKey +import java.io.IOException import javax.inject.Inject +import kotlinx.coroutines.flow.catch +import kotlinx.coroutines.flow.first import us.wedemy.eggeum.android.data.model.token.TokenRequest import us.wedemy.eggeum.android.data.model.token.TokenResponse import us.wedemy.eggeum.android.data.service.TokenService import us.wedemy.eggeum.android.domain.util.runSuspendCatching internal class TokenDataSourceImpl @Inject constructor( + private val dataStore: DataStore, private val service: TokenService, ) : TokenDataSource { + private companion object { + private val KEY_ACCESS_TOKEN = stringPreferencesKey("access_token") + private val KEY_REFRESH_TOKEN = stringPreferencesKey("refresh_token") + } + + override suspend fun setAccessToken(accessToken: String) { + dataStore.edit { preferences -> preferences[KEY_ACCESS_TOKEN] = accessToken } + } + + override suspend fun setRefreshToken(refreshToken: String) { + dataStore.edit { preferences -> preferences[KEY_REFRESH_TOKEN] = refreshToken } + } + + override suspend fun getAccessToken(): String = dataStore.data + .catch { exception -> + if (exception is IOException) emit(emptyPreferences()) + else throw exception + }.first()[KEY_ACCESS_TOKEN] ?: "" + + override suspend fun getRefreshToken(): String = dataStore.data + .catch { exception -> + if (exception is IOException) emit(emptyPreferences()) + else throw exception + }.first()[KEY_REFRESH_TOKEN] ?: "" + + override suspend fun clear() { + dataStore.edit { it.clear() } + } override suspend fun getNewAccessToken(tokenRequest: TokenRequest): Result = runSuspendCatching { diff --git a/data/src/main/kotlin/us/wedemy/eggeum/android/data/datastore/TokenDataStore.kt b/data/src/main/kotlin/us/wedemy/eggeum/android/data/datastore/TokenDataStore.kt deleted file mode 100644 index 170033bb..00000000 --- a/data/src/main/kotlin/us/wedemy/eggeum/android/data/datastore/TokenDataStore.kt +++ /dev/null @@ -1,20 +0,0 @@ -/* - * Designed and developed by Wedemy 2023. - * - * Licensed under the MIT. - * Please see full license: https://github.com/Wedemy/eggeum-android/blob/main/LICENSE - */ - -package us.wedemy.eggeum.android.data.datastore - -public interface TokenDataStore { - public suspend fun setAccessToken(accessToken: String) - - public suspend fun setRefreshToken(refreshToken: String) - - public suspend fun getAccessToken(): String - - public suspend fun getRefreshToken(): String - - public suspend fun clear() -} diff --git a/data/src/main/kotlin/us/wedemy/eggeum/android/data/datastore/TokenDataStoreProvider.kt b/data/src/main/kotlin/us/wedemy/eggeum/android/data/datastore/TokenDataStoreProvider.kt deleted file mode 100644 index 89c3fe6b..00000000 --- a/data/src/main/kotlin/us/wedemy/eggeum/android/data/datastore/TokenDataStoreProvider.kt +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Designed and developed by Wedemy 2023. - * - * Licensed under the MIT. - * Please see full license: https://github.com/Wedemy/eggeum-android/blob/main/LICENSE - */ - -package us.wedemy.eggeum.android.data.datastore - -import androidx.datastore.core.DataStore -import androidx.datastore.preferences.core.Preferences -import androidx.datastore.preferences.core.edit -import androidx.datastore.preferences.core.emptyPreferences -import androidx.datastore.preferences.core.stringPreferencesKey -import java.io.IOException -import javax.inject.Inject -import kotlinx.coroutines.flow.catch -import kotlinx.coroutines.flow.first - -public class TokenDataStoreProvider @Inject constructor( - private val dataStore: DataStore, -) : TokenDataStore { - private companion object { - private val KEY_ACCESS_TOKEN = stringPreferencesKey("access_token") - private val KEY_REFRESH_TOKEN = stringPreferencesKey("refresh_token") - } - - override suspend fun setAccessToken(accessToken: String) { - dataStore.edit { preferences -> preferences[KEY_ACCESS_TOKEN] = accessToken } - } - - override suspend fun setRefreshToken(refreshToken: String) { - dataStore.edit { preferences -> preferences[KEY_REFRESH_TOKEN] = refreshToken } - } - - override suspend fun getAccessToken(): String = dataStore.data - .catch { exception -> - if (exception is IOException) emit(emptyPreferences()) - else throw exception - }.first()[KEY_ACCESS_TOKEN] ?: "" - - override suspend fun getRefreshToken(): String = dataStore.data - .catch { exception -> - if (exception is IOException) emit(emptyPreferences()) - else throw exception - }.first()[KEY_REFRESH_TOKEN] ?: "" - - override suspend fun clear() { - dataStore.edit { it.clear() } - } -} diff --git a/data/src/main/kotlin/us/wedemy/eggeum/android/data/di/DataStoreModule.kt b/data/src/main/kotlin/us/wedemy/eggeum/android/data/di/DataStoreModule.kt index 25cf52df..d1a96f82 100644 --- a/data/src/main/kotlin/us/wedemy/eggeum/android/data/di/DataStoreModule.kt +++ b/data/src/main/kotlin/us/wedemy/eggeum/android/data/di/DataStoreModule.kt @@ -17,7 +17,6 @@ import dagger.hilt.InstallIn import dagger.hilt.android.qualifiers.ApplicationContext import dagger.hilt.components.SingletonComponent import javax.inject.Singleton -import us.wedemy.eggeum.android.data.datastore.TokenDataStoreProvider private const val TOKEN_DATASTORE = "token_datastore" private val Context.tokenDataStore: DataStore by preferencesDataStore(name = TOKEN_DATASTORE) @@ -28,9 +27,5 @@ internal object DataStoreModule { @Singleton @Provides - internal fun providePreferencesDataStore(@ApplicationContext context: Context) = context.tokenDataStore - - @Singleton - @Provides - internal fun provideTokenDataStore(dataStore: DataStore) = TokenDataStoreProvider(dataStore) + internal fun provideTokenDataStore(@ApplicationContext context: Context) = context.tokenDataStore } diff --git a/data/src/main/kotlin/us/wedemy/eggeum/android/data/di/NetworkModule.kt b/data/src/main/kotlin/us/wedemy/eggeum/android/data/di/NetworkModule.kt index 47a3c7f6..fc43053f 100644 --- a/data/src/main/kotlin/us/wedemy/eggeum/android/data/di/NetworkModule.kt +++ b/data/src/main/kotlin/us/wedemy/eggeum/android/data/di/NetworkModule.kt @@ -36,7 +36,7 @@ import retrofit2.Retrofit import timber.log.Timber import us.wedemy.eggeum.android.data.BuildConfig import us.wedemy.eggeum.android.data.datasource.token.TokenDataSource -import us.wedemy.eggeum.android.data.datastore.TokenDataStoreProvider +import us.wedemy.eggeum.android.data.datasource.token.TokenDataSourceImpl import us.wedemy.eggeum.android.data.service.TokenAuthenticator import us.wedemy.eggeum.android.data.service.TokenInterceptor import us.wedemy.eggeum.android.data.util.JsonBuilder @@ -85,7 +85,7 @@ internal object NetworkModule { @Singleton @Named("KtorHttpClient") @Provides - internal fun provideKtorApiHttpClient(dataStoreProvider: TokenDataStoreProvider): HttpClient { + internal fun provideKtorApiHttpClient(dataStoreImpl: TokenDataSourceImpl): HttpClient { return HttpClient(engineFactory = CIO) { engine { endpoint { @@ -95,7 +95,7 @@ internal object NetworkModule { } defaultRequest { val accessToken = runBlocking { - dataStoreProvider.getAccessToken() + dataStoreImpl.getAccessToken() } url(BuildConfig.SERVER_BASE_URL) contentType(ContentType.Application.Json) @@ -129,18 +129,17 @@ internal object NetworkModule { @Singleton @Provides internal fun provideTokenAuthenticator( - dataStoreProvider: TokenDataStoreProvider, tokenDataSource: TokenDataSource, ): TokenAuthenticator { - return TokenAuthenticator(dataStoreProvider, tokenDataSource) + return TokenAuthenticator(tokenDataSource) } @Singleton @Provides internal fun provideTokenInterceptor( - dataStoreProvider: TokenDataStoreProvider, + tokenDataSource: TokenDataSource, ): TokenInterceptor { - return TokenInterceptor(dataStoreProvider) + return TokenInterceptor(tokenDataSource) } @Singleton diff --git a/data/src/main/kotlin/us/wedemy/eggeum/android/data/model/File.kt b/data/src/main/kotlin/us/wedemy/eggeum/android/data/model/File.kt index 6b5e1b48..cddd0dbe 100644 --- a/data/src/main/kotlin/us/wedemy/eggeum/android/data/model/File.kt +++ b/data/src/main/kotlin/us/wedemy/eggeum/android/data/model/File.kt @@ -11,7 +11,7 @@ import kotlinx.serialization.SerialName import kotlinx.serialization.Serializable @Serializable -public data class File( +internal data class File( @SerialName("uploadFileId") val uploadFileId: Long?, diff --git a/data/src/main/kotlin/us/wedemy/eggeum/android/data/model/ProfileImage.kt b/data/src/main/kotlin/us/wedemy/eggeum/android/data/model/ProfileImage.kt index 4320e216..3275682c 100644 --- a/data/src/main/kotlin/us/wedemy/eggeum/android/data/model/ProfileImage.kt +++ b/data/src/main/kotlin/us/wedemy/eggeum/android/data/model/ProfileImage.kt @@ -11,7 +11,7 @@ import kotlinx.serialization.SerialName import kotlinx.serialization.Serializable @Serializable -public data class ProfileImage( +internal data class ProfileImage( @SerialName("files") val files: List, ) diff --git a/data/src/main/kotlin/us/wedemy/eggeum/android/data/model/enums/EnumListResponse.kt b/data/src/main/kotlin/us/wedemy/eggeum/android/data/model/enums/EnumListResponse.kt index 6916797d..17414bac 100644 --- a/data/src/main/kotlin/us/wedemy/eggeum/android/data/model/enums/EnumListResponse.kt +++ b/data/src/main/kotlin/us/wedemy/eggeum/android/data/model/enums/EnumListResponse.kt @@ -14,7 +14,7 @@ import com.squareup.moshi.JsonClass // 추후 방법을 알아내어 Ktor 로 이를 구현할 예정 @JsonClass(generateAdapter = true) -public data class EnumListResponse( +internal data class EnumListResponse( @Json(name = "additionalProp1") val additionalProp1: List, diff --git a/data/src/main/kotlin/us/wedemy/eggeum/android/data/model/file/FileResponse.kt b/data/src/main/kotlin/us/wedemy/eggeum/android/data/model/file/FileResponse.kt index ab6cde43..778c5a35 100644 --- a/data/src/main/kotlin/us/wedemy/eggeum/android/data/model/file/FileResponse.kt +++ b/data/src/main/kotlin/us/wedemy/eggeum/android/data/model/file/FileResponse.kt @@ -11,7 +11,7 @@ import kotlinx.serialization.SerialName import kotlinx.serialization.Serializable @Serializable -public data class FileResponse( +internal data class FileResponse( @SerialName("name") val name: String?, diff --git a/data/src/main/kotlin/us/wedemy/eggeum/android/data/model/login/LoginRequest.kt b/data/src/main/kotlin/us/wedemy/eggeum/android/data/model/login/LoginRequest.kt index de91d81d..dcf06a1a 100644 --- a/data/src/main/kotlin/us/wedemy/eggeum/android/data/model/login/LoginRequest.kt +++ b/data/src/main/kotlin/us/wedemy/eggeum/android/data/model/login/LoginRequest.kt @@ -11,7 +11,7 @@ import kotlinx.serialization.SerialName import kotlinx.serialization.Serializable @Serializable -public data class LoginRequest( +internal data class LoginRequest( @SerialName("idToken") val idToken: String, ) diff --git a/data/src/main/kotlin/us/wedemy/eggeum/android/data/model/login/LoginResponse.kt b/data/src/main/kotlin/us/wedemy/eggeum/android/data/model/login/LoginResponse.kt index db0bc054..f879e461 100644 --- a/data/src/main/kotlin/us/wedemy/eggeum/android/data/model/login/LoginResponse.kt +++ b/data/src/main/kotlin/us/wedemy/eggeum/android/data/model/login/LoginResponse.kt @@ -11,7 +11,7 @@ import kotlinx.serialization.SerialName import kotlinx.serialization.Serializable @Serializable -public data class LoginResponse( +internal data class LoginResponse( @SerialName("accessToken") val accessToken: String, diff --git a/data/src/main/kotlin/us/wedemy/eggeum/android/data/model/login/SignUpRequest.kt b/data/src/main/kotlin/us/wedemy/eggeum/android/data/model/login/SignUpRequest.kt index 542e8db7..e8e46d5f 100644 --- a/data/src/main/kotlin/us/wedemy/eggeum/android/data/model/login/SignUpRequest.kt +++ b/data/src/main/kotlin/us/wedemy/eggeum/android/data/model/login/SignUpRequest.kt @@ -11,7 +11,7 @@ import kotlinx.serialization.SerialName import kotlinx.serialization.Serializable @Serializable -public data class SignUpRequest( +internal data class SignUpRequest( @SerialName("agreemMarketing") val agreemMarketing: Boolean?, diff --git a/data/src/main/kotlin/us/wedemy/eggeum/android/data/model/login/SignUpResponse.kt b/data/src/main/kotlin/us/wedemy/eggeum/android/data/model/login/SignUpResponse.kt index b954dfbf..18f07c02 100644 --- a/data/src/main/kotlin/us/wedemy/eggeum/android/data/model/login/SignUpResponse.kt +++ b/data/src/main/kotlin/us/wedemy/eggeum/android/data/model/login/SignUpResponse.kt @@ -11,7 +11,7 @@ import kotlinx.serialization.SerialName import kotlinx.serialization.Serializable @Serializable -public data class SignUpResponse( +internal data class SignUpResponse( @SerialName("accessToken") val accessToken: String, diff --git a/data/src/main/kotlin/us/wedemy/eggeum/android/data/model/notice/NoticeListResponse.kt b/data/src/main/kotlin/us/wedemy/eggeum/android/data/model/notice/NoticeListResponse.kt index 8cfe1881..563b083a 100644 --- a/data/src/main/kotlin/us/wedemy/eggeum/android/data/model/notice/NoticeListResponse.kt +++ b/data/src/main/kotlin/us/wedemy/eggeum/android/data/model/notice/NoticeListResponse.kt @@ -11,7 +11,7 @@ import kotlinx.serialization.SerialName import kotlinx.serialization.Serializable @Serializable -public data class NoticeListResponse( +internal data class NoticeListResponse( @SerialName("list") val list: List, diff --git a/data/src/main/kotlin/us/wedemy/eggeum/android/data/model/notice/NoticeResponse.kt b/data/src/main/kotlin/us/wedemy/eggeum/android/data/model/notice/NoticeResponse.kt index 5d02ed2a..c058ea96 100644 --- a/data/src/main/kotlin/us/wedemy/eggeum/android/data/model/notice/NoticeResponse.kt +++ b/data/src/main/kotlin/us/wedemy/eggeum/android/data/model/notice/NoticeResponse.kt @@ -11,7 +11,7 @@ import kotlinx.serialization.SerialName import kotlinx.serialization.Serializable @Serializable -public data class NoticeResponse( +internal data class NoticeResponse( @SerialName("id") val id: Long, diff --git a/data/src/main/kotlin/us/wedemy/eggeum/android/data/model/place/Image.kt b/data/src/main/kotlin/us/wedemy/eggeum/android/data/model/place/Image.kt index 6f05c5ca..ec1890bb 100644 --- a/data/src/main/kotlin/us/wedemy/eggeum/android/data/model/place/Image.kt +++ b/data/src/main/kotlin/us/wedemy/eggeum/android/data/model/place/Image.kt @@ -12,7 +12,7 @@ import kotlinx.serialization.Serializable import us.wedemy.eggeum.android.data.model.File @Serializable -public data class Image( +internal data class Image( @SerialName("files") val files: List?, ) diff --git a/data/src/main/kotlin/us/wedemy/eggeum/android/data/model/place/Info.kt b/data/src/main/kotlin/us/wedemy/eggeum/android/data/model/place/Info.kt index 308d793a..ba1b6213 100644 --- a/data/src/main/kotlin/us/wedemy/eggeum/android/data/model/place/Info.kt +++ b/data/src/main/kotlin/us/wedemy/eggeum/android/data/model/place/Info.kt @@ -11,7 +11,7 @@ import kotlinx.serialization.SerialName import kotlinx.serialization.Serializable @Serializable -public data class Info( +internal data class Info( @SerialName("areaSize") val areaSize: String?, diff --git a/data/src/main/kotlin/us/wedemy/eggeum/android/data/model/place/Menu.kt b/data/src/main/kotlin/us/wedemy/eggeum/android/data/model/place/Menu.kt index d2ae5c14..07193ac8 100644 --- a/data/src/main/kotlin/us/wedemy/eggeum/android/data/model/place/Menu.kt +++ b/data/src/main/kotlin/us/wedemy/eggeum/android/data/model/place/Menu.kt @@ -11,7 +11,7 @@ import kotlinx.serialization.SerialName import kotlinx.serialization.Serializable @Serializable -public data class Menu( +internal data class Menu( @SerialName("products") val products: List?, ) diff --git a/data/src/main/kotlin/us/wedemy/eggeum/android/data/model/place/PlaceListResponse.kt b/data/src/main/kotlin/us/wedemy/eggeum/android/data/model/place/PlaceListResponse.kt index 5521be25..1efcc750 100644 --- a/data/src/main/kotlin/us/wedemy/eggeum/android/data/model/place/PlaceListResponse.kt +++ b/data/src/main/kotlin/us/wedemy/eggeum/android/data/model/place/PlaceListResponse.kt @@ -11,7 +11,7 @@ import kotlinx.serialization.SerialName import kotlinx.serialization.Serializable @Serializable -public data class PlaceListResponse( +internal data class PlaceListResponse( @SerialName("list") val list: List, diff --git a/data/src/main/kotlin/us/wedemy/eggeum/android/data/model/place/PlaceResponse.kt b/data/src/main/kotlin/us/wedemy/eggeum/android/data/model/place/PlaceResponse.kt index af548d44..9c74b3e7 100644 --- a/data/src/main/kotlin/us/wedemy/eggeum/android/data/model/place/PlaceResponse.kt +++ b/data/src/main/kotlin/us/wedemy/eggeum/android/data/model/place/PlaceResponse.kt @@ -14,7 +14,7 @@ import kotlinx.serialization.Serializable @Serializable @Entity(tableName = "places") -public data class PlaceResponse( +internal data class PlaceResponse( @SerialName("address1") val address1: String?, diff --git a/data/src/main/kotlin/us/wedemy/eggeum/android/data/model/place/Product.kt b/data/src/main/kotlin/us/wedemy/eggeum/android/data/model/place/Product.kt index d91c251f..884d1f84 100644 --- a/data/src/main/kotlin/us/wedemy/eggeum/android/data/model/place/Product.kt +++ b/data/src/main/kotlin/us/wedemy/eggeum/android/data/model/place/Product.kt @@ -11,7 +11,7 @@ import kotlinx.serialization.SerialName import kotlinx.serialization.Serializable @Serializable -public data class Product( +internal data class Product( @SerialName("name") val name: String, diff --git a/data/src/main/kotlin/us/wedemy/eggeum/android/data/model/place/UpsertPlaceRequest.kt b/data/src/main/kotlin/us/wedemy/eggeum/android/data/model/place/UpsertPlaceRequest.kt index 1fec8b53..3b9ef79f 100644 --- a/data/src/main/kotlin/us/wedemy/eggeum/android/data/model/place/UpsertPlaceRequest.kt +++ b/data/src/main/kotlin/us/wedemy/eggeum/android/data/model/place/UpsertPlaceRequest.kt @@ -11,7 +11,7 @@ import kotlinx.serialization.SerialName import kotlinx.serialization.Serializable @Serializable -public data class UpsertPlaceRequest( +internal data class UpsertPlaceRequest( @SerialName("address1") val address1: String?, diff --git a/data/src/main/kotlin/us/wedemy/eggeum/android/data/model/report/CreateReportRequest.kt b/data/src/main/kotlin/us/wedemy/eggeum/android/data/model/report/CreateReportRequest.kt index 9d25469f..7dc8e274 100644 --- a/data/src/main/kotlin/us/wedemy/eggeum/android/data/model/report/CreateReportRequest.kt +++ b/data/src/main/kotlin/us/wedemy/eggeum/android/data/model/report/CreateReportRequest.kt @@ -11,7 +11,7 @@ import kotlinx.serialization.SerialName import kotlinx.serialization.Serializable @Serializable -public data class CreateReportRequest( +internal data class CreateReportRequest( @SerialName("title") val title: String, diff --git a/data/src/main/kotlin/us/wedemy/eggeum/android/data/model/report/ReportListResponse.kt b/data/src/main/kotlin/us/wedemy/eggeum/android/data/model/report/ReportListResponse.kt index b0f5eb14..5a830341 100644 --- a/data/src/main/kotlin/us/wedemy/eggeum/android/data/model/report/ReportListResponse.kt +++ b/data/src/main/kotlin/us/wedemy/eggeum/android/data/model/report/ReportListResponse.kt @@ -11,7 +11,7 @@ import kotlinx.serialization.SerialName import kotlinx.serialization.Serializable @Serializable -public data class ReportListResponse( +internal data class ReportListResponse( @SerialName("list") val list: List, diff --git a/data/src/main/kotlin/us/wedemy/eggeum/android/data/model/report/ReportResponse.kt b/data/src/main/kotlin/us/wedemy/eggeum/android/data/model/report/ReportResponse.kt index 96500119..516f2ae9 100644 --- a/data/src/main/kotlin/us/wedemy/eggeum/android/data/model/report/ReportResponse.kt +++ b/data/src/main/kotlin/us/wedemy/eggeum/android/data/model/report/ReportResponse.kt @@ -12,7 +12,7 @@ import kotlinx.serialization.Serializable import us.wedemy.eggeum.android.data.model.user.User @Serializable -public data class ReportResponse( +internal data class ReportResponse( @SerialName("content") val content: String, diff --git a/data/src/main/kotlin/us/wedemy/eggeum/android/data/model/report/UpdateReportRequest.kt b/data/src/main/kotlin/us/wedemy/eggeum/android/data/model/report/UpdateReportRequest.kt index 143d02ad..d376c2ee 100644 --- a/data/src/main/kotlin/us/wedemy/eggeum/android/data/model/report/UpdateReportRequest.kt +++ b/data/src/main/kotlin/us/wedemy/eggeum/android/data/model/report/UpdateReportRequest.kt @@ -11,7 +11,7 @@ import kotlinx.serialization.SerialName import kotlinx.serialization.Serializable @Serializable -public data class UpdateReportRequest( +internal data class UpdateReportRequest( @SerialName("title") val title: String, diff --git a/data/src/main/kotlin/us/wedemy/eggeum/android/data/model/token/TokenRequest.kt b/data/src/main/kotlin/us/wedemy/eggeum/android/data/model/token/TokenRequest.kt index bcf416df..c511da91 100644 --- a/data/src/main/kotlin/us/wedemy/eggeum/android/data/model/token/TokenRequest.kt +++ b/data/src/main/kotlin/us/wedemy/eggeum/android/data/model/token/TokenRequest.kt @@ -11,7 +11,7 @@ import kotlinx.serialization.SerialName import kotlinx.serialization.Serializable @Serializable -public data class TokenRequest( +internal data class TokenRequest( @SerialName("refreshToken") val refreshToken: String, ) diff --git a/data/src/main/kotlin/us/wedemy/eggeum/android/data/model/token/TokenResponse.kt b/data/src/main/kotlin/us/wedemy/eggeum/android/data/model/token/TokenResponse.kt index 63e97e9e..12fb47a7 100644 --- a/data/src/main/kotlin/us/wedemy/eggeum/android/data/model/token/TokenResponse.kt +++ b/data/src/main/kotlin/us/wedemy/eggeum/android/data/model/token/TokenResponse.kt @@ -11,7 +11,7 @@ import kotlinx.serialization.SerialName import kotlinx.serialization.Serializable @Serializable -public data class TokenResponse( +internal data class TokenResponse( @SerialName("accessToken") val accessToken: String, diff --git a/data/src/main/kotlin/us/wedemy/eggeum/android/data/model/user/UpdateUserInfoRequest.kt b/data/src/main/kotlin/us/wedemy/eggeum/android/data/model/user/UpdateUserInfoRequest.kt index 0a79fff4..809c9a55 100644 --- a/data/src/main/kotlin/us/wedemy/eggeum/android/data/model/user/UpdateUserInfoRequest.kt +++ b/data/src/main/kotlin/us/wedemy/eggeum/android/data/model/user/UpdateUserInfoRequest.kt @@ -12,7 +12,7 @@ import kotlinx.serialization.Serializable import us.wedemy.eggeum.android.data.model.ProfileImage @Serializable -public data class UpdateUserInfoRequest( +internal data class UpdateUserInfoRequest( @SerialName("nickname") val nickname: String, diff --git a/data/src/main/kotlin/us/wedemy/eggeum/android/data/model/user/UpdateUserNicknameRequest.kt b/data/src/main/kotlin/us/wedemy/eggeum/android/data/model/user/UpdateUserNicknameRequest.kt index b78f2791..f1a9a0ae 100644 --- a/data/src/main/kotlin/us/wedemy/eggeum/android/data/model/user/UpdateUserNicknameRequest.kt +++ b/data/src/main/kotlin/us/wedemy/eggeum/android/data/model/user/UpdateUserNicknameRequest.kt @@ -11,7 +11,7 @@ import kotlinx.serialization.SerialName import kotlinx.serialization.Serializable @Serializable -public data class UpdateUserNicknameRequest( +internal data class UpdateUserNicknameRequest( @SerialName("nickname") val nickname: String, ) diff --git a/data/src/main/kotlin/us/wedemy/eggeum/android/data/model/user/User.kt b/data/src/main/kotlin/us/wedemy/eggeum/android/data/model/user/User.kt index a178fb17..c09a6fb2 100644 --- a/data/src/main/kotlin/us/wedemy/eggeum/android/data/model/user/User.kt +++ b/data/src/main/kotlin/us/wedemy/eggeum/android/data/model/user/User.kt @@ -12,7 +12,7 @@ import kotlinx.serialization.Serializable import us.wedemy.eggeum.android.data.model.ProfileImage @Serializable -public data class User( +internal data class User( @SerialName("agreeMarketing") val agreeMarketing: Boolean, diff --git a/data/src/main/kotlin/us/wedemy/eggeum/android/data/model/user/UserInfoResponse.kt b/data/src/main/kotlin/us/wedemy/eggeum/android/data/model/user/UserInfoResponse.kt index 29183c96..4b290bb2 100644 --- a/data/src/main/kotlin/us/wedemy/eggeum/android/data/model/user/UserInfoResponse.kt +++ b/data/src/main/kotlin/us/wedemy/eggeum/android/data/model/user/UserInfoResponse.kt @@ -12,7 +12,7 @@ import kotlinx.serialization.Serializable import us.wedemy.eggeum.android.data.model.ProfileImage @Serializable -public data class UserInfoResponse( +internal data class UserInfoResponse( @SerialName("agreeMarketing") val agreeMarketing: Boolean, diff --git a/data/src/main/kotlin/us/wedemy/eggeum/android/data/service/TokenAuthenticator.kt b/data/src/main/kotlin/us/wedemy/eggeum/android/data/service/TokenAuthenticator.kt index 7f32765e..334d4dba 100644 --- a/data/src/main/kotlin/us/wedemy/eggeum/android/data/service/TokenAuthenticator.kt +++ b/data/src/main/kotlin/us/wedemy/eggeum/android/data/service/TokenAuthenticator.kt @@ -8,19 +8,17 @@ import okhttp3.Response import okhttp3.Route import us.wedemy.eggeum.android.common.util.RefreshTokenExpiredException import us.wedemy.eggeum.android.data.datasource.token.TokenDataSource -import us.wedemy.eggeum.android.data.datastore.TokenDataStoreProvider import us.wedemy.eggeum.android.data.model.token.TokenRequest internal class TokenAuthenticator @Inject constructor( - private val dataStoreProvider: TokenDataStoreProvider, private val tokenDataSource: TokenDataSource, ) : Authenticator { override fun authenticate(route: Route?, response: Response): Request? { return runBlocking { - tokenDataSource.getNewAccessToken(TokenRequest(dataStoreProvider.getRefreshToken())) + tokenDataSource.getNewAccessToken(TokenRequest(tokenDataSource.getRefreshToken())) .onSuccess { tokenResponse -> - dataStoreProvider.setAccessToken(tokenResponse.accessToken) - dataStoreProvider.setRefreshToken(tokenResponse.refreshToken) + tokenDataSource.setAccessToken(tokenResponse.accessToken) + tokenDataSource.setRefreshToken(tokenResponse.refreshToken) }.map { tokenResponse -> newRequestWithAccessToken(response.request, tokenResponse.accessToken) }.onFailure { diff --git a/data/src/main/kotlin/us/wedemy/eggeum/android/data/service/TokenInterceptor.kt b/data/src/main/kotlin/us/wedemy/eggeum/android/data/service/TokenInterceptor.kt index 492000aa..456c45dd 100644 --- a/data/src/main/kotlin/us/wedemy/eggeum/android/data/service/TokenInterceptor.kt +++ b/data/src/main/kotlin/us/wedemy/eggeum/android/data/service/TokenInterceptor.kt @@ -1,18 +1,18 @@ package us.wedemy.eggeum.android.data.service +import javax.inject.Inject import kotlinx.coroutines.runBlocking import okhttp3.Interceptor import okhttp3.Request import okhttp3.Response -import javax.inject.Inject -import us.wedemy.eggeum.android.data.datastore.TokenDataStoreProvider +import us.wedemy.eggeum.android.data.datasource.token.TokenDataSource internal class TokenInterceptor @Inject constructor( - private val dataStoreProvider: TokenDataStoreProvider, + private val tokenDataSource: TokenDataSource, ) : Interceptor { override fun intercept(chain: Interceptor.Chain): Response { val accessToken = runBlocking { - dataStoreProvider.getAccessToken() + tokenDataSource.getAccessToken() } val request: Request = chain.request().newBuilder() .addHeader("Authorization", "Bearer $accessToken") From da19054f4e25c6247dd1c0b503a2002cef81fb0a Mon Sep 17 00:00:00 2001 From: JI HUN LEE <51016231+easyhooon@users.noreply.github.com> Date: Wed, 1 May 2024 17:38:40 +0900 Subject: [PATCH 03/12] =?UTF-8?q?fix:=20=EC=9C=A0=EC=A0=80=20=EB=8B=89?= =?UTF-8?q?=EB=84=A4=EC=9E=84=20=EB=B3=80=EA=B2=BD=20=EB=A1=9C=EC=A7=81=20?= =?UTF-8?q?=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 닉네임만 변경한 경우 내 정보 수정 API 가 아닌, 닉네임 수정 API 호출 하도록 변경 --- .../data/datasource/user/UserDataSource.kt | 3 +- .../datasource/user/UserDataSourceImpl.kt | 5 ++-- .../eggeum/android/data/mapper/UserMapper.kt | 7 +++++ .../data/repository/UserRepositoryImpl.kt | 5 ++-- .../android/data/service/UserService.kt | 3 +- .../model/user/UpdateUserNicknameEntity.kt | 12 ++++++++ .../domain/repository/UserRepository.kt | 5 ++-- .../android/domain/usecase/UserUseCase.kt | 7 +++-- .../main/ui/myaccount/EditMyInfoFragment.kt | 2 +- .../main/viewmodel/EditMyInfoViewModel.kt | 28 +++++++++---------- 10 files changed, 50 insertions(+), 27 deletions(-) create mode 100644 domain/src/main/kotlin/us/wedemy/eggeum/android/domain/model/user/UpdateUserNicknameEntity.kt diff --git a/data/src/main/kotlin/us/wedemy/eggeum/android/data/datasource/user/UserDataSource.kt b/data/src/main/kotlin/us/wedemy/eggeum/android/data/datasource/user/UserDataSource.kt index 7d3a1e5e..181dde1a 100644 --- a/data/src/main/kotlin/us/wedemy/eggeum/android/data/datasource/user/UserDataSource.kt +++ b/data/src/main/kotlin/us/wedemy/eggeum/android/data/datasource/user/UserDataSource.kt @@ -8,6 +8,7 @@ package us.wedemy.eggeum.android.data.datasource.user import us.wedemy.eggeum.android.data.model.user.UpdateUserInfoRequest +import us.wedemy.eggeum.android.data.model.user.UpdateUserNicknameRequest import us.wedemy.eggeum.android.data.model.user.UserInfoResponse internal interface UserDataSource { @@ -17,7 +18,7 @@ internal interface UserDataSource { suspend fun withdraw() - suspend fun updateUserNickname(nickname: String) + suspend fun updateUserNickname(updateUserNicknameRequest: UpdateUserNicknameRequest) suspend fun checkNicknameExist(nickname: String): Boolean } diff --git a/data/src/main/kotlin/us/wedemy/eggeum/android/data/datasource/user/UserDataSourceImpl.kt b/data/src/main/kotlin/us/wedemy/eggeum/android/data/datasource/user/UserDataSourceImpl.kt index f2e8cb8f..a6d2f6e9 100644 --- a/data/src/main/kotlin/us/wedemy/eggeum/android/data/datasource/user/UserDataSourceImpl.kt +++ b/data/src/main/kotlin/us/wedemy/eggeum/android/data/datasource/user/UserDataSourceImpl.kt @@ -10,6 +10,7 @@ package us.wedemy.eggeum.android.data.datasource.user import javax.inject.Inject import javax.inject.Singleton import us.wedemy.eggeum.android.data.model.user.UpdateUserInfoRequest +import us.wedemy.eggeum.android.data.model.user.UpdateUserNicknameRequest import us.wedemy.eggeum.android.data.model.user.UserInfoResponse import us.wedemy.eggeum.android.data.service.UserService @@ -29,8 +30,8 @@ internal class UserDataSourceImpl @Inject constructor( service.withdraw() } - override suspend fun updateUserNickname(nickname: String) { - service.updateUserNickname(nickname) + override suspend fun updateUserNickname(updateUserNicknameRequest: UpdateUserNicknameRequest) { + service.updateUserNickname(updateUserNicknameRequest) } override suspend fun checkNicknameExist(nickname: String): Boolean { diff --git a/data/src/main/kotlin/us/wedemy/eggeum/android/data/mapper/UserMapper.kt b/data/src/main/kotlin/us/wedemy/eggeum/android/data/mapper/UserMapper.kt index 808a5256..8004e258 100644 --- a/data/src/main/kotlin/us/wedemy/eggeum/android/data/mapper/UserMapper.kt +++ b/data/src/main/kotlin/us/wedemy/eggeum/android/data/mapper/UserMapper.kt @@ -9,9 +9,11 @@ package us.wedemy.eggeum.android.data.mapper import us.wedemy.eggeum.android.data.model.user.User import us.wedemy.eggeum.android.data.model.user.UpdateUserInfoRequest +import us.wedemy.eggeum.android.data.model.user.UpdateUserNicknameRequest import us.wedemy.eggeum.android.data.model.user.UserInfoResponse import us.wedemy.eggeum.android.domain.model.report.UserEntity import us.wedemy.eggeum.android.domain.model.user.UpdateUserInfoEntity +import us.wedemy.eggeum.android.domain.model.user.UpdateUserNicknameEntity import us.wedemy.eggeum.android.domain.model.user.UserInfoEntity internal fun UserInfoResponse.toEntity() = @@ -32,6 +34,11 @@ internal fun UpdateUserInfoEntity.toModel() = profileImage = profileImageEntity?.toModel(), ) +internal fun UpdateUserNicknameEntity.toModel() = + UpdateUserNicknameRequest( + nickname = nickname, + ) + internal fun User.toEntity() = UserEntity( agreeMarketing = agreeMarketing, diff --git a/data/src/main/kotlin/us/wedemy/eggeum/android/data/repository/UserRepositoryImpl.kt b/data/src/main/kotlin/us/wedemy/eggeum/android/data/repository/UserRepositoryImpl.kt index 39ceec3b..0a6dd949 100644 --- a/data/src/main/kotlin/us/wedemy/eggeum/android/data/repository/UserRepositoryImpl.kt +++ b/data/src/main/kotlin/us/wedemy/eggeum/android/data/repository/UserRepositoryImpl.kt @@ -13,6 +13,7 @@ import us.wedemy.eggeum.android.data.datasource.user.UserDataSource import us.wedemy.eggeum.android.data.mapper.toEntity import us.wedemy.eggeum.android.data.mapper.toModel import us.wedemy.eggeum.android.domain.model.user.UpdateUserInfoEntity +import us.wedemy.eggeum.android.domain.model.user.UpdateUserNicknameEntity import us.wedemy.eggeum.android.domain.model.user.UserInfoEntity import us.wedemy.eggeum.android.domain.repository.UserRepository @@ -32,8 +33,8 @@ internal class UserRepositoryImpl @Inject constructor( dataSource.withdraw() } - override suspend fun updateUserNickname(nickname: String) { - dataSource.updateUserNickname(nickname) + override suspend fun updateUserNickname(updateUserNicknameEntity: UpdateUserNicknameEntity) { + dataSource.updateUserNickname(updateUserNicknameEntity.toModel()) } override suspend fun checkNicknameExist(nickname: String): Boolean { diff --git a/data/src/main/kotlin/us/wedemy/eggeum/android/data/service/UserService.kt b/data/src/main/kotlin/us/wedemy/eggeum/android/data/service/UserService.kt index c8dcf080..946d910a 100644 --- a/data/src/main/kotlin/us/wedemy/eggeum/android/data/service/UserService.kt +++ b/data/src/main/kotlin/us/wedemy/eggeum/android/data/service/UserService.kt @@ -13,6 +13,7 @@ import retrofit2.http.GET import retrofit2.http.PUT import retrofit2.http.Query import us.wedemy.eggeum.android.data.model.user.UpdateUserInfoRequest +import us.wedemy.eggeum.android.data.model.user.UpdateUserNicknameRequest import us.wedemy.eggeum.android.data.model.user.UserInfoResponse internal interface UserService { @@ -29,7 +30,7 @@ internal interface UserService { @PUT("app/users/me/nickname") suspend fun updateUserNickname( - @Body nickname: String, + @Body updateUserNicknameRequest: UpdateUserNicknameRequest, ) @GET("app/users/nickname/exists") diff --git a/domain/src/main/kotlin/us/wedemy/eggeum/android/domain/model/user/UpdateUserNicknameEntity.kt b/domain/src/main/kotlin/us/wedemy/eggeum/android/domain/model/user/UpdateUserNicknameEntity.kt new file mode 100644 index 00000000..00949630 --- /dev/null +++ b/domain/src/main/kotlin/us/wedemy/eggeum/android/domain/model/user/UpdateUserNicknameEntity.kt @@ -0,0 +1,12 @@ +/* + * Designed and developed by Wedemy 2023. + * + * Licensed under the MIT. + * Please see full license: https://github.com/Wedemy/eggeum-android/blob/main/LICENSE + */ + +package us.wedemy.eggeum.android.domain.model.user + +public data class UpdateUserNicknameEntity( + val nickname: String, +) diff --git a/domain/src/main/kotlin/us/wedemy/eggeum/android/domain/repository/UserRepository.kt b/domain/src/main/kotlin/us/wedemy/eggeum/android/domain/repository/UserRepository.kt index 1990e61e..7e33f5c0 100644 --- a/domain/src/main/kotlin/us/wedemy/eggeum/android/domain/repository/UserRepository.kt +++ b/domain/src/main/kotlin/us/wedemy/eggeum/android/domain/repository/UserRepository.kt @@ -8,6 +8,7 @@ package us.wedemy.eggeum.android.domain.repository import us.wedemy.eggeum.android.domain.model.user.UpdateUserInfoEntity +import us.wedemy.eggeum.android.domain.model.user.UpdateUserNicknameEntity import us.wedemy.eggeum.android.domain.model.user.UserInfoEntity /** 사용자 API */ @@ -33,9 +34,9 @@ public interface UserRepository { /** * 닉네임 수정 * - * @param nickname 닉네임 + * @param updateUserNicknameEntity */ - public suspend fun updateUserNickname(nickname: String) + public suspend fun updateUserNickname(updateUserNicknameEntity: UpdateUserNicknameEntity) /** * 닉네임 존재여부 조회 diff --git a/domain/src/main/kotlin/us/wedemy/eggeum/android/domain/usecase/UserUseCase.kt b/domain/src/main/kotlin/us/wedemy/eggeum/android/domain/usecase/UserUseCase.kt index 09531dee..7613c491 100644 --- a/domain/src/main/kotlin/us/wedemy/eggeum/android/domain/usecase/UserUseCase.kt +++ b/domain/src/main/kotlin/us/wedemy/eggeum/android/domain/usecase/UserUseCase.kt @@ -10,6 +10,7 @@ package us.wedemy.eggeum.android.domain.usecase import javax.inject.Inject import javax.inject.Singleton import us.wedemy.eggeum.android.domain.model.user.UpdateUserInfoEntity +import us.wedemy.eggeum.android.domain.model.user.UpdateUserNicknameEntity import us.wedemy.eggeum.android.domain.model.user.UserInfoEntity import us.wedemy.eggeum.android.domain.repository.UserRepository import us.wedemy.eggeum.android.domain.util.runSuspendCatching @@ -25,7 +26,7 @@ public class GetUserInfoUseCase @Inject constructor( } @Singleton -public class UpdateUserInfoUseCase @Inject constructor( +public class UpdateUserProfileAndNicknameUseCase @Inject constructor( private val repository: UserRepository, ) { public suspend operator fun invoke(updateUserInfoEntity: UpdateUserInfoEntity): Result = @@ -48,9 +49,9 @@ public class WithdrawUseCase @Inject constructor( public class UpdateUserNicknameUseCase @Inject constructor( private val repository: UserRepository, ) { - public suspend operator fun invoke(nickname: String): Result = + public suspend operator fun invoke(updateUserNicknameEntity: UpdateUserNicknameEntity): Result = runSuspendCatching { - repository.updateUserNickname(nickname) + repository.updateUserNickname(updateUserNicknameEntity) } } diff --git a/main/src/main/kotlin/us/wedemy/eggeum/android/main/ui/myaccount/EditMyInfoFragment.kt b/main/src/main/kotlin/us/wedemy/eggeum/android/main/ui/myaccount/EditMyInfoFragment.kt index 837cfb86..ec71fdb8 100644 --- a/main/src/main/kotlin/us/wedemy/eggeum/android/main/ui/myaccount/EditMyInfoFragment.kt +++ b/main/src/main/kotlin/us/wedemy/eggeum/android/main/ui/myaccount/EditMyInfoFragment.kt @@ -62,7 +62,7 @@ class EditMyInfoFragment : BaseFragment() { } binding.btnEditMyInfo.setOnClickListener { - viewModel.updateUserNickname() + viewModel.updateUserInfo() } } diff --git a/main/src/main/kotlin/us/wedemy/eggeum/android/main/viewmodel/EditMyInfoViewModel.kt b/main/src/main/kotlin/us/wedemy/eggeum/android/main/viewmodel/EditMyInfoViewModel.kt index ec22039e..0f4e651c 100644 --- a/main/src/main/kotlin/us/wedemy/eggeum/android/main/viewmodel/EditMyInfoViewModel.kt +++ b/main/src/main/kotlin/us/wedemy/eggeum/android/main/viewmodel/EditMyInfoViewModel.kt @@ -30,18 +30,20 @@ import us.wedemy.eggeum.android.common.util.handleException import us.wedemy.eggeum.android.domain.model.FileEntity import us.wedemy.eggeum.android.domain.model.ProfileImageEntity import us.wedemy.eggeum.android.domain.model.user.UpdateUserInfoEntity +import us.wedemy.eggeum.android.domain.model.user.UpdateUserNicknameEntity import us.wedemy.eggeum.android.domain.usecase.CheckNicknameExistUseCase import us.wedemy.eggeum.android.domain.usecase.LogoutUseCase -import us.wedemy.eggeum.android.domain.usecase.UpdateUserInfoUseCase +import us.wedemy.eggeum.android.domain.usecase.UpdateUserNicknameUseCase +import us.wedemy.eggeum.android.domain.usecase.UpdateUserProfileAndNicknameUseCase import us.wedemy.eggeum.android.domain.usecase.UploadImageFileUseCase import us.wedemy.eggeum.android.main.R -import us.wedemy.eggeum.android.main.mapper.toEntity import us.wedemy.eggeum.android.main.model.UserInfoModel @HiltViewModel class EditMyInfoViewModel @Inject constructor( private val uploadImageFileUseCase: UploadImageFileUseCase, - private val updateUserInfoUseCase: UpdateUserInfoUseCase, + private val updateUserProfileAndNicknameUseCase: UpdateUserProfileAndNicknameUseCase, + private val updateUserNicknameUseCase: UpdateUserNicknameUseCase, private val checkNicknameExistUseCase: CheckNicknameExistUseCase, private val logoutUseCase: LogoutUseCase, savedStateHandle: SavedStateHandle, @@ -139,28 +141,24 @@ class EditMyInfoViewModel @Inject constructor( } } - fun updateUserNickname() { + fun updateUserInfo() { viewModelScope.launch { if (newProfileImageUri.value != null && newProfileImageUri.value != userInfo.value.profileImageModel?.files?.get(0)?.url) { getUploadFileId(newProfileImageUri.value!!) } else { - updateUserInfoUseCase( - UpdateUserInfoEntity( - nickname = _nickname.value, - profileImageEntity = userInfo.value.profileImageModel?.toEntity(), - ), - ).onSuccess { - _userInfoUpdateSuccessEvent.emit(Unit) - }.onFailure { exception -> - handleException(exception, this@EditMyInfoViewModel) - } + updateUserNicknameUseCase(UpdateUserNicknameEntity(nickname = _nickname.value)) + .onSuccess { + _userInfoUpdateSuccessEvent.emit(Unit) + }.onFailure { exception -> + handleException(exception, this@EditMyInfoViewModel) + } } } } private fun updateUserProfileAndNickname(file: FileEntity) { viewModelScope.launch { - updateUserInfoUseCase( + updateUserProfileAndNicknameUseCase( UpdateUserInfoEntity( nickname = _nickname.value, profileImageEntity = ProfileImageEntity(files = listOf(file)), From 2b7aceb7fd348b19da6d4e4dcdb91e01729a3374 Mon Sep 17 00:00:00 2001 From: JI HUN LEE <51016231+easyhooon@users.noreply.github.com> Date: Wed, 1 May 2024 19:13:32 +0900 Subject: [PATCH 04/12] =?UTF-8?q?fix:=20@Named=20=ED=8C=8C=EB=9D=BC?= =?UTF-8?q?=EB=AF=B8=ED=84=B0=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../eggeum/android/data/di/NetworkModule.kt | 25 +++++++++---------- .../eggeum/android/data/di/ServiceModule.kt | 10 +++----- 2 files changed, 15 insertions(+), 20 deletions(-) diff --git a/data/src/main/kotlin/us/wedemy/eggeum/android/data/di/NetworkModule.kt b/data/src/main/kotlin/us/wedemy/eggeum/android/data/di/NetworkModule.kt index fc43053f..1801725c 100644 --- a/data/src/main/kotlin/us/wedemy/eggeum/android/data/di/NetworkModule.kt +++ b/data/src/main/kotlin/us/wedemy/eggeum/android/data/di/NetworkModule.kt @@ -57,9 +57,9 @@ private val jsonRule = Json { internal object NetworkModule { @Singleton - @Named("KtorAuthHttpClient") + @Named("Auth") @Provides - internal fun provideKtorHttpClient(): HttpClient { + internal fun provideKtor(): HttpClient { return HttpClient(engineFactory = CIO) { engine { endpoint { @@ -85,7 +85,7 @@ internal object NetworkModule { @Singleton @Named("KtorHttpClient") @Provides - internal fun provideKtorApiHttpClient(dataStoreImpl: TokenDataSourceImpl): HttpClient { + internal fun provideKtorApi(dataStoreImpl: TokenDataSourceImpl): HttpClient { return HttpClient(engineFactory = CIO) { engine { endpoint { @@ -144,8 +144,8 @@ internal object NetworkModule { @Singleton @Provides - @Named("RetrofitAuthHttpClient") - internal fun provideRetrofitAuthHttpClient( + @Named("Auth") + internal fun provideAuthRetrofit( httpLoggingInterceptor: HttpLoggingInterceptor, ): Retrofit { val contentType = "application/json".toMediaType() @@ -163,8 +163,7 @@ internal object NetworkModule { @Singleton @Provides - @Named("RetrofitHttpClient") - internal fun provideRetrofitHttpClient( + internal fun provideRetrofit( tokenInterceptor: TokenInterceptor, tokenAuthenticator: TokenAuthenticator, httpLoggingInterceptor: HttpLoggingInterceptor, @@ -172,10 +171,10 @@ internal object NetworkModule { val contentType = "application/json".toMediaType() val httpClient = OkHttpClient.Builder() .connectTimeout(MaxTimeoutMillis, TimeUnit.MILLISECONDS) - // To set the token in the header - .addInterceptor(tokenInterceptor) // To update the token when it gets HTTP unauthorized error .authenticator(tokenAuthenticator) + // To set the token in the header + .addInterceptor(tokenInterceptor) .addInterceptor(httpLoggingInterceptor) .build() @@ -188,8 +187,8 @@ internal object NetworkModule { @Singleton @Provides - @Named("RetrofitFileHttpClient") - internal fun provideRetrofitFileHttpClient( + @Named("Multipart") + internal fun provideFileRetrofit( tokenAuthenticator: TokenAuthenticator, tokenInterceptor: TokenInterceptor, httpLoggingInterceptor: HttpLoggingInterceptor, @@ -199,10 +198,10 @@ internal object NetworkModule { .connectTimeout(MaxTimeoutMillis, TimeUnit.MILLISECONDS) .readTimeout(MaxTimeoutMillis, TimeUnit.MILLISECONDS) .writeTimeout(MaxTimeoutMillis, TimeUnit.MILLISECONDS) - // To set the token in the header - .addInterceptor(tokenInterceptor) // To update the token when it gets HTTP unauthorized error .authenticator(tokenAuthenticator) + // To set the token in the header + .addInterceptor(tokenInterceptor) .addInterceptor(httpLoggingInterceptor) .build() diff --git a/data/src/main/kotlin/us/wedemy/eggeum/android/data/di/ServiceModule.kt b/data/src/main/kotlin/us/wedemy/eggeum/android/data/di/ServiceModule.kt index b180e9fd..56686e92 100644 --- a/data/src/main/kotlin/us/wedemy/eggeum/android/data/di/ServiceModule.kt +++ b/data/src/main/kotlin/us/wedemy/eggeum/android/data/di/ServiceModule.kt @@ -29,7 +29,7 @@ internal object ServiceModule { @Singleton @Provides internal fun provideLoginService( - @Named("RetrofitAuthHttpClient") + @Named("Auth") retrofit: Retrofit, ): LoginService { return retrofit.create(LoginService::class.java) @@ -38,7 +38,6 @@ internal object ServiceModule { @Singleton @Provides internal fun provideNoticeService( - @Named("RetrofitHttpClient") retrofit: Retrofit, ): NoticeService { return retrofit.create(NoticeService::class.java) @@ -47,7 +46,6 @@ internal object ServiceModule { @Singleton @Provides internal fun providePlaceService( - @Named("RetrofitHttpClient") retrofit: Retrofit, ): PlaceService { return retrofit.create(PlaceService::class.java) @@ -56,7 +54,6 @@ internal object ServiceModule { @Singleton @Provides internal fun provideReportService( - @Named("RetrofitHttpClient") retrofit: Retrofit, ): ReportService { return retrofit.create(ReportService::class.java) @@ -65,7 +62,6 @@ internal object ServiceModule { @Singleton @Provides internal fun provideUserService( - @Named("RetrofitHttpClient") retrofit: Retrofit, ): UserService { return retrofit.create(UserService::class.java) @@ -74,7 +70,7 @@ internal object ServiceModule { @Singleton @Provides internal fun provideFileService( - @Named("RetrofitFileHttpClient") + @Named("Multipart") retrofit: Retrofit, ): FileService { return retrofit.create(FileService::class.java) @@ -83,7 +79,7 @@ internal object ServiceModule { @Singleton @Provides internal fun provideTokenService( - @Named("RetrofitAuthHttpClient") + @Named("Auth") retrofit: Retrofit, ): TokenService { return retrofit.create(TokenService::class.java) From 330da907942d45d38032132db78b80709419f41a Mon Sep 17 00:00:00 2001 From: JI HUN LEE <51016231+easyhooon@users.noreply.github.com> Date: Thu, 2 May 2024 05:04:53 +0900 Subject: [PATCH 05/12] =?UTF-8?q?feat:=20=ED=98=84=20=EC=A7=80=EB=8F=84?= =?UTF-8?q?=EC=97=90=EC=84=9C=20=EA=B2=80=EC=83=89=20=EB=B2=84=ED=8A=BC=20?= =?UTF-8?q?=EC=9C=84=EC=B9=98=20=EB=B3=80=EA=B2=BD=EC=97=90=20=EB=94=B0?= =?UTF-8?q?=EB=A5=B8=20=ED=99=9C=EC=84=B1=ED=99=94/=EB=B9=84=ED=99=9C?= =?UTF-8?q?=EC=84=B1=ED=99=94=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../android/main/ui/search/SearchFragment.kt | 55 ++++++++++++++----- .../android/main/viewmodel/SearchViewModel.kt | 14 +++++ 2 files changed, 55 insertions(+), 14 deletions(-) diff --git a/main/src/main/kotlin/us/wedemy/eggeum/android/main/ui/search/SearchFragment.kt b/main/src/main/kotlin/us/wedemy/eggeum/android/main/ui/search/SearchFragment.kt index 3cc5a1b6..f897f45b 100644 --- a/main/src/main/kotlin/us/wedemy/eggeum/android/main/ui/search/SearchFragment.kt +++ b/main/src/main/kotlin/us/wedemy/eggeum/android/main/ui/search/SearchFragment.kt @@ -39,14 +39,14 @@ import kotlinx.coroutines.flow.collectLatest import kotlinx.coroutines.flow.distinctUntilChangedBy import kotlinx.coroutines.launch import timber.log.Timber +import us.wedemy.eggeum.android.common.base.BaseFragment import us.wedemy.eggeum.android.common.extension.repeatOnStarted import us.wedemy.eggeum.android.common.extension.safeNavigate -import us.wedemy.eggeum.android.common.base.BaseFragment +import us.wedemy.eggeum.android.common.model.CafeDetailModel import us.wedemy.eggeum.android.domain.model.place.PlaceEntity import us.wedemy.eggeum.android.main.R import us.wedemy.eggeum.android.main.databinding.FragmentSearchBinding import us.wedemy.eggeum.android.main.mapper.toUiModel -import us.wedemy.eggeum.android.common.model.CafeDetailModel import us.wedemy.eggeum.android.main.ui.adapter.SearchCafeAdapter import us.wedemy.eggeum.android.main.viewmodel.CafeDetailViewModel import us.wedemy.eggeum.android.main.viewmodel.SearchViewModel @@ -115,17 +115,25 @@ class SearchFragment : BaseFragment(), OnMapReadyCallback } private fun initListener() { - binding.fabSearchTracking.setOnClickListener { - naverMap?.locationTrackingMode = LocationTrackingMode.Follow - } - - binding.tietSearchCafe.setOnClickListener { - binding.cvSearchCafe.performClick() - } - - binding.cvSearchCafe.setOnClickListener { - val action = SearchFragmentDirections.actionFragmentSearchToFragmentSearchCafeFragment(searchViewModel.currentLocation.value) - findNavController().safeNavigate(action) + with(binding) { + fabSearchTracking.setOnClickListener { + naverMap?.locationTrackingMode = LocationTrackingMode.Follow + } + tietSearchCafe.setOnClickListener { + cvSearchCafe.performClick() + } + cvSearchCafe.setOnClickListener { + val action = + SearchFragmentDirections.actionFragmentSearchToFragmentSearchCafeFragment(searchViewModel.currentLocation.value) + findNavController().safeNavigate(action) + } + cvCurrentMapSearchCafe.setOnClickListener { + binding.cvCurrentMapSearchCafe.visibility = View.GONE + searchViewModel.setInitialCameraLocation( + searchViewModel.lastCameraLocation.value.latitude, + searchViewModel.lastCameraLocation.value.longitude + ) + } } } @@ -147,6 +155,16 @@ class SearchFragment : BaseFragment(), OnMapReadyCallback } } } + + launch { + searchViewModel.lastCameraLocation.collect { lastCameraLocation -> + if (lastCameraLocation != searchViewModel.initialCameraLocation.value && searchViewModel.initialCameraLocation.value.latitude != -1.0) { + binding.cvCurrentMapSearchCafe.visibility = View.VISIBLE + } else { + binding.cvCurrentMapSearchCafe.visibility = View.GONE + } + } + } } } @@ -207,6 +225,12 @@ class SearchFragment : BaseFragment(), OnMapReadyCallback ZOOM_LEVEL, ) setLayerGroupEnabled(NaverMap.LAYER_GROUP_BUILDING, true) + addOnCameraChangeListener { _, _ -> + searchViewModel.setLastCameraLocation( + cameraPosition.target.latitude, + cameraPosition.target.longitude + ) + } } moveToCameraToUserLocation() } @@ -217,8 +241,11 @@ class SearchFragment : BaseFragment(), OnMapReadyCallback val cameraUpdate = CameraUpdate.scrollTo(LatLng(location.latitude, location.longitude)) naverMap?.moveCamera(cameraUpdate) Timber.d("Current Location ${location.latitude} ${location.longitude}") - searchViewModel.setCurrentLocation(location.latitude, location.longitude) + if (searchViewModel.initialCameraLocation.value.latitude == -1.0) { + searchViewModel.setInitialCameraLocation(location.latitude, location.longitude) + Timber.d("Initial Camera Location initialized ${searchViewModel.initialCameraLocation.value.latitude} ${searchViewModel.initialCameraLocation.value.longitude}") + } } } diff --git a/main/src/main/kotlin/us/wedemy/eggeum/android/main/viewmodel/SearchViewModel.kt b/main/src/main/kotlin/us/wedemy/eggeum/android/main/viewmodel/SearchViewModel.kt index b736cd98..ce0dfe34 100644 --- a/main/src/main/kotlin/us/wedemy/eggeum/android/main/viewmodel/SearchViewModel.kt +++ b/main/src/main/kotlin/us/wedemy/eggeum/android/main/viewmodel/SearchViewModel.kt @@ -30,10 +30,24 @@ class SearchViewModel @Inject constructor( private val _currentLocation = MutableStateFlow(LatLng(-1.0, -1.0)) val currentLocation: StateFlow = _currentLocation.asStateFlow() + private val _initialCameraLocation = MutableStateFlow(LatLng(-1.0, -1.0)) + val initialCameraLocation: StateFlow = _initialCameraLocation.asStateFlow() + + private val _lastCameraLocation = MutableStateFlow(LatLng(-1.0, -1.0)) + val lastCameraLocation: StateFlow = _lastCameraLocation.asStateFlow() + fun setCurrentLocation(latitude: Double, longitude: Double) { _currentLocation.value = LatLng(latitude, longitude) } + fun setInitialCameraLocation(latitude: Double, longitude: Double) { + _initialCameraLocation.value = LatLng(latitude, longitude) + } + + fun setLastCameraLocation(latitude: Double, longitude: Double) { + _lastCameraLocation.value = LatLng(latitude, longitude) + } + // TODO 맵 zoom level, 내 위치가 변하면 값이 갱신 되어야 함 // 반경 2.5km 내에 위치한 장소에 마커가 찍히도록 @OptIn(ExperimentalCoroutinesApi::class) From cf0950ca60f9e6e293e2dee21e0bf78b340d09cf Mon Sep 17 00:00:00 2001 From: JI HUN LEE <51016231+easyhooon@users.noreply.github.com> Date: Thu, 2 May 2024 05:08:38 +0900 Subject: [PATCH 06/12] =?UTF-8?q?feat:=20=ED=98=84=20=EC=A7=80=EB=8F=84?= =?UTF-8?q?=EC=97=90=EC=84=9C=20=EA=B2=80=EC=83=89=20=EA=B8=B0=EB=8A=A5=20?= =?UTF-8?q?=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../wedemy/eggeum/android/main/ui/search/SearchFragment.kt | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/main/src/main/kotlin/us/wedemy/eggeum/android/main/ui/search/SearchFragment.kt b/main/src/main/kotlin/us/wedemy/eggeum/android/main/ui/search/SearchFragment.kt index f897f45b..017c39b1 100644 --- a/main/src/main/kotlin/us/wedemy/eggeum/android/main/ui/search/SearchFragment.kt +++ b/main/src/main/kotlin/us/wedemy/eggeum/android/main/ui/search/SearchFragment.kt @@ -128,11 +128,15 @@ class SearchFragment : BaseFragment(), OnMapReadyCallback findNavController().safeNavigate(action) } cvCurrentMapSearchCafe.setOnClickListener { - binding.cvCurrentMapSearchCafe.visibility = View.GONE searchViewModel.setInitialCameraLocation( searchViewModel.lastCameraLocation.value.latitude, searchViewModel.lastCameraLocation.value.longitude ) + searchViewModel.setCurrentLocation( + searchViewModel.lastCameraLocation.value.latitude, + searchViewModel.lastCameraLocation.value.longitude + ) + cvCurrentMapSearchCafe.visibility = View.GONE } } } From a3f8b085253177978c1ebfc224e39464546e3d23 Mon Sep 17 00:00:00 2001 From: JI HUN LEE <51016231+easyhooon@users.noreply.github.com> Date: Thu, 2 May 2024 05:39:32 +0900 Subject: [PATCH 07/12] =?UTF-8?q?feat:=20=ED=98=84=20=EC=A7=80=EB=8F=84?= =?UTF-8?q?=EC=97=90=EC=84=9C=20=EA=B2=80=EC=83=89=20=EC=8B=9C,=20?= =?UTF-8?q?=EC=9D=B4=EC=A0=84=20=EB=A7=88=EC=BB=A4=20=EC=A0=9C=EA=B1=B0=20?= =?UTF-8?q?=EB=A1=9C=EC=A7=81=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit SearchFragment 코드 최적화 --- .../android/main/ui/search/SearchFragment.kt | 114 +++++++++--------- 1 file changed, 54 insertions(+), 60 deletions(-) diff --git a/main/src/main/kotlin/us/wedemy/eggeum/android/main/ui/search/SearchFragment.kt b/main/src/main/kotlin/us/wedemy/eggeum/android/main/ui/search/SearchFragment.kt index 017c39b1..0b16ba53 100644 --- a/main/src/main/kotlin/us/wedemy/eggeum/android/main/ui/search/SearchFragment.kt +++ b/main/src/main/kotlin/us/wedemy/eggeum/android/main/ui/search/SearchFragment.kt @@ -38,7 +38,6 @@ import dagger.hilt.android.AndroidEntryPoint import kotlinx.coroutines.flow.collectLatest import kotlinx.coroutines.flow.distinctUntilChangedBy import kotlinx.coroutines.launch -import timber.log.Timber import us.wedemy.eggeum.android.common.base.BaseFragment import us.wedemy.eggeum.android.common.extension.repeatOnStarted import us.wedemy.eggeum.android.common.extension.safeNavigate @@ -69,8 +68,9 @@ class SearchFragment : BaseFragment(), OnMapReadyCallback private var permissionsGranted = false private val requestMultiplePermissionsLauncher = - registerForActivityResult(ActivityResultContracts.RequestMultiplePermissions()) { _ -> - if (isPermissionsGranted()) { + registerForActivityResult(ActivityResultContracts.RequestMultiplePermissions()) { permissions -> + permissionsGranted = permissions.entries.all { it.value } + if (permissionsGranted) { permissionsGranted = true moveToCameraToUserLocation() naverMap?.locationTrackingMode = LocationTrackingMode.Follow @@ -92,25 +92,40 @@ class SearchFragment : BaseFragment(), OnMapReadyCallback } override fun onMapReady(naverMap: NaverMap) { - this.naverMap = naverMap + this.naverMap = naverMap.apply { + cameraPosition = CameraPosition( + LatLng(cameraPosition.target.latitude, cameraPosition.target.longitude), + ZOOM_LEVEL, + ) + uiSettings.isScaleBarEnabled = false + uiSettings.isZoomControlEnabled = false + locationSource = this@SearchFragment.locationSource + addOnCameraChangeListener { _, _ -> + searchViewModel.setLastCameraLocation(cameraPosition.target.latitude, cameraPosition.target.longitude) + } + } if (permissionsGranted) { naverMap.locationTrackingMode = LocationTrackingMode.Follow + moveToCameraToUserLocation() } - initNaverMap() addMarkersToMap(searchCafeAdapter.snapshot()) } - private fun isPermissionsGranted(): Boolean { - return permissions.all { + private fun checkPermission() { + val allPermissionsGranted = permissions.all { ContextCompat.checkSelfPermission(requireContext(), it) == PackageManager.PERMISSION_GRANTED } - } - private fun checkPermission() { - if (shouldShowPermissionRationale()) { - showLocationPermissionRationaleDialog() + if (!allPermissionsGranted) { + if (shouldShowPermissionRationale()) { + showLocationPermissionRationaleDialog() + } else { + requestPermissions() + } } else { - requestPermissions() + permissionsGranted = true + naverMap?.locationTrackingMode = LocationTrackingMode.Follow + moveToCameraToUserLocation() } } @@ -173,24 +188,30 @@ class SearchFragment : BaseFragment(), OnMapReadyCallback } private fun addMarkersToMap(snapshot: ItemSnapshotList) { + clearMarkers() snapshot.toList().forEach { place -> - if (place != null) { - createAndAddMarker(place) + place?.let { + createAndAddMarker(it) } } } + private fun clearMarkers() { + markers.forEach { marker -> + marker.map = null + } + markers.clear() + } + private fun createAndAddMarker(data: PlaceEntity) { - val marker = Marker() - if (data.latitude != null && data.longitude != null) { - marker.position = LatLng(data.latitude!!, data.longitude!!) - markers.add(marker) - marker.map = naverMap + val marker = Marker().apply { + position = LatLng(data.latitude ?: return, data.longitude ?: return) + icon = OverlayImage.fromResource(us.wedemy.eggeum.android.design.R.drawable.ic_map_marker_24) + map = naverMap + tag = data.id + onClickListener = this@SearchFragment } - marker.tag = data.id - marker.icon = OverlayImage.fromResource(us.wedemy.eggeum.android.design.R.drawable.ic_map_marker_24) - marker.onClickListener = this@SearchFragment - markers.add(marker) + markers.add(marker) // 마커 리스트에 추가는 한 번만 수행 } override fun onClick(overlay: Overlay): Boolean { @@ -219,36 +240,14 @@ class SearchFragment : BaseFragment(), OnMapReadyCallback return true } - private fun initNaverMap() { - naverMap?.apply { - locationSource = this@SearchFragment.locationSource - uiSettings.isScaleBarEnabled = false - uiSettings.isZoomControlEnabled = false - cameraPosition = CameraPosition( - LatLng(cameraPosition.target.latitude, cameraPosition.target.longitude), - ZOOM_LEVEL, - ) - setLayerGroupEnabled(NaverMap.LAYER_GROUP_BUILDING, true) - addOnCameraChangeListener { _, _ -> - searchViewModel.setLastCameraLocation( - cameraPosition.target.latitude, - cameraPosition.target.longitude - ) - } - } - moveToCameraToUserLocation() - } - @SuppressLint("MissingPermission") private fun moveToCameraToUserLocation() { fusedLocationClient.lastLocation.addOnSuccessListener { location -> val cameraUpdate = CameraUpdate.scrollTo(LatLng(location.latitude, location.longitude)) naverMap?.moveCamera(cameraUpdate) - Timber.d("Current Location ${location.latitude} ${location.longitude}") searchViewModel.setCurrentLocation(location.latitude, location.longitude) if (searchViewModel.initialCameraLocation.value.latitude == -1.0) { searchViewModel.setInitialCameraLocation(location.latitude, location.longitude) - Timber.d("Initial Camera Location initialized ${searchViewModel.initialCameraLocation.value.latitude} ${searchViewModel.initialCameraLocation.value.longitude}") } } } @@ -263,18 +262,16 @@ class SearchFragment : BaseFragment(), OnMapReadyCallback } private fun showLocationPermissionRationaleDialog() { - val dialog = AlertDialog.Builder(requireContext()) - .setMessage(getString(R.string.location_permission_educational_message)) - .setPositiveButton(getString(R.string.check)) { _, _ -> - requestPermissions() + AlertDialog.Builder(requireContext()).apply { + setMessage(getString(R.string.location_permission_educational_message)) + setPositiveButton(getString(R.string.check)) { _, _ -> requestPermissions() } + setNegativeButton(getString(R.string.cancel), null) + show().also { + it.getButton(DialogInterface.BUTTON_POSITIVE) + .setTextColor(ContextCompat.getColor(requireContext(), us.wedemy.eggeum.android.design.R.color.teal_500)) + it.getButton(DialogInterface.BUTTON_NEGATIVE) + .setTextColor(ContextCompat.getColor(requireContext(), us.wedemy.eggeum.android.design.R.color.gray_400)) } - .setNegativeButton(getString(R.string.cancel), null) - .show() - dialog.apply { - getButton(DialogInterface.BUTTON_POSITIVE) - .setTextColor(ContextCompat.getColor(requireContext(), us.wedemy.eggeum.android.design.R.color.teal_500)) - getButton(DialogInterface.BUTTON_NEGATIVE) - .setTextColor(ContextCompat.getColor(requireContext(), us.wedemy.eggeum.android.design.R.color.gray_400)) } } @@ -305,10 +302,7 @@ class SearchFragment : BaseFragment(), OnMapReadyCallback } override fun onDestroyView() { - markers.forEach { marker -> - marker.map = null - } - markers.clear() + clearMarkers() binding.mvSearch.onDestroy() naverMap = null super.onDestroyView() From 298e3ef296d7930f08173f5f8502268969a98053 Mon Sep 17 00:00:00 2001 From: JI HUN LEE <51016231+easyhooon@users.noreply.github.com> Date: Thu, 2 May 2024 07:46:13 +0900 Subject: [PATCH 08/12] =?UTF-8?q?refactor:=20permissionsGranted=20?= =?UTF-8?q?=EB=B3=80=EC=88=98=20=EB=B7=B0=EB=AA=A8=EB=8D=B8=EC=97=90?= =?UTF-8?q?=EC=84=9C=20=EA=B4=80=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../android/main/ui/search/SearchFragment.kt | 57 ++++++++++--------- .../android/main/viewmodel/SearchViewModel.kt | 34 ++++++----- 2 files changed, 50 insertions(+), 41 deletions(-) diff --git a/main/src/main/kotlin/us/wedemy/eggeum/android/main/ui/search/SearchFragment.kt b/main/src/main/kotlin/us/wedemy/eggeum/android/main/ui/search/SearchFragment.kt index 0b16ba53..bfc8744a 100644 --- a/main/src/main/kotlin/us/wedemy/eggeum/android/main/ui/search/SearchFragment.kt +++ b/main/src/main/kotlin/us/wedemy/eggeum/android/main/ui/search/SearchFragment.kt @@ -19,9 +19,7 @@ import androidx.core.content.ContextCompat import androidx.fragment.app.activityViewModels import androidx.fragment.app.viewModels import androidx.navigation.fragment.findNavController -import androidx.paging.ItemSnapshotList import androidx.paging.LoadState -import com.google.android.gms.location.FusedLocationProviderClient import com.google.android.gms.location.LocationServices import com.naver.maps.geometry.LatLng import com.naver.maps.map.CameraAnimation @@ -60,33 +58,27 @@ class SearchFragment : BaseFragment(), OnMapReadyCallback private val searchCafeAdapter by lazy { SearchCafeAdapter(null) } private var naverMap: NaverMap? = null + // TODO 마커 리스트를 뷰모델에서 관리 private val markers = mutableListOf() - private lateinit var fusedLocationClient: FusedLocationProviderClient + private val fusedLocationClient by lazy { + LocationServices.getFusedLocationProviderClient(requireContext()) + } private val locationSource = FusedLocationSource(this, LOCATION_PERMISSION_REQUEST_CODE) private val permissions = arrayOf(Manifest.permission.ACCESS_COARSE_LOCATION, Manifest.permission.ACCESS_FINE_LOCATION) - private var permissionsGranted = false private val requestMultiplePermissionsLauncher = registerForActivityResult(ActivityResultContracts.RequestMultiplePermissions()) { permissions -> - permissionsGranted = permissions.entries.all { it.value } - if (permissionsGranted) { - permissionsGranted = true - moveToCameraToUserLocation() - naverMap?.locationTrackingMode = LocationTrackingMode.Follow - } else { - naverMap?.locationTrackingMode = LocationTrackingMode.None - } + val allPermissionsGranted = permissions.entries.all { it.value } + searchViewModel.setPermissionsGranted(allPermissionsGranted) } override fun onViewCreated(view: View, savedInstanceState: Bundle?) { super.onViewCreated(view, savedInstanceState) - fusedLocationClient = LocationServices.getFusedLocationProviderClient(requireContext()) binding.mvSearch.apply { onCreate(savedInstanceState) getMapAsync(this@SearchFragment) } - checkPermission() initListener() initObserver() } @@ -104,11 +96,7 @@ class SearchFragment : BaseFragment(), OnMapReadyCallback searchViewModel.setLastCameraLocation(cameraPosition.target.latitude, cameraPosition.target.longitude) } } - if (permissionsGranted) { - naverMap.locationTrackingMode = LocationTrackingMode.Follow - moveToCameraToUserLocation() - } - addMarkersToMap(searchCafeAdapter.snapshot()) + moveToCameraToUserLocation() } private fun checkPermission() { @@ -123,7 +111,7 @@ class SearchFragment : BaseFragment(), OnMapReadyCallback requestPermissions() } } else { - permissionsGranted = true + searchViewModel.setPermissionsGranted(true) naverMap?.locationTrackingMode = LocationTrackingMode.Follow moveToCameraToUserLocation() } @@ -158,6 +146,17 @@ class SearchFragment : BaseFragment(), OnMapReadyCallback private fun initObserver() { repeatOnStarted { + launch { + searchViewModel.permissionsGranted.collect { granted -> + if (granted) { + naverMap?.locationTrackingMode = LocationTrackingMode.Follow + moveToCameraToUserLocation() + } else { + naverMap?.locationTrackingMode = LocationTrackingMode.None + } + } + } + launch { searchViewModel.placeList.collectLatest { pagingData -> searchCafeAdapter.submitData(pagingData) @@ -170,11 +169,16 @@ class SearchFragment : BaseFragment(), OnMapReadyCallback .collect { loadStates -> if (loadStates.source.refresh is LoadState.NotLoading) { searchViewModel.updatePlaceSnapshotList(searchCafeAdapter.snapshot()) - addMarkersToMap(searchCafeAdapter.snapshot()) } } } + launch { + searchViewModel.placeSnapshotList.collect { + addMarkersToMap(it) + } + } + launch { searchViewModel.lastCameraLocation.collect { lastCameraLocation -> if (lastCameraLocation != searchViewModel.initialCameraLocation.value && searchViewModel.initialCameraLocation.value.latitude != -1.0) { @@ -187,12 +191,10 @@ class SearchFragment : BaseFragment(), OnMapReadyCallback } } - private fun addMarkersToMap(snapshot: ItemSnapshotList) { + private fun addMarkersToMap(markers: List) { clearMarkers() - snapshot.toList().forEach { place -> - place?.let { - createAndAddMarker(it) - } + markers.forEach { + createAndAddMarker(it) } } @@ -211,7 +213,7 @@ class SearchFragment : BaseFragment(), OnMapReadyCallback tag = data.id onClickListener = this@SearchFragment } - markers.add(marker) // 마커 리스트에 추가는 한 번만 수행 + markers.add(marker) } override fun onClick(overlay: Overlay): Boolean { @@ -283,6 +285,7 @@ class SearchFragment : BaseFragment(), OnMapReadyCallback override fun onResume() { super.onResume() binding.mvSearch.onResume() + checkPermission() } override fun onPause() { diff --git a/main/src/main/kotlin/us/wedemy/eggeum/android/main/viewmodel/SearchViewModel.kt b/main/src/main/kotlin/us/wedemy/eggeum/android/main/viewmodel/SearchViewModel.kt index ce0dfe34..68a38f9e 100644 --- a/main/src/main/kotlin/us/wedemy/eggeum/android/main/viewmodel/SearchViewModel.kt +++ b/main/src/main/kotlin/us/wedemy/eggeum/android/main/viewmodel/SearchViewModel.kt @@ -27,6 +27,9 @@ import us.wedemy.eggeum.android.domain.usecase.GetPlaceListUseCase class SearchViewModel @Inject constructor( private val getPlaceListUseCase: GetPlaceListUseCase, ) : ViewModel() { + private val _permissionsGranted = MutableStateFlow(false) + val permissionsGranted: StateFlow = _permissionsGranted.asStateFlow() + private val _currentLocation = MutableStateFlow(LatLng(-1.0, -1.0)) val currentLocation: StateFlow = _currentLocation.asStateFlow() @@ -36,19 +39,9 @@ class SearchViewModel @Inject constructor( private val _lastCameraLocation = MutableStateFlow(LatLng(-1.0, -1.0)) val lastCameraLocation: StateFlow = _lastCameraLocation.asStateFlow() - fun setCurrentLocation(latitude: Double, longitude: Double) { - _currentLocation.value = LatLng(latitude, longitude) - } - - fun setInitialCameraLocation(latitude: Double, longitude: Double) { - _initialCameraLocation.value = LatLng(latitude, longitude) - } - - fun setLastCameraLocation(latitude: Double, longitude: Double) { - _lastCameraLocation.value = LatLng(latitude, longitude) - } + private val _placeSnapshoList = MutableStateFlow(emptyList()) + val placeSnapshotList: StateFlow> = _placeSnapshoList.asStateFlow() - // TODO 맵 zoom level, 내 위치가 변하면 값이 갱신 되어야 함 // 반경 2.5km 내에 위치한 장소에 마커가 찍히도록 @OptIn(ExperimentalCoroutinesApi::class) val placeList = _currentLocation @@ -62,8 +55,21 @@ class SearchViewModel @Inject constructor( ) }.cachedIn(viewModelScope) - private val _placeSnapshoList = MutableStateFlow(emptyList()) - val placeSnapshotList: StateFlow> = _placeSnapshoList.asStateFlow() + fun setPermissionsGranted(granted: Boolean) { + _permissionsGranted.value = granted + } + + fun setCurrentLocation(latitude: Double, longitude: Double) { + _currentLocation.value = LatLng(latitude, longitude) + } + + fun setInitialCameraLocation(latitude: Double, longitude: Double) { + _initialCameraLocation.value = LatLng(latitude, longitude) + } + + fun setLastCameraLocation(latitude: Double, longitude: Double) { + _lastCameraLocation.value = LatLng(latitude, longitude) + } fun updatePlaceSnapshotList(snapshot: ItemSnapshotList) { val snapshotList = mutableListOf() From 47809ab17a618c698ed3f9e633ba8e52aefe2413 Mon Sep 17 00:00:00 2001 From: JI HUN LEE <51016231+easyhooon@users.noreply.github.com> Date: Thu, 2 May 2024 07:48:19 +0900 Subject: [PATCH 09/12] =?UTF-8?q?refactor:=20retrofit=20authenticate=20?= =?UTF-8?q?=ED=95=A8=EC=88=98=20=EC=98=88=EC=99=B8=EC=B2=98=EB=A6=AC=20?= =?UTF-8?q?=EB=B0=A9=EC=8B=9D=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../data/datasource/token/TokenDataSource.kt | 3 +- .../datasource/token/TokenDataSourceImpl.kt | 5 ++- .../data/service/TokenAuthenticator.kt | 42 +++++++++++++------ .../android/data/service/TokenService.kt | 2 +- 4 files changed, 35 insertions(+), 17 deletions(-) diff --git a/data/src/main/kotlin/us/wedemy/eggeum/android/data/datasource/token/TokenDataSource.kt b/data/src/main/kotlin/us/wedemy/eggeum/android/data/datasource/token/TokenDataSource.kt index a71c140b..6696c6be 100644 --- a/data/src/main/kotlin/us/wedemy/eggeum/android/data/datasource/token/TokenDataSource.kt +++ b/data/src/main/kotlin/us/wedemy/eggeum/android/data/datasource/token/TokenDataSource.kt @@ -14,7 +14,6 @@ package us.wedemy.eggeum.android.data.datasource.token -import us.wedemy.eggeum.android.data.model.token.TokenRequest import us.wedemy.eggeum.android.data.model.token.TokenResponse internal interface TokenDataSource { @@ -28,5 +27,5 @@ internal interface TokenDataSource { suspend fun clear() - suspend fun getNewAccessToken(tokenRequest: TokenRequest): Result + suspend fun refresh(): Result } diff --git a/data/src/main/kotlin/us/wedemy/eggeum/android/data/datasource/token/TokenDataSourceImpl.kt b/data/src/main/kotlin/us/wedemy/eggeum/android/data/datasource/token/TokenDataSourceImpl.kt index 14692374..a2ade3d3 100644 --- a/data/src/main/kotlin/us/wedemy/eggeum/android/data/datasource/token/TokenDataSourceImpl.kt +++ b/data/src/main/kotlin/us/wedemy/eggeum/android/data/datasource/token/TokenDataSourceImpl.kt @@ -61,8 +61,9 @@ internal class TokenDataSourceImpl @Inject constructor( dataStore.edit { it.clear() } } - override suspend fun getNewAccessToken(tokenRequest: TokenRequest): Result = + override suspend fun refresh(): Result = runSuspendCatching { - service.getRefreshToken(tokenRequest) + val tokenRequest = TokenRequest(getRefreshToken()) + service.refresh(tokenRequest) } } diff --git a/data/src/main/kotlin/us/wedemy/eggeum/android/data/service/TokenAuthenticator.kt b/data/src/main/kotlin/us/wedemy/eggeum/android/data/service/TokenAuthenticator.kt index 334d4dba..68db25f1 100644 --- a/data/src/main/kotlin/us/wedemy/eggeum/android/data/service/TokenAuthenticator.kt +++ b/data/src/main/kotlin/us/wedemy/eggeum/android/data/service/TokenAuthenticator.kt @@ -6,24 +6,42 @@ import okhttp3.Authenticator import okhttp3.Request import okhttp3.Response import okhttp3.Route -import us.wedemy.eggeum.android.common.util.RefreshTokenExpiredException import us.wedemy.eggeum.android.data.datasource.token.TokenDataSource -import us.wedemy.eggeum.android.data.model.token.TokenRequest internal class TokenAuthenticator @Inject constructor( private val tokenDataSource: TokenDataSource, ) : Authenticator { override fun authenticate(route: Route?, response: Response): Request? { - return runBlocking { - tokenDataSource.getNewAccessToken(TokenRequest(tokenDataSource.getRefreshToken())) - .onSuccess { tokenResponse -> - tokenDataSource.setAccessToken(tokenResponse.accessToken) - tokenDataSource.setRefreshToken(tokenResponse.refreshToken) - }.map { tokenResponse -> - newRequestWithAccessToken(response.request, tokenResponse.accessToken) - }.onFailure { - throw RefreshTokenExpiredException - }.getOrNull() + val newAccessToken = runBlocking { getNewAccessToken() } ?: return null + return newRequestWithAccessToken(response.request, newAccessToken) + } + +// override fun authenticate(route: Route?, response: Response): Request? { +// return runBlocking { +// tokenDataSource.getNewAccessToken(TokenRequest(tokenDataSource.getRefreshToken())) +// .onSuccess { tokenResponse -> +// tokenDataSource.setAccessToken(tokenResponse.accessToken) +// tokenDataSource.setRefreshToken(tokenResponse.refreshToken) +// }.map { tokenResponse -> +// newRequestWithAccessToken(response.request, tokenResponse.accessToken) +// }.onFailure { +// throw RefreshTokenExpiredException +// }.getOrNull() +// } +// } + + private suspend fun getNewAccessToken(): String? { + val response = tokenDataSource.refresh() + val newToken = response.getOrNull() + return newToken?.let { + tokenDataSource.apply { + setAccessToken(it.accessToken) + setRefreshToken(it.refreshToken) + } + it.accessToken + } ?: run { + tokenDataSource.clear() + null } } diff --git a/data/src/main/kotlin/us/wedemy/eggeum/android/data/service/TokenService.kt b/data/src/main/kotlin/us/wedemy/eggeum/android/data/service/TokenService.kt index 8adee994..24953a34 100644 --- a/data/src/main/kotlin/us/wedemy/eggeum/android/data/service/TokenService.kt +++ b/data/src/main/kotlin/us/wedemy/eggeum/android/data/service/TokenService.kt @@ -15,7 +15,7 @@ import us.wedemy.eggeum.android.data.model.token.TokenResponse internal interface TokenService { @POST("app/token/refresh") - suspend fun getRefreshToken( + suspend fun refresh( @Body tokenRequest: TokenRequest, ): TokenResponse } From 2768c18d54a097165605c34f52c0ecee1b123d8c Mon Sep 17 00:00:00 2001 From: JI HUN LEE <51016231+easyhooon@users.noreply.github.com> Date: Thu, 2 May 2024 07:50:55 +0900 Subject: [PATCH 10/12] chore: code style check success --- .../wedemy/eggeum/android/main/ui/search/SearchFragment.kt | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/main/src/main/kotlin/us/wedemy/eggeum/android/main/ui/search/SearchFragment.kt b/main/src/main/kotlin/us/wedemy/eggeum/android/main/ui/search/SearchFragment.kt index bfc8744a..2293e0f6 100644 --- a/main/src/main/kotlin/us/wedemy/eggeum/android/main/ui/search/SearchFragment.kt +++ b/main/src/main/kotlin/us/wedemy/eggeum/android/main/ui/search/SearchFragment.kt @@ -58,6 +58,7 @@ class SearchFragment : BaseFragment(), OnMapReadyCallback private val searchCafeAdapter by lazy { SearchCafeAdapter(null) } private var naverMap: NaverMap? = null + // TODO 마커 리스트를 뷰모델에서 관리 private val markers = mutableListOf() private val fusedLocationClient by lazy { @@ -133,11 +134,11 @@ class SearchFragment : BaseFragment(), OnMapReadyCallback cvCurrentMapSearchCafe.setOnClickListener { searchViewModel.setInitialCameraLocation( searchViewModel.lastCameraLocation.value.latitude, - searchViewModel.lastCameraLocation.value.longitude + searchViewModel.lastCameraLocation.value.longitude, ) searchViewModel.setCurrentLocation( searchViewModel.lastCameraLocation.value.latitude, - searchViewModel.lastCameraLocation.value.longitude + searchViewModel.lastCameraLocation.value.longitude, ) cvCurrentMapSearchCafe.visibility = View.GONE } From a2125aa85b62a3c57fb32423df45581a73aa96c1 Mon Sep 17 00:00:00 2001 From: JI HUN LEE <51016231+easyhooon@users.noreply.github.com> Date: Thu, 2 May 2024 07:51:23 +0900 Subject: [PATCH 11/12] chore: app version up --- build-logic/src/main/kotlin/internal/Constants.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build-logic/src/main/kotlin/internal/Constants.kt b/build-logic/src/main/kotlin/internal/Constants.kt index 44cae288..bf68b2ed 100644 --- a/build-logic/src/main/kotlin/internal/Constants.kt +++ b/build-logic/src/main/kotlin/internal/Constants.kt @@ -11,8 +11,8 @@ internal object ApplicationConstants { const val MinSdk = 24 const val TargetSdk = 34 const val CompileSdk = 34 - const val VersionCode = 6 - const val VersionName = "0.0.5" + const val VersionCode = 7 + const val VersionName = "0.1.0" val JavaVersion = org.gradle.api.JavaVersion.VERSION_17 const val JavaVersionAsInt = 17 } From 1cc17f6a2c02701869fd212aa2c0fe27e5cec5bf Mon Sep 17 00:00:00 2001 From: JI HUN LEE <51016231+easyhooon@users.noreply.github.com> Date: Thu, 2 May 2024 07:57:43 +0900 Subject: [PATCH 12/12] =?UTF-8?q?feat:=20=EA=B2=80=EC=83=89=20=ED=99=94?= =?UTF-8?q?=EB=A9=B4=EC=9C=BC=EB=A1=9C=20=EB=84=98=EC=96=B4=EA=B0=80?= =?UTF-8?q?=EA=B8=B0=20=EC=9D=B4=EC=A0=84,=20LastCameraLocation=20?= =?UTF-8?q?=EC=9D=84=20currentLocation=20=EC=9C=BC=EB=A1=9C=20=EC=97=85?= =?UTF-8?q?=EB=8D=B0=EC=9D=B4=ED=8A=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../us/wedemy/eggeum/android/main/ui/search/SearchFragment.kt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/main/src/main/kotlin/us/wedemy/eggeum/android/main/ui/search/SearchFragment.kt b/main/src/main/kotlin/us/wedemy/eggeum/android/main/ui/search/SearchFragment.kt index 2293e0f6..4ac22a16 100644 --- a/main/src/main/kotlin/us/wedemy/eggeum/android/main/ui/search/SearchFragment.kt +++ b/main/src/main/kotlin/us/wedemy/eggeum/android/main/ui/search/SearchFragment.kt @@ -127,6 +127,10 @@ class SearchFragment : BaseFragment(), OnMapReadyCallback cvSearchCafe.performClick() } cvSearchCafe.setOnClickListener { + searchViewModel.setCurrentLocation( + searchViewModel.lastCameraLocation.value.latitude, + searchViewModel.lastCameraLocation.value.longitude, + ) val action = SearchFragmentDirections.actionFragmentSearchToFragmentSearchCafeFragment(searchViewModel.currentLocation.value) findNavController().safeNavigate(action)