From 9b8c6c3861c9cc5db4cac9f890d3338959b7fb9f Mon Sep 17 00:00:00 2001 From: Sangwook123 Date: Tue, 16 Jul 2024 23:03:28 +0900 Subject: [PATCH 01/14] [feat] #92 core page --- core/model/src/main/java/com/record/model/Page.kt | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 core/model/src/main/java/com/record/model/Page.kt diff --git a/core/model/src/main/java/com/record/model/Page.kt b/core/model/src/main/java/com/record/model/Page.kt new file mode 100644 index 00000000..e576a51c --- /dev/null +++ b/core/model/src/main/java/com/record/model/Page.kt @@ -0,0 +1,7 @@ +package com.record.model + +data class Page( + val hasNext: Boolean, + val page: Int, + val data: List, +) From 0ea3151e9744f25ca55bf18cf335b6442c8b2a87 Mon Sep 17 00:00:00 2001 From: Sangwook123 Date: Tue, 16 Jul 2024 23:03:53 +0900 Subject: [PATCH 02/14] [feat] #92 keyword domain --- domain/keyword/build.gradle.kts | 8 ++++++++ .../java/com/record/keyword/model/PreferenceKeyword.kt | 5 +++++ .../com/record/keyword/repository/KeywordRepository.kt | 7 +++++++ 3 files changed, 20 insertions(+) create mode 100644 domain/keyword/build.gradle.kts create mode 100644 domain/keyword/src/main/java/com/record/keyword/model/PreferenceKeyword.kt create mode 100644 domain/keyword/src/main/java/com/record/keyword/repository/KeywordRepository.kt diff --git a/domain/keyword/build.gradle.kts b/domain/keyword/build.gradle.kts new file mode 100644 index 00000000..8c84885d --- /dev/null +++ b/domain/keyword/build.gradle.kts @@ -0,0 +1,8 @@ +plugins { + alias(libs.plugins.recordy.java.library) +} + +dependencies { + implementation(projects.core.model) + implementation(libs.kotlinx.coroutines.core) +} diff --git a/domain/keyword/src/main/java/com/record/keyword/model/PreferenceKeyword.kt b/domain/keyword/src/main/java/com/record/keyword/model/PreferenceKeyword.kt new file mode 100644 index 00000000..306426b8 --- /dev/null +++ b/domain/keyword/src/main/java/com/record/keyword/model/PreferenceKeyword.kt @@ -0,0 +1,5 @@ +package com.record.keyword.model + +data class PreferenceKeyword( + val keywords: List +) diff --git a/domain/keyword/src/main/java/com/record/keyword/repository/KeywordRepository.kt b/domain/keyword/src/main/java/com/record/keyword/repository/KeywordRepository.kt new file mode 100644 index 00000000..18301397 --- /dev/null +++ b/domain/keyword/src/main/java/com/record/keyword/repository/KeywordRepository.kt @@ -0,0 +1,7 @@ +package com.record.keyword.repository + +import com.record.keyword.model.PreferenceKeyword + +interface KeywordRepository { + fun getKeywords(): Result +} From 15a8bc882e8962701c83722005c0f5c73681a3cc Mon Sep 17 00:00:00 2001 From: Sangwook123 Date: Tue, 16 Jul 2024 23:04:18 +0900 Subject: [PATCH 03/14] [feat] #92 user domain --- .../user/src/main/java/com/record/user/model/Preference.kt | 6 ++++++ .../main/java/com/record/user/repository/UserRepository.kt | 3 +++ 2 files changed, 9 insertions(+) create mode 100644 domain/user/src/main/java/com/record/user/model/Preference.kt diff --git a/domain/user/src/main/java/com/record/user/model/Preference.kt b/domain/user/src/main/java/com/record/user/model/Preference.kt new file mode 100644 index 00000000..2b158a44 --- /dev/null +++ b/domain/user/src/main/java/com/record/user/model/Preference.kt @@ -0,0 +1,6 @@ +package com.record.user.model + +data class Preference( + val keyword: String, + val percentage: Int, +) diff --git a/domain/user/src/main/java/com/record/user/repository/UserRepository.kt b/domain/user/src/main/java/com/record/user/repository/UserRepository.kt index d6bdec84..8ede21c9 100644 --- a/domain/user/src/main/java/com/record/user/repository/UserRepository.kt +++ b/domain/user/src/main/java/com/record/user/repository/UserRepository.kt @@ -1,6 +1,7 @@ package com.record.user.repository import com.record.model.Cursor +import com.record.user.model.Preference import com.record.user.model.Profile import com.record.user.model.User @@ -22,4 +23,6 @@ interface UserRepository { fun getUserProfile( userId: Long, ): Result + + fun getUserPreference(): Result> } From ad2d8c4ef1b52827638aa1069bed1f00e306d41b Mon Sep 17 00:00:00 2001 From: Sangwook123 Date: Tue, 16 Jul 2024 23:04:29 +0900 Subject: [PATCH 04/14] [feat] #92 video domain --- .../video/src/main/java/com/record/video/model/VideoData.kt | 1 + .../java/com/record/video/repository/VideoRepository.kt | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/domain/video/src/main/java/com/record/video/model/VideoData.kt b/domain/video/src/main/java/com/record/video/model/VideoData.kt index c2cced07..8e3ce484 100644 --- a/domain/video/src/main/java/com/record/video/model/VideoData.kt +++ b/domain/video/src/main/java/com/record/video/model/VideoData.kt @@ -10,4 +10,5 @@ data class VideoData( val location: String, val uploaderId: Int, val nickname: String, + val isMine: Boolean ) diff --git a/domain/video/src/main/java/com/record/video/repository/VideoRepository.kt b/domain/video/src/main/java/com/record/video/repository/VideoRepository.kt index e4ac44c0..6968d82c 100644 --- a/domain/video/src/main/java/com/record/video/repository/VideoRepository.kt +++ b/domain/video/src/main/java/com/record/video/repository/VideoRepository.kt @@ -1,9 +1,15 @@ package com.record.video.repository import com.record.model.Cursor +import com.record.model.Page import com.record.video.model.VideoData interface VideoRepository { fun getAllVideos(cursorId: Long, pageSize: Int): Result> fun getRecentVideos(keywords: List, pageNumber: Int, pageSize: Int): Result> + fun getPopularVideos(keywords: List, pageNumber: Int, pageSize: Int): Result> + fun getUserVideos(otherUserId: Long, cursorId: Long, size: Int): Result> + fun getFollowingVideos(userId: Long, cursorId: Long, size: Int): Result> + fun getBookmarkVideos(cursorId: Long, size: Int): Result> + fun bookmark(videoId: Long): Result } From 120ec5579bc81e064d2e7636b36a65c37a19909b Mon Sep 17 00:00:00 2001 From: Sangwook123 Date: Tue, 16 Jul 2024 23:05:01 +0900 Subject: [PATCH 05/14] [feat] #92 remote keyword --- remote/keyword/build.gradle.kts | 11 +++++++++++ remote/keyword/src/main/AndroidManifest.xml | 4 ++++ .../java/com/record/keyword/api/KeywordApi.kt | 8 ++++++++ .../java/com/record/keyword/di/ApiModule.kt | 18 ++++++++++++++++++ .../java/com/record/keyword/di/DataModule.kt | 17 +++++++++++++++++ .../source/RemoteKeywordDataSourceImpl.kt | 10 ++++++++++ 6 files changed, 68 insertions(+) create mode 100644 remote/keyword/build.gradle.kts create mode 100644 remote/keyword/src/main/AndroidManifest.xml create mode 100644 remote/keyword/src/main/java/com/record/keyword/api/KeywordApi.kt create mode 100644 remote/keyword/src/main/java/com/record/keyword/di/ApiModule.kt create mode 100644 remote/keyword/src/main/java/com/record/keyword/di/DataModule.kt create mode 100644 remote/keyword/src/main/java/com/record/keyword/source/RemoteKeywordDataSourceImpl.kt diff --git a/remote/keyword/build.gradle.kts b/remote/keyword/build.gradle.kts new file mode 100644 index 00000000..b9c690cf --- /dev/null +++ b/remote/keyword/build.gradle.kts @@ -0,0 +1,11 @@ +plugins { + alias(libs.plugins.recordy.remote) +} + +android { + namespace = "com.record.keyword" +} + +dependencies { + implementation(projects.data.keyword) +} diff --git a/remote/keyword/src/main/AndroidManifest.xml b/remote/keyword/src/main/AndroidManifest.xml new file mode 100644 index 00000000..8bdb7e14 --- /dev/null +++ b/remote/keyword/src/main/AndroidManifest.xml @@ -0,0 +1,4 @@ + + + + diff --git a/remote/keyword/src/main/java/com/record/keyword/api/KeywordApi.kt b/remote/keyword/src/main/java/com/record/keyword/api/KeywordApi.kt new file mode 100644 index 00000000..b44ac5ed --- /dev/null +++ b/remote/keyword/src/main/java/com/record/keyword/api/KeywordApi.kt @@ -0,0 +1,8 @@ +package com.record.keyword.api + +import retrofit2.http.GET + +interface KeywordApi { + @GET("/api/v1/keywords") + fun getKeywords(): List +} diff --git a/remote/keyword/src/main/java/com/record/keyword/di/ApiModule.kt b/remote/keyword/src/main/java/com/record/keyword/di/ApiModule.kt new file mode 100644 index 00000000..b4d170d9 --- /dev/null +++ b/remote/keyword/src/main/java/com/record/keyword/di/ApiModule.kt @@ -0,0 +1,18 @@ +package com.record.keyword.di + +import com.record.keyword.api.KeywordApi +import com.record.network.di.Auth +import dagger.Module +import dagger.Provides +import dagger.hilt.InstallIn +import retrofit2.Retrofit +import retrofit2.create +import javax.inject.Singleton + +@Module +@InstallIn +object ApiModule { + @Provides + @Singleton + fun providesKeywordApi(@Auth retrofit: Retrofit): KeywordApi = retrofit.create() +} diff --git a/remote/keyword/src/main/java/com/record/keyword/di/DataModule.kt b/remote/keyword/src/main/java/com/record/keyword/di/DataModule.kt new file mode 100644 index 00000000..53057c2c --- /dev/null +++ b/remote/keyword/src/main/java/com/record/keyword/di/DataModule.kt @@ -0,0 +1,17 @@ +package com.record.keyword.di + +import com.record.keyword.source.RemoteKeywordDataSource +import com.record.keyword.source.RemoteKeywordDataSourceImpl +import dagger.Binds +import dagger.Module +import dagger.hilt.InstallIn +import dagger.hilt.components.SingletonComponent +import javax.inject.Singleton + +@Module +@InstallIn(SingletonComponent::class) +abstract class DataModule { + @Binds + @Singleton + abstract fun bindsKeywordDataSource(remoteKeywordDataSourceImpl: RemoteKeywordDataSourceImpl): RemoteKeywordDataSource +} diff --git a/remote/keyword/src/main/java/com/record/keyword/source/RemoteKeywordDataSourceImpl.kt b/remote/keyword/src/main/java/com/record/keyword/source/RemoteKeywordDataSourceImpl.kt new file mode 100644 index 00000000..9dd5023a --- /dev/null +++ b/remote/keyword/src/main/java/com/record/keyword/source/RemoteKeywordDataSourceImpl.kt @@ -0,0 +1,10 @@ +package com.record.keyword.source + +import com.record.keyword.api.KeywordApi +import javax.inject.Inject + +class RemoteKeywordDataSourceImpl @Inject constructor( + private val keywordApi: KeywordApi, +) : RemoteKeywordDataSource { + override fun getKeywords(): List = keywordApi.getKeywords() +} From 3ffb15f2d2308231bebc3a35a782dcc7e34dfefb Mon Sep 17 00:00:00 2001 From: Sangwook123 Date: Tue, 16 Jul 2024 23:05:17 +0900 Subject: [PATCH 06/14] [feat] #92 user remote --- remote/user/src/main/java/com/record/user/api/UserApi.kt | 7 +++++-- .../com/record/user/datasource/RemoteUserDataSourceImpl.kt | 5 ++++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/remote/user/src/main/java/com/record/user/api/UserApi.kt b/remote/user/src/main/java/com/record/user/api/UserApi.kt index 1aeb7b26..5d270dca 100644 --- a/remote/user/src/main/java/com/record/user/api/UserApi.kt +++ b/remote/user/src/main/java/com/record/user/api/UserApi.kt @@ -2,8 +2,8 @@ package com.record.user.api import com.record.user.model.remote.response.ResponseGetFollowerListDto import com.record.user.model.remote.response.ResponseGetFollowingListDto +import com.record.user.model.remote.response.ResponseGetUserPreferenceDto import com.record.user.model.remote.response.ResponseGetUserProfileDto -import com.record.user.model.remote.response.ResponsePostFollowDto import retrofit2.http.GET import retrofit2.http.POST import retrofit2.http.Path @@ -25,10 +25,13 @@ interface UserApi { @POST("/api/v1/users/follow/{followingId}") fun postFollow( @Path("followingId") followingId: Long, - ): ResponsePostFollowDto + ): Boolean @GET("/api/v1/users/profile/{userId}") fun getUserProfileDto( @Path("userId") userId: Long, ): ResponseGetUserProfileDto + + @GET("/api/v1/preference") + fun getUserPreference(): ResponseGetUserPreferenceDto } diff --git a/remote/user/src/main/java/com/record/user/datasource/RemoteUserDataSourceImpl.kt b/remote/user/src/main/java/com/record/user/datasource/RemoteUserDataSourceImpl.kt index b6f5ab21..2e16bacb 100644 --- a/remote/user/src/main/java/com/record/user/datasource/RemoteUserDataSourceImpl.kt +++ b/remote/user/src/main/java/com/record/user/datasource/RemoteUserDataSourceImpl.kt @@ -3,6 +3,7 @@ package com.record.user.datasource import com.record.user.api.UserApi import com.record.user.model.remote.response.ResponseGetFollowerListDto import com.record.user.model.remote.response.ResponseGetFollowingListDto +import com.record.user.model.remote.response.ResponseGetUserPreferenceDto import com.record.user.model.remote.response.ResponseGetUserProfileDto import com.record.user.model.remote.response.ResponsePostFollowDto import com.record.user.source.remote.RemoteUserDataSource @@ -15,7 +16,9 @@ class RemoteUserDataSourceImpl @Inject constructor( override fun getFollowerList(cursorId: Long, size: Int): ResponseGetFollowerListDto = userApi.getFollowerList(cursorId, size) - override fun postFollow(followingId: Long): ResponsePostFollowDto = userApi.postFollow(followingId) + override fun postFollow(followingId: Long): Boolean = userApi.postFollow(followingId) override fun getUserProfile(userId: Long): ResponseGetUserProfileDto = userApi.getUserProfileDto(userId) + + override fun getUserPreference(): ResponseGetUserPreferenceDto = userApi.getUserPreference() } From b3e692aa6f029150a339373d7d49b04092d42096 Mon Sep 17 00:00:00 2001 From: Sangwook123 Date: Tue, 16 Jul 2024 23:05:35 +0900 Subject: [PATCH 07/14] [feat] #92 remote video --- .../java/com/record/video/api/VideoApi.kt | 40 ++++++++++++++++++- .../datasource/RemoteVideoDataSourceImpl.kt | 19 ++++++++- 2 files changed, 55 insertions(+), 4 deletions(-) diff --git a/remote/video/src/main/java/com/record/video/api/VideoApi.kt b/remote/video/src/main/java/com/record/video/api/VideoApi.kt index 645ff48f..da7f3e38 100644 --- a/remote/video/src/main/java/com/record/video/api/VideoApi.kt +++ b/remote/video/src/main/java/com/record/video/api/VideoApi.kt @@ -1,8 +1,12 @@ package com.record.video.api -import com.record.video.model.remote.response.ResponseGetRecentVideoDto +import com.record.video.model.remote.response.ResponseGetPagingVideoDto +import com.record.video.model.remote.response.ResponseGetSliceVideoDto import com.record.video.model.remote.response.ResponseGetVideoDto import retrofit2.http.GET +import retrofit2.http.Header +import retrofit2.http.POST +import retrofit2.http.Path import retrofit2.http.Query interface VideoApi { @@ -17,5 +21,37 @@ interface VideoApi { @Query("keywords") keywords: List, @Query("pageNumber") pageNumber: Int, @Query("pageSize") pageSize: Int, - ): ResponseGetRecentVideoDto + ): ResponseGetSliceVideoDto + + @GET("/api/v1/records/famous") + fun getPopularVideos( + @Query("keywords") keywords: List, + @Query("pageNumber") pageNumber: Int, + @Query("pageSize") pageSize: Int, + ): ResponseGetPagingVideoDto + + @GET("/api/v1/records/user/{otherUserId}") + fun getUserVideos( + @Path("otherUserId") otherUserId: Long, + @Query("cursorId") cursorId: Long, + @Query("size") size: Int, + ): ResponseGetSliceVideoDto + + @GET("/api/v1/records/following") + fun getFollowingVideos( + @Header("userId") userId: Long, + @Query("cursorId") cursorId: Long, + @Query("size") size: Int, + ): ResponseGetSliceVideoDto + + @GET("/api/v1/records/bookmark") + fun getBookmarkVideos( + @Query("cursorId") cursorId: Long, + @Query("size") size: Int, + ): ResponseGetSliceVideoDto + + @POST("/api/v1/bookmarks/{recordId}") + fun postBookmark( + @Path("recordId") recordId: Long, + ): Boolean } diff --git a/remote/video/src/main/java/com/record/video/datasource/RemoteVideoDataSourceImpl.kt b/remote/video/src/main/java/com/record/video/datasource/RemoteVideoDataSourceImpl.kt index d12e7a2a..9e264c27 100644 --- a/remote/video/src/main/java/com/record/video/datasource/RemoteVideoDataSourceImpl.kt +++ b/remote/video/src/main/java/com/record/video/datasource/RemoteVideoDataSourceImpl.kt @@ -1,7 +1,8 @@ package com.record.video.datasource import com.record.video.api.VideoApi -import com.record.video.model.remote.response.ResponseGetRecentVideoDto +import com.record.video.model.remote.response.ResponseGetPagingVideoDto +import com.record.video.model.remote.response.ResponseGetSliceVideoDto import com.record.video.model.remote.response.ResponseGetVideoDto import com.record.video.source.remote.RemoteVideoDataSource import javax.inject.Inject @@ -11,9 +12,23 @@ class RemoteVideoDataSourceImpl @Inject constructor( ) : RemoteVideoDataSource { override fun getAllVideos(cursorId: Long, size: Int): List = videoApi.getAllVideos(cursorId, size) - override fun getRecentVideos(keywords: List, pageNumber: Int, pageSize: Int): ResponseGetRecentVideoDto = videoApi.getRecentVideos( + override fun getRecentVideos(keywords: List, pageNumber: Int, pageSize: Int): ResponseGetSliceVideoDto = videoApi.getRecentVideos( keywords, pageNumber, pageSize, ) + + override fun getPopularVideos(keywords: List, pageNumber: Int, pageSize: Int): ResponseGetPagingVideoDto = + videoApi.getPopularVideos(keywords, pageNumber, pageSize) + + override fun getUserVideos(otherUserId: Long, cursorId: Long, size: Int): ResponseGetSliceVideoDto = + videoApi.getUserVideos(otherUserId, cursorId, size) + + override fun getFollowingVideos(userId: Long, cursorId: Long, size: Int): ResponseGetSliceVideoDto = + videoApi.getFollowingVideos(userId, cursorId, size) + + override fun getBookmarkVideos(cursorId: Long, size: Int): ResponseGetSliceVideoDto = videoApi.getBookmarkVideos(cursorId, size) + + override fun bookmark(recordId: Long): Boolean = videoApi.postBookmark(recordId) + } From e22bb2c33f0f9f9564a8869c4b110258aefbb5fd Mon Sep 17 00:00:00 2001 From: Sangwook123 Date: Tue, 16 Jul 2024 23:06:48 +0900 Subject: [PATCH 08/14] [feat] #92 data keyword --- data/keyword/build.gradle.kts | 12 +++++++++ data/keyword/src/main/AndroidManifest.xml | 4 +++ .../com/record/keyword/di/RepositoryModule.kt | 17 ++++++++++++ .../repository/KeywordRepositoryImpl.kt | 27 +++++++++++++++++++ .../keyword/source/RemoteKeywordDataSource.kt | 5 ++++ 5 files changed, 65 insertions(+) create mode 100644 data/keyword/build.gradle.kts create mode 100644 data/keyword/src/main/AndroidManifest.xml create mode 100644 data/keyword/src/main/java/com/record/keyword/di/RepositoryModule.kt create mode 100644 data/keyword/src/main/java/com/record/keyword/repository/KeywordRepositoryImpl.kt create mode 100644 data/keyword/src/main/java/com/record/keyword/source/RemoteKeywordDataSource.kt diff --git a/data/keyword/build.gradle.kts b/data/keyword/build.gradle.kts new file mode 100644 index 00000000..3a2f2cb9 --- /dev/null +++ b/data/keyword/build.gradle.kts @@ -0,0 +1,12 @@ +plugins { + alias(libs.plugins.recordy.data) + alias(libs.plugins.kotlin.serialization) +} + +android { + namespace = "com.record.keyword" +} + +dependencies { + implementation(projects.domain.keyword) +} diff --git a/data/keyword/src/main/AndroidManifest.xml b/data/keyword/src/main/AndroidManifest.xml new file mode 100644 index 00000000..8bdb7e14 --- /dev/null +++ b/data/keyword/src/main/AndroidManifest.xml @@ -0,0 +1,4 @@ + + + + diff --git a/data/keyword/src/main/java/com/record/keyword/di/RepositoryModule.kt b/data/keyword/src/main/java/com/record/keyword/di/RepositoryModule.kt new file mode 100644 index 00000000..34acc5f5 --- /dev/null +++ b/data/keyword/src/main/java/com/record/keyword/di/RepositoryModule.kt @@ -0,0 +1,17 @@ +package com.record.keyword.di + +import com.record.keyword.repository.KeywordRepository +import com.record.keyword.repository.KeywordRepositoryImpl +import dagger.Binds +import dagger.Module +import dagger.hilt.InstallIn +import dagger.hilt.components.SingletonComponent +import javax.inject.Singleton + +@Module +@InstallIn(SingletonComponent::class) +abstract class RepositoryModule { + @Binds + @Singleton + abstract fun bindsKeywordRepository(keywordRepositoryImpl: KeywordRepositoryImpl): KeywordRepository +} diff --git a/data/keyword/src/main/java/com/record/keyword/repository/KeywordRepositoryImpl.kt b/data/keyword/src/main/java/com/record/keyword/repository/KeywordRepositoryImpl.kt new file mode 100644 index 00000000..410fb36d --- /dev/null +++ b/data/keyword/src/main/java/com/record/keyword/repository/KeywordRepositoryImpl.kt @@ -0,0 +1,27 @@ +package com.record.keyword.repository + +import com.record.keyword.model.PreferenceKeyword +import com.record.keyword.source.RemoteKeywordDataSource +import com.record.model.exception.ApiError +import retrofit2.HttpException +import javax.inject.Inject + +class KeywordRepositoryImpl @Inject constructor( + private val remoteKeywordDataSource: RemoteKeywordDataSource, +) : KeywordRepository { + override fun getKeywords(): Result = runCatching { + remoteKeywordDataSource.getKeywords() + }.mapCatching { + PreferenceKeyword(keywords = it) + }.recoverCatching { exception -> + when (exception) { + is HttpException -> { + throw ApiError(exception.message()) + } + + else -> { + throw exception + } + } + } +} diff --git a/data/keyword/src/main/java/com/record/keyword/source/RemoteKeywordDataSource.kt b/data/keyword/src/main/java/com/record/keyword/source/RemoteKeywordDataSource.kt new file mode 100644 index 00000000..67b16f9f --- /dev/null +++ b/data/keyword/src/main/java/com/record/keyword/source/RemoteKeywordDataSource.kt @@ -0,0 +1,5 @@ +package com.record.keyword.source + +interface RemoteKeywordDataSource { + fun getKeywords(): List +} From 50c83f22efc28b771030c8b651a81555dd037af1 Mon Sep 17 00:00:00 2001 From: Sangwook123 Date: Tue, 16 Jul 2024 23:07:05 +0900 Subject: [PATCH 09/14] [feat] #92 data user --- .../response/ResponseGetUserPreferenceDto.kt | 13 +++++++++++ .../user/repository/UserRepositoryImpl.kt | 23 ++++++++++++++++++- .../source/remote/RemoteUserDataSource.kt | 6 ++++- 3 files changed, 40 insertions(+), 2 deletions(-) create mode 100644 data/user/src/main/java/com/record/user/model/remote/response/ResponseGetUserPreferenceDto.kt diff --git a/data/user/src/main/java/com/record/user/model/remote/response/ResponseGetUserPreferenceDto.kt b/data/user/src/main/java/com/record/user/model/remote/response/ResponseGetUserPreferenceDto.kt new file mode 100644 index 00000000..6fe3da50 --- /dev/null +++ b/data/user/src/main/java/com/record/user/model/remote/response/ResponseGetUserPreferenceDto.kt @@ -0,0 +1,13 @@ +package com.record.user.model.remote.response + + +import kotlinx.serialization.SerialName +import kotlinx.serialization.Serializable + +@Serializable +data class ResponseGetUserPreferenceDto( + @SerialName("preference") + val preference: List>, + @SerialName("userId") + val userId: Int +) diff --git a/data/user/src/main/java/com/record/user/repository/UserRepositoryImpl.kt b/data/user/src/main/java/com/record/user/repository/UserRepositoryImpl.kt index 1dae4329..cb28bd7d 100644 --- a/data/user/src/main/java/com/record/user/repository/UserRepositoryImpl.kt +++ b/data/user/src/main/java/com/record/user/repository/UserRepositoryImpl.kt @@ -2,6 +2,7 @@ package com.record.user.repository import com.record.model.Cursor import com.record.model.exception.ApiError +import com.record.user.model.Preference import com.record.user.model.Profile import com.record.user.model.User import com.record.user.model.remote.response.toCore @@ -48,7 +49,7 @@ class UserRepositoryImpl @Inject constructor( override fun postFollow(followingId: Long): Result = runCatching { remoteUserDataSource.postFollow(followingId) }.map { - it.isFollowing + it }.recoverCatching { exception -> when (exception) { is HttpException -> { @@ -76,4 +77,24 @@ class UserRepositoryImpl @Inject constructor( } } } + + override fun getUserPreference(): Result> = runCatching { + remoteUserDataSource.getUserPreference().preference + }.mapCatching { + Triple( + Preference(it[0][0], it[0][1].toInt()), + Preference(it[1][0], it[1][1].toInt()), + Preference(it[2][0], it[2][1].toInt()), + ) + }.recoverCatching { exception -> + when (exception) { + is HttpException -> { + throw ApiError(exception.message()) + } + + else -> { + throw exception + } + } + } } diff --git a/data/user/src/main/java/com/record/user/source/remote/RemoteUserDataSource.kt b/data/user/src/main/java/com/record/user/source/remote/RemoteUserDataSource.kt index 2cbe7ae8..95bfd88e 100644 --- a/data/user/src/main/java/com/record/user/source/remote/RemoteUserDataSource.kt +++ b/data/user/src/main/java/com/record/user/source/remote/RemoteUserDataSource.kt @@ -2,6 +2,7 @@ package com.record.user.source.remote import com.record.user.model.remote.response.ResponseGetFollowerListDto import com.record.user.model.remote.response.ResponseGetFollowingListDto +import com.record.user.model.remote.response.ResponseGetUserPreferenceDto import com.record.user.model.remote.response.ResponseGetUserProfileDto import com.record.user.model.remote.response.ResponsePostFollowDto @@ -18,9 +19,12 @@ interface RemoteUserDataSource { fun postFollow( followingId: Long, - ): ResponsePostFollowDto + ): Boolean fun getUserProfile( userId: Long, ): ResponseGetUserProfileDto + + fun getUserPreference( + ): ResponseGetUserPreferenceDto } From 70cf1d1d94775d0a9448d2b2350c0d90d83d503a Mon Sep 17 00:00:00 2001 From: Sangwook123 Date: Tue, 16 Jul 2024 23:07:26 +0900 Subject: [PATCH 10/14] [feat] #92 data video --- .../video/model/remote/response/RecordInfo.kt | 3 ++ .../response/ResponseGetBookmarkVideoDto.kt | 14 ------ ...deoDto.kt => ResponseGetPagingVideoDto.kt} | 11 ++++- ...ideoDto.kt => ResponseGetSliceVideoDto.kt} | 4 +- .../remote/response/ResponseGetVideoDto.kt | 1 + .../video/repository/VideoRepositoryImpl.kt | 49 +------------------ .../source/remote/RemoteVideoDataSource.kt | 14 +++++- 7 files changed, 29 insertions(+), 67 deletions(-) delete mode 100644 data/video/src/main/java/com/record/video/model/remote/response/ResponseGetBookmarkVideoDto.kt rename data/video/src/main/java/com/record/video/model/remote/response/{ResponseGetPopularVideoDto.kt => ResponseGetPagingVideoDto.kt} (60%) rename data/video/src/main/java/com/record/video/model/remote/response/{ResponseGetRecentVideoDto.kt => ResponseGetSliceVideoDto.kt} (84%) diff --git a/data/video/src/main/java/com/record/video/model/remote/response/RecordInfo.kt b/data/video/src/main/java/com/record/video/model/remote/response/RecordInfo.kt index c2f9c91b..5e022b18 100644 --- a/data/video/src/main/java/com/record/video/model/remote/response/RecordInfo.kt +++ b/data/video/src/main/java/com/record/video/model/remote/response/RecordInfo.kt @@ -2,6 +2,7 @@ package com.record.video.model.remote.response import kotlinx.serialization.SerialName import kotlinx.serialization.Serializable +import java.io.Serial @Serializable data class RecordInfo( @@ -19,6 +20,8 @@ data class RecordInfo( val uploaderId: Int, @SerialName("uploaderNickname") val uploaderNickname: String, + @SerialName("isMine") + val isMine: Boolean ) @Serializable diff --git a/data/video/src/main/java/com/record/video/model/remote/response/ResponseGetBookmarkVideoDto.kt b/data/video/src/main/java/com/record/video/model/remote/response/ResponseGetBookmarkVideoDto.kt deleted file mode 100644 index 09593f1e..00000000 --- a/data/video/src/main/java/com/record/video/model/remote/response/ResponseGetBookmarkVideoDto.kt +++ /dev/null @@ -1,14 +0,0 @@ -package com.record.video.model.remote.response - -import kotlinx.serialization.SerialName -import kotlinx.serialization.Serializable - -@Serializable -data class ResponseGetBookmarkVideoDto( - @SerialName("content") - val content: List, - @SerialName("hasNext") - val hasNext: Boolean, - @SerialName("nextCursor") - val nextCursor: Int, -) diff --git a/data/video/src/main/java/com/record/video/model/remote/response/ResponseGetPopularVideoDto.kt b/data/video/src/main/java/com/record/video/model/remote/response/ResponseGetPagingVideoDto.kt similarity index 60% rename from data/video/src/main/java/com/record/video/model/remote/response/ResponseGetPopularVideoDto.kt rename to data/video/src/main/java/com/record/video/model/remote/response/ResponseGetPagingVideoDto.kt index d0524840..15bca4ba 100644 --- a/data/video/src/main/java/com/record/video/model/remote/response/ResponseGetPopularVideoDto.kt +++ b/data/video/src/main/java/com/record/video/model/remote/response/ResponseGetPagingVideoDto.kt @@ -1,10 +1,11 @@ package com.record.video.model.remote.response +import com.record.model.Page import kotlinx.serialization.SerialName import kotlinx.serialization.Serializable @Serializable -data class ResponseGetPopularVideoDto( +data class ResponseGetPagingVideoDto( @SerialName("content") val content: List, @SerialName("hasNext") @@ -12,3 +13,11 @@ data class ResponseGetPopularVideoDto( @SerialName("pageNumber") val pageNumber: Int, ) + +fun ResponseGetPagingVideoDto.toCore() = Page( + hasNext = hasNext, + page = pageNumber, + data = content.map { + it.toDomain() + } +) diff --git a/data/video/src/main/java/com/record/video/model/remote/response/ResponseGetRecentVideoDto.kt b/data/video/src/main/java/com/record/video/model/remote/response/ResponseGetSliceVideoDto.kt similarity index 84% rename from data/video/src/main/java/com/record/video/model/remote/response/ResponseGetRecentVideoDto.kt rename to data/video/src/main/java/com/record/video/model/remote/response/ResponseGetSliceVideoDto.kt index 53ffdecf..27958055 100644 --- a/data/video/src/main/java/com/record/video/model/remote/response/ResponseGetRecentVideoDto.kt +++ b/data/video/src/main/java/com/record/video/model/remote/response/ResponseGetSliceVideoDto.kt @@ -5,7 +5,7 @@ import kotlinx.serialization.SerialName import kotlinx.serialization.Serializable @Serializable -data class ResponseGetRecentVideoDto( +data class ResponseGetSliceVideoDto( @SerialName("content") val content: List, @SerialName("hasNext") @@ -14,7 +14,7 @@ data class ResponseGetRecentVideoDto( val nextCursor: Int, ) -fun ResponseGetRecentVideoDto.toCore() = Cursor( +fun ResponseGetSliceVideoDto.toCore() = Cursor( hasNext = hasNext, nextCursor = nextCursor, data = content.map { content -> diff --git a/data/video/src/main/java/com/record/video/model/remote/response/ResponseGetVideoDto.kt b/data/video/src/main/java/com/record/video/model/remote/response/ResponseGetVideoDto.kt index 97f828f4..c4b6b427 100644 --- a/data/video/src/main/java/com/record/video/model/remote/response/ResponseGetVideoDto.kt +++ b/data/video/src/main/java/com/record/video/model/remote/response/ResponseGetVideoDto.kt @@ -22,4 +22,5 @@ fun ResponseGetVideoDto.toDomain() = VideoData( location = recordInfo.location, uploaderId = recordInfo.uploaderId, nickname = recordInfo.uploaderNickname, + isMine = recordInfo.isMine, ) diff --git a/data/video/src/main/java/com/record/video/repository/VideoRepositoryImpl.kt b/data/video/src/main/java/com/record/video/repository/VideoRepositoryImpl.kt index 184221d2..4a1c3185 100644 --- a/data/video/src/main/java/com/record/video/repository/VideoRepositoryImpl.kt +++ b/data/video/src/main/java/com/record/video/repository/VideoRepositoryImpl.kt @@ -1,48 +1 @@ -package com.record.video.repository - -import com.record.common.util.toUTF8HexString -import com.record.model.Cursor -import com.record.model.exception.ApiError -import com.record.video.model.VideoData -import com.record.video.model.remote.response.toCore -import com.record.video.model.remote.response.toDomain -import com.record.video.source.remote.RemoteVideoDataSource -import retrofit2.HttpException -import javax.inject.Inject - -class VideoRepositoryImpl @Inject constructor( - private val remoteVideoDataSource: RemoteVideoDataSource, -) : VideoRepository { - override fun getAllVideos(cursorId: Long, pageSize: Int): Result> = runCatching { - remoteVideoDataSource.getAllVideos(cursorId, pageSize) - }.mapCatching { - it.map { video -> video.toDomain() } - }.recoverCatching { exception -> - when (exception) { - is HttpException -> { - throw ApiError(exception.message()) - } - - else -> { - throw exception - } - } - } - - override fun getRecentVideos(keywords: List, pageNumber: Int, pageSize: Int): Result> = runCatching { - val encodedKeywords = keywords.map { toUTF8HexString(it) } - remoteVideoDataSource.getRecentVideos(encodedKeywords, pageNumber, pageSize) - }.mapCatching { - it.toCore() - }.recoverCatching { exception -> - when (exception) { - is HttpException -> { - throw ApiError(exception.message()) - } - - else -> { - throw exception - } - } - } -} +package com.record.video.repository import com.record.common.util.toUTF8HexString import com.record.model.Cursor import com.record.model.Page import com.record.model.exception.ApiError import com.record.video.model.VideoData import com.record.video.model.remote.response.toCore import com.record.video.model.remote.response.toDomain import com.record.video.source.remote.RemoteVideoDataSource import retrofit2.HttpException import javax.inject.Inject class VideoRepositoryImpl @Inject constructor( private val remoteVideoDataSource: RemoteVideoDataSource, ) : VideoRepository { override fun getAllVideos(cursorId: Long, pageSize: Int): Result> = runCatching { remoteVideoDataSource.getAllVideos(cursorId, pageSize) }.mapCatching { it.map { video -> video.toDomain() } }.recoverCatching { exception -> when (exception) { is HttpException -> { throw ApiError(exception.message()) } else -> { throw exception } } } override fun getRecentVideos(keywords: List, pageNumber: Int, pageSize: Int): Result> = runCatching { val encodedKeywords = keywords.map { toUTF8HexString(it) } remoteVideoDataSource.getRecentVideos(encodedKeywords, pageNumber, pageSize) }.mapCatching { it.toCore() }.recoverCatching { exception -> when (exception) { is HttpException -> { throw ApiError(exception.message()) } else -> { throw exception } } } override fun getPopularVideos(keywords: List, pageNumber: Int, pageSize: Int): Result> = runCatching { val encodedKeywords = keywords.map { toUTF8HexString(it) } remoteVideoDataSource.getPopularVideos(encodedKeywords, pageNumber, pageSize) }.mapCatching { it.toCore() }.recoverCatching { exception -> when (exception) { is HttpException -> { throw ApiError(exception.message()) } else -> { throw exception } } } override fun getUserVideos(otherUserId: Long, cursorId: Long, size: Int): Result> = runCatching { remoteVideoDataSource.getUserVideos(otherUserId, cursorId, size) }.mapCatching { it.toCore() }.recoverCatching { exception -> when (exception) { is HttpException -> { throw ApiError(exception.message()) } else -> { throw exception } } } override fun getFollowingVideos(userId: Long, cursorId: Long, size: Int): Result> = runCatching { remoteVideoDataSource.getFollowingVideos(userId, cursorId, size) }.mapCatching { it.toCore() }.recoverCatching { exception -> when (exception) { is HttpException -> { throw ApiError(exception.message()) } else -> { throw exception } } } override fun getBookmarkVideos(cursorId: Long, size: Int): Result> = runCatching { remoteVideoDataSource.getBookmarkVideos(cursorId, size) }.mapCatching { it.toCore() }.recoverCatching { exception -> when (exception) { is HttpException -> { throw ApiError(exception.message()) } else -> { throw exception } } } override fun bookmark(videoId: Long): Result = runCatching { remoteVideoDataSource.bookmark(videoId) }.recoverCatching { exception -> when (exception) { is HttpException -> { throw ApiError(exception.message()) } else -> { throw exception } } } } \ No newline at end of file diff --git a/data/video/src/main/java/com/record/video/source/remote/RemoteVideoDataSource.kt b/data/video/src/main/java/com/record/video/source/remote/RemoteVideoDataSource.kt index a1c5cc2d..856dd8b4 100644 --- a/data/video/src/main/java/com/record/video/source/remote/RemoteVideoDataSource.kt +++ b/data/video/src/main/java/com/record/video/source/remote/RemoteVideoDataSource.kt @@ -1,9 +1,19 @@ package com.record.video.source.remote -import com.record.video.model.remote.response.ResponseGetRecentVideoDto +import com.record.video.model.remote.response.ResponseGetPagingVideoDto +import com.record.video.model.remote.response.ResponseGetSliceVideoDto import com.record.video.model.remote.response.ResponseGetVideoDto +import retrofit2.http.GET +import retrofit2.http.Header +import retrofit2.http.Path +import retrofit2.http.Query interface RemoteVideoDataSource { fun getAllVideos(cursorId: Long, size: Int): List - fun getRecentVideos(keywords: List, pageNumber: Int, pageSize: Int): ResponseGetRecentVideoDto + fun getRecentVideos(keywords: List, pageNumber: Int, pageSize: Int): ResponseGetSliceVideoDto + fun getPopularVideos(keywords: List, pageNumber: Int, pageSize: Int): ResponseGetPagingVideoDto + fun getUserVideos(otherUserId: Long, cursorId: Long, size: Int): ResponseGetSliceVideoDto + fun getFollowingVideos(userId: Long, cursorId: Long, size: Int): ResponseGetSliceVideoDto + fun getBookmarkVideos(cursorId: Long, size: Int): ResponseGetSliceVideoDto + fun bookmark(recordId: Long): Boolean } From 0eff38f0dc463c2812c718419b06221a33e8f782 Mon Sep 17 00:00:00 2001 From: Sangwook123 Date: Tue, 16 Jul 2024 23:07:43 +0900 Subject: [PATCH 11/14] [feat] #92 add module --- app/build.gradle.kts | 2 ++ settings.gradle.kts | 3 +++ 2 files changed, 5 insertions(+) diff --git a/app/build.gradle.kts b/app/build.gradle.kts index 7b3ce665..cef03290 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -18,10 +18,12 @@ dependencies { implementation(projects.data.oauth) implementation(projects.data.video) implementation(projects.data.user) + implementation(projects.data.keyword) implementation(projects.local.auth) implementation(projects.remote.auth) implementation(projects.remote.user) implementation(projects.remote.video) + implementation(projects.remote.keyword) implementation(projects.feature.navigator) implementation(libs.kakao.login) } diff --git a/settings.gradle.kts b/settings.gradle.kts index 70299261..fd7faf77 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -51,3 +51,6 @@ include(":data:user") include(":data:video") include(":remote:video") include(":remote:user") +include(":domain:keyword") +include(":data:keyword") +include(":remote:keyword") From 6e0748779b74ffc41e8e9a32165c1bd4d05a988d Mon Sep 17 00:00:00 2001 From: Sangwook123 Date: Tue, 16 Jul 2024 23:51:09 +0900 Subject: [PATCH 12/14] [chore] #92 ktlintformat --- .../model/remote/response/ResponseGetUserPreferenceDto.kt | 3 +-- .../com/record/user/source/remote/RemoteUserDataSource.kt | 4 +--- .../java/com/record/video/model/remote/response/RecordInfo.kt | 3 +-- .../video/model/remote/response/ResponseGetPagingVideoDto.kt | 2 +- .../com/record/video/source/remote/RemoteVideoDataSource.kt | 4 ---- .../main/java/com/record/keyword/model/PreferenceKeyword.kt | 2 +- .../main/java/com/record/user/repository/UserRepository.kt | 2 +- .../video/src/main/java/com/record/video/model/VideoData.kt | 2 +- .../com/record/user/datasource/RemoteUserDataSourceImpl.kt | 1 - .../com/record/video/datasource/RemoteVideoDataSourceImpl.kt | 1 - 10 files changed, 7 insertions(+), 17 deletions(-) diff --git a/data/user/src/main/java/com/record/user/model/remote/response/ResponseGetUserPreferenceDto.kt b/data/user/src/main/java/com/record/user/model/remote/response/ResponseGetUserPreferenceDto.kt index 6fe3da50..776e9c51 100644 --- a/data/user/src/main/java/com/record/user/model/remote/response/ResponseGetUserPreferenceDto.kt +++ b/data/user/src/main/java/com/record/user/model/remote/response/ResponseGetUserPreferenceDto.kt @@ -1,6 +1,5 @@ package com.record.user.model.remote.response - import kotlinx.serialization.SerialName import kotlinx.serialization.Serializable @@ -9,5 +8,5 @@ data class ResponseGetUserPreferenceDto( @SerialName("preference") val preference: List>, @SerialName("userId") - val userId: Int + val userId: Int, ) diff --git a/data/user/src/main/java/com/record/user/source/remote/RemoteUserDataSource.kt b/data/user/src/main/java/com/record/user/source/remote/RemoteUserDataSource.kt index 95bfd88e..4f7ee135 100644 --- a/data/user/src/main/java/com/record/user/source/remote/RemoteUserDataSource.kt +++ b/data/user/src/main/java/com/record/user/source/remote/RemoteUserDataSource.kt @@ -4,7 +4,6 @@ import com.record.user.model.remote.response.ResponseGetFollowerListDto import com.record.user.model.remote.response.ResponseGetFollowingListDto import com.record.user.model.remote.response.ResponseGetUserPreferenceDto import com.record.user.model.remote.response.ResponseGetUserProfileDto -import com.record.user.model.remote.response.ResponsePostFollowDto interface RemoteUserDataSource { fun getFollowingList( @@ -25,6 +24,5 @@ interface RemoteUserDataSource { userId: Long, ): ResponseGetUserProfileDto - fun getUserPreference( - ): ResponseGetUserPreferenceDto + fun getUserPreference(): ResponseGetUserPreferenceDto } diff --git a/data/video/src/main/java/com/record/video/model/remote/response/RecordInfo.kt b/data/video/src/main/java/com/record/video/model/remote/response/RecordInfo.kt index 5e022b18..5938cfb4 100644 --- a/data/video/src/main/java/com/record/video/model/remote/response/RecordInfo.kt +++ b/data/video/src/main/java/com/record/video/model/remote/response/RecordInfo.kt @@ -2,7 +2,6 @@ package com.record.video.model.remote.response import kotlinx.serialization.SerialName import kotlinx.serialization.Serializable -import java.io.Serial @Serializable data class RecordInfo( @@ -21,7 +20,7 @@ data class RecordInfo( @SerialName("uploaderNickname") val uploaderNickname: String, @SerialName("isMine") - val isMine: Boolean + val isMine: Boolean, ) @Serializable diff --git a/data/video/src/main/java/com/record/video/model/remote/response/ResponseGetPagingVideoDto.kt b/data/video/src/main/java/com/record/video/model/remote/response/ResponseGetPagingVideoDto.kt index 15bca4ba..58b4cae7 100644 --- a/data/video/src/main/java/com/record/video/model/remote/response/ResponseGetPagingVideoDto.kt +++ b/data/video/src/main/java/com/record/video/model/remote/response/ResponseGetPagingVideoDto.kt @@ -19,5 +19,5 @@ fun ResponseGetPagingVideoDto.toCore() = Page( page = pageNumber, data = content.map { it.toDomain() - } + }, ) diff --git a/data/video/src/main/java/com/record/video/source/remote/RemoteVideoDataSource.kt b/data/video/src/main/java/com/record/video/source/remote/RemoteVideoDataSource.kt index 856dd8b4..e9cfa462 100644 --- a/data/video/src/main/java/com/record/video/source/remote/RemoteVideoDataSource.kt +++ b/data/video/src/main/java/com/record/video/source/remote/RemoteVideoDataSource.kt @@ -3,10 +3,6 @@ package com.record.video.source.remote import com.record.video.model.remote.response.ResponseGetPagingVideoDto import com.record.video.model.remote.response.ResponseGetSliceVideoDto import com.record.video.model.remote.response.ResponseGetVideoDto -import retrofit2.http.GET -import retrofit2.http.Header -import retrofit2.http.Path -import retrofit2.http.Query interface RemoteVideoDataSource { fun getAllVideos(cursorId: Long, size: Int): List diff --git a/domain/keyword/src/main/java/com/record/keyword/model/PreferenceKeyword.kt b/domain/keyword/src/main/java/com/record/keyword/model/PreferenceKeyword.kt index 306426b8..5ad823fc 100644 --- a/domain/keyword/src/main/java/com/record/keyword/model/PreferenceKeyword.kt +++ b/domain/keyword/src/main/java/com/record/keyword/model/PreferenceKeyword.kt @@ -1,5 +1,5 @@ package com.record.keyword.model data class PreferenceKeyword( - val keywords: List + val keywords: List, ) diff --git a/domain/user/src/main/java/com/record/user/repository/UserRepository.kt b/domain/user/src/main/java/com/record/user/repository/UserRepository.kt index 8ede21c9..ab3c99cb 100644 --- a/domain/user/src/main/java/com/record/user/repository/UserRepository.kt +++ b/domain/user/src/main/java/com/record/user/repository/UserRepository.kt @@ -24,5 +24,5 @@ interface UserRepository { userId: Long, ): Result - fun getUserPreference(): Result> + fun getUserPreference(): Result> } diff --git a/domain/video/src/main/java/com/record/video/model/VideoData.kt b/domain/video/src/main/java/com/record/video/model/VideoData.kt index 8e3ce484..26a9ae64 100644 --- a/domain/video/src/main/java/com/record/video/model/VideoData.kt +++ b/domain/video/src/main/java/com/record/video/model/VideoData.kt @@ -10,5 +10,5 @@ data class VideoData( val location: String, val uploaderId: Int, val nickname: String, - val isMine: Boolean + val isMine: Boolean, ) diff --git a/remote/user/src/main/java/com/record/user/datasource/RemoteUserDataSourceImpl.kt b/remote/user/src/main/java/com/record/user/datasource/RemoteUserDataSourceImpl.kt index 2e16bacb..a669d3f6 100644 --- a/remote/user/src/main/java/com/record/user/datasource/RemoteUserDataSourceImpl.kt +++ b/remote/user/src/main/java/com/record/user/datasource/RemoteUserDataSourceImpl.kt @@ -5,7 +5,6 @@ import com.record.user.model.remote.response.ResponseGetFollowerListDto import com.record.user.model.remote.response.ResponseGetFollowingListDto import com.record.user.model.remote.response.ResponseGetUserPreferenceDto import com.record.user.model.remote.response.ResponseGetUserProfileDto -import com.record.user.model.remote.response.ResponsePostFollowDto import com.record.user.source.remote.RemoteUserDataSource import javax.inject.Inject diff --git a/remote/video/src/main/java/com/record/video/datasource/RemoteVideoDataSourceImpl.kt b/remote/video/src/main/java/com/record/video/datasource/RemoteVideoDataSourceImpl.kt index 9e264c27..7b0894fe 100644 --- a/remote/video/src/main/java/com/record/video/datasource/RemoteVideoDataSourceImpl.kt +++ b/remote/video/src/main/java/com/record/video/datasource/RemoteVideoDataSourceImpl.kt @@ -30,5 +30,4 @@ class RemoteVideoDataSourceImpl @Inject constructor( override fun getBookmarkVideos(cursorId: Long, size: Int): ResponseGetSliceVideoDto = videoApi.getBookmarkVideos(cursorId, size) override fun bookmark(recordId: Long): Boolean = videoApi.postBookmark(recordId) - } From 649327e1c32a64b099ec7e8156ab01c20f9474bb Mon Sep 17 00:00:00 2001 From: Sangwook123 Date: Wed, 17 Jul 2024 00:17:41 +0900 Subject: [PATCH 13/14] [chore] #92 suspend --- .../keyword/repository/KeywordRepositoryImpl.kt | 2 +- .../keyword/source/RemoteKeywordDataSource.kt | 2 +- .../record/user/repository/UserRepositoryImpl.kt | 10 +++++----- .../user/source/remote/RemoteUserDataSource.kt | 10 +++++----- .../video/repository/UploadRepositoryImpl.kt | 4 ++-- .../video/repository/VideoCoreRepositoryImpl.kt | 4 ++-- .../record/video/repository/VideoRepositoryImpl.kt | 2 +- .../video/source/remote/RemoteUploadDataSource.kt | 4 ++-- .../source/remote/RemoteVideoCoreDataSource.kt | 4 ++-- .../video/source/remote/RemoteVideoDataSource.kt | 14 +++++++------- .../record/keyword/repository/KeywordRepository.kt | 2 +- .../record/upload/repository/UploadRepository.kt | 4 ++-- .../com/record/user/repository/UserRepository.kt | 10 +++++----- .../record/video/repository/VideoCoreRepository.kt | 4 ++-- .../com/record/video/repository/VideoRepository.kt | 14 +++++++------- .../main/java/com/record/keyword/api/KeywordApi.kt | 2 +- .../keyword/source/RemoteKeywordDataSourceImpl.kt | 2 +- .../src/main/java/com/record/user/api/UserApi.kt | 10 +++++----- .../user/datasource/RemoteUserDataSourceImpl.kt | 10 +++++----- .../main/java/com/record/video/api/UploadApi.kt | 4 ++-- .../src/main/java/com/record/video/api/VideoApi.kt | 14 +++++++------- .../main/java/com/record/video/api/VideoCoreApi.kt | 4 ++-- .../video/datasource/RemoteUploadDataSourceImpl.kt | 4 ++-- .../datasource/RemoteVideoCoreDataSourceImpl.kt | 4 ++-- .../video/datasource/RemoteVideoDataSourceImpl.kt | 14 +++++++------- 25 files changed, 79 insertions(+), 79 deletions(-) diff --git a/data/keyword/src/main/java/com/record/keyword/repository/KeywordRepositoryImpl.kt b/data/keyword/src/main/java/com/record/keyword/repository/KeywordRepositoryImpl.kt index 410fb36d..b615fef7 100644 --- a/data/keyword/src/main/java/com/record/keyword/repository/KeywordRepositoryImpl.kt +++ b/data/keyword/src/main/java/com/record/keyword/repository/KeywordRepositoryImpl.kt @@ -9,7 +9,7 @@ import javax.inject.Inject class KeywordRepositoryImpl @Inject constructor( private val remoteKeywordDataSource: RemoteKeywordDataSource, ) : KeywordRepository { - override fun getKeywords(): Result = runCatching { + override suspend fun getKeywords(): Result = runCatching { remoteKeywordDataSource.getKeywords() }.mapCatching { PreferenceKeyword(keywords = it) diff --git a/data/keyword/src/main/java/com/record/keyword/source/RemoteKeywordDataSource.kt b/data/keyword/src/main/java/com/record/keyword/source/RemoteKeywordDataSource.kt index 67b16f9f..1534c08f 100644 --- a/data/keyword/src/main/java/com/record/keyword/source/RemoteKeywordDataSource.kt +++ b/data/keyword/src/main/java/com/record/keyword/source/RemoteKeywordDataSource.kt @@ -1,5 +1,5 @@ package com.record.keyword.source interface RemoteKeywordDataSource { - fun getKeywords(): List + suspend fun getKeywords(): List } diff --git a/data/user/src/main/java/com/record/user/repository/UserRepositoryImpl.kt b/data/user/src/main/java/com/record/user/repository/UserRepositoryImpl.kt index cb28bd7d..7b99f3fb 100644 --- a/data/user/src/main/java/com/record/user/repository/UserRepositoryImpl.kt +++ b/data/user/src/main/java/com/record/user/repository/UserRepositoryImpl.kt @@ -14,7 +14,7 @@ import javax.inject.Inject class UserRepositoryImpl @Inject constructor( private val remoteUserDataSource: RemoteUserDataSource, ) : UserRepository { - override fun getFollowingList(cursorId: Long, size: Int): Result> = runCatching { + override suspend fun getFollowingList(cursorId: Long, size: Int): Result> = runCatching { remoteUserDataSource.getFollowerList(cursorId, size) }.mapCatching { it.toCore() @@ -30,7 +30,7 @@ class UserRepositoryImpl @Inject constructor( } } - override fun getFollowerList(cursorId: Long, size: Int): Result> = runCatching { + override suspend fun getFollowerList(cursorId: Long, size: Int): Result> = runCatching { remoteUserDataSource.getFollowerList(cursorId, size) }.mapCatching { it.toCore() @@ -46,7 +46,7 @@ class UserRepositoryImpl @Inject constructor( } } - override fun postFollow(followingId: Long): Result = runCatching { + override suspend fun postFollow(followingId: Long): Result = runCatching { remoteUserDataSource.postFollow(followingId) }.map { it @@ -62,7 +62,7 @@ class UserRepositoryImpl @Inject constructor( } } - override fun getUserProfile(userId: Long): Result = runCatching { + override suspend fun getUserProfile(userId: Long): Result = runCatching { remoteUserDataSource.getUserProfile(userId) }.mapCatching { it.toDomain() @@ -78,7 +78,7 @@ class UserRepositoryImpl @Inject constructor( } } - override fun getUserPreference(): Result> = runCatching { + override suspend fun getUserPreference(): Result> = runCatching { remoteUserDataSource.getUserPreference().preference }.mapCatching { Triple( diff --git a/data/user/src/main/java/com/record/user/source/remote/RemoteUserDataSource.kt b/data/user/src/main/java/com/record/user/source/remote/RemoteUserDataSource.kt index 4f7ee135..3656fc58 100644 --- a/data/user/src/main/java/com/record/user/source/remote/RemoteUserDataSource.kt +++ b/data/user/src/main/java/com/record/user/source/remote/RemoteUserDataSource.kt @@ -6,23 +6,23 @@ import com.record.user.model.remote.response.ResponseGetUserPreferenceDto import com.record.user.model.remote.response.ResponseGetUserProfileDto interface RemoteUserDataSource { - fun getFollowingList( + suspend fun getFollowingList( cursorId: Long, size: Int, ): ResponseGetFollowingListDto - fun getFollowerList( + suspend fun getFollowerList( cursorId: Long, size: Int, ): ResponseGetFollowerListDto - fun postFollow( + suspend fun postFollow( followingId: Long, ): Boolean - fun getUserProfile( + suspend fun getUserProfile( userId: Long, ): ResponseGetUserProfileDto - fun getUserPreference(): ResponseGetUserPreferenceDto + suspend fun getUserPreference(): ResponseGetUserPreferenceDto } diff --git a/data/video/src/main/java/com/record/video/repository/UploadRepositoryImpl.kt b/data/video/src/main/java/com/record/video/repository/UploadRepositoryImpl.kt index 0821479f..8c62712c 100644 --- a/data/video/src/main/java/com/record/video/repository/UploadRepositoryImpl.kt +++ b/data/video/src/main/java/com/record/video/repository/UploadRepositoryImpl.kt @@ -13,7 +13,7 @@ import javax.inject.Inject class UploadRepositoryImpl @Inject constructor( private val remoteUploadDataSource: RemoteUploadDataSource, ) : UploadRepository { - override fun getPresignedUrl(): Result = runCatching { + override suspend fun getPresignedUrl(): Result = runCatching { remoteUploadDataSource.getUploadUrl() }.mapCatching { it.toCore() @@ -29,7 +29,7 @@ class UploadRepositoryImpl @Inject constructor( } } - override fun uploadRecord(videoInfo: VideoInfo): Result = runCatching { + override suspend fun uploadRecord(videoInfo: VideoInfo): Result = runCatching { remoteUploadDataSource.uploadRecord(videoInfo.toData()) }.recoverCatching { exception -> when (exception) { diff --git a/data/video/src/main/java/com/record/video/repository/VideoCoreRepositoryImpl.kt b/data/video/src/main/java/com/record/video/repository/VideoCoreRepositoryImpl.kt index 787aa03f..2ac17256 100644 --- a/data/video/src/main/java/com/record/video/repository/VideoCoreRepositoryImpl.kt +++ b/data/video/src/main/java/com/record/video/repository/VideoCoreRepositoryImpl.kt @@ -8,7 +8,7 @@ import javax.inject.Inject class VideoCoreRepositoryImpl @Inject constructor( private val remoteVideoCoreDataSource: RemoteVideoCoreDataSource, ) : VideoCoreRepository { - override fun deleteVideo(id: Long): Result = runCatching { + override suspend fun deleteVideo(id: Long): Result = runCatching { remoteVideoCoreDataSource.deleteVideo(id) }.recoverCatching { exception -> when (exception) { @@ -22,7 +22,7 @@ class VideoCoreRepositoryImpl @Inject constructor( } } - override fun watchVideo(id: Long): Result = runCatching { + override suspend fun watchVideo(id: Long): Result = runCatching { remoteVideoCoreDataSource.watchVideo(id) }.recoverCatching { exception -> when (exception) { diff --git a/data/video/src/main/java/com/record/video/repository/VideoRepositoryImpl.kt b/data/video/src/main/java/com/record/video/repository/VideoRepositoryImpl.kt index 4a1c3185..46e3d7a7 100644 --- a/data/video/src/main/java/com/record/video/repository/VideoRepositoryImpl.kt +++ b/data/video/src/main/java/com/record/video/repository/VideoRepositoryImpl.kt @@ -1 +1 @@ -package com.record.video.repository import com.record.common.util.toUTF8HexString import com.record.model.Cursor import com.record.model.Page import com.record.model.exception.ApiError import com.record.video.model.VideoData import com.record.video.model.remote.response.toCore import com.record.video.model.remote.response.toDomain import com.record.video.source.remote.RemoteVideoDataSource import retrofit2.HttpException import javax.inject.Inject class VideoRepositoryImpl @Inject constructor( private val remoteVideoDataSource: RemoteVideoDataSource, ) : VideoRepository { override fun getAllVideos(cursorId: Long, pageSize: Int): Result> = runCatching { remoteVideoDataSource.getAllVideos(cursorId, pageSize) }.mapCatching { it.map { video -> video.toDomain() } }.recoverCatching { exception -> when (exception) { is HttpException -> { throw ApiError(exception.message()) } else -> { throw exception } } } override fun getRecentVideos(keywords: List, pageNumber: Int, pageSize: Int): Result> = runCatching { val encodedKeywords = keywords.map { toUTF8HexString(it) } remoteVideoDataSource.getRecentVideos(encodedKeywords, pageNumber, pageSize) }.mapCatching { it.toCore() }.recoverCatching { exception -> when (exception) { is HttpException -> { throw ApiError(exception.message()) } else -> { throw exception } } } override fun getPopularVideos(keywords: List, pageNumber: Int, pageSize: Int): Result> = runCatching { val encodedKeywords = keywords.map { toUTF8HexString(it) } remoteVideoDataSource.getPopularVideos(encodedKeywords, pageNumber, pageSize) }.mapCatching { it.toCore() }.recoverCatching { exception -> when (exception) { is HttpException -> { throw ApiError(exception.message()) } else -> { throw exception } } } override fun getUserVideos(otherUserId: Long, cursorId: Long, size: Int): Result> = runCatching { remoteVideoDataSource.getUserVideos(otherUserId, cursorId, size) }.mapCatching { it.toCore() }.recoverCatching { exception -> when (exception) { is HttpException -> { throw ApiError(exception.message()) } else -> { throw exception } } } override fun getFollowingVideos(userId: Long, cursorId: Long, size: Int): Result> = runCatching { remoteVideoDataSource.getFollowingVideos(userId, cursorId, size) }.mapCatching { it.toCore() }.recoverCatching { exception -> when (exception) { is HttpException -> { throw ApiError(exception.message()) } else -> { throw exception } } } override fun getBookmarkVideos(cursorId: Long, size: Int): Result> = runCatching { remoteVideoDataSource.getBookmarkVideos(cursorId, size) }.mapCatching { it.toCore() }.recoverCatching { exception -> when (exception) { is HttpException -> { throw ApiError(exception.message()) } else -> { throw exception } } } override fun bookmark(videoId: Long): Result = runCatching { remoteVideoDataSource.bookmark(videoId) }.recoverCatching { exception -> when (exception) { is HttpException -> { throw ApiError(exception.message()) } else -> { throw exception } } } } \ No newline at end of file +package com.record.video.repository import com.record.common.util.toUTF8HexString import com.record.model.Cursor import com.record.model.Page import com.record.model.exception.ApiError import com.record.video.model.VideoData import com.record.video.model.remote.response.toCore import com.record.video.model.remote.response.toDomain import com.record.video.source.remote.RemoteVideoDataSource import retrofit2.HttpException import javax.inject.Inject class VideoRepositoryImpl @Inject constructor( private val remoteVideoDataSource: RemoteVideoDataSource, ) : VideoRepository { override suspend fun getAllVideos(cursorId: Long, pageSize: Int): Result> = runCatching { remoteVideoDataSource.getAllVideos(cursorId, pageSize) }.mapCatching { it.map { video -> video.toDomain() } }.recoverCatching { exception -> when (exception) { is HttpException -> { throw ApiError(exception.message()) } else -> { throw exception } } } override suspend fun getRecentVideos(keywords: List, pageNumber: Int, pageSize: Int): Result> = runCatching { val encodedKeywords = keywords.map { toUTF8HexString(it) } remoteVideoDataSource.getRecentVideos(encodedKeywords, pageNumber, pageSize) }.mapCatching { it.toCore() }.recoverCatching { exception -> when (exception) { is HttpException -> { throw ApiError(exception.message()) } else -> { throw exception } } } override suspend fun getPopularVideos(keywords: List, pageNumber: Int, pageSize: Int): Result> = runCatching { val encodedKeywords = keywords.map { toUTF8HexString(it) } remoteVideoDataSource.getPopularVideos(encodedKeywords, pageNumber, pageSize) }.mapCatching { it.toCore() }.recoverCatching { exception -> when (exception) { is HttpException -> { throw ApiError(exception.message()) } else -> { throw exception } } } override suspend fun getUserVideos(otherUserId: Long, cursorId: Long, size: Int): Result> = runCatching { remoteVideoDataSource.getUserVideos(otherUserId, cursorId, size) }.mapCatching { it.toCore() }.recoverCatching { exception -> when (exception) { is HttpException -> { throw ApiError(exception.message()) } else -> { throw exception } } } override suspend fun getFollowingVideos(userId: Long, cursorId: Long, size: Int): Result> = runCatching { remoteVideoDataSource.getFollowingVideos(userId, cursorId, size) }.mapCatching { it.toCore() }.recoverCatching { exception -> when (exception) { is HttpException -> { throw ApiError(exception.message()) } else -> { throw exception } } } override suspend fun getBookmarkVideos(cursorId: Long, size: Int): Result> = runCatching { remoteVideoDataSource.getBookmarkVideos(cursorId, size) }.mapCatching { it.toCore() }.recoverCatching { exception -> when (exception) { is HttpException -> { throw ApiError(exception.message()) } else -> { throw exception } } } override suspend fun bookmark(videoId: Long): Result = runCatching { remoteVideoDataSource.bookmark(videoId) }.recoverCatching { exception -> when (exception) { is HttpException -> { throw ApiError(exception.message()) } else -> { throw exception } } } } \ No newline at end of file diff --git a/data/video/src/main/java/com/record/video/source/remote/RemoteUploadDataSource.kt b/data/video/src/main/java/com/record/video/source/remote/RemoteUploadDataSource.kt index 35948622..1e5ddd02 100644 --- a/data/video/src/main/java/com/record/video/source/remote/RemoteUploadDataSource.kt +++ b/data/video/src/main/java/com/record/video/source/remote/RemoteUploadDataSource.kt @@ -4,6 +4,6 @@ import com.record.video.model.remote.request.RequestPostVideoDto import com.record.video.model.remote.response.ResponseGetPresignedUrlDto interface RemoteUploadDataSource { - fun getUploadUrl(): ResponseGetPresignedUrlDto - fun uploadRecord(requestPostVideoDto: RequestPostVideoDto) + suspend fun getUploadUrl(): ResponseGetPresignedUrlDto + suspend fun uploadRecord(requestPostVideoDto: RequestPostVideoDto) } diff --git a/data/video/src/main/java/com/record/video/source/remote/RemoteVideoCoreDataSource.kt b/data/video/src/main/java/com/record/video/source/remote/RemoteVideoCoreDataSource.kt index ecb580b1..cc1027a0 100644 --- a/data/video/src/main/java/com/record/video/source/remote/RemoteVideoCoreDataSource.kt +++ b/data/video/src/main/java/com/record/video/source/remote/RemoteVideoCoreDataSource.kt @@ -1,6 +1,6 @@ package com.record.video.source.remote interface RemoteVideoCoreDataSource { - fun deleteVideo(recordId: Long) - fun watchVideo(recordId: Long) + suspend fun deleteVideo(recordId: Long) + suspend fun watchVideo(recordId: Long) } diff --git a/data/video/src/main/java/com/record/video/source/remote/RemoteVideoDataSource.kt b/data/video/src/main/java/com/record/video/source/remote/RemoteVideoDataSource.kt index e9cfa462..ff733c46 100644 --- a/data/video/src/main/java/com/record/video/source/remote/RemoteVideoDataSource.kt +++ b/data/video/src/main/java/com/record/video/source/remote/RemoteVideoDataSource.kt @@ -5,11 +5,11 @@ import com.record.video.model.remote.response.ResponseGetSliceVideoDto import com.record.video.model.remote.response.ResponseGetVideoDto interface RemoteVideoDataSource { - fun getAllVideos(cursorId: Long, size: Int): List - fun getRecentVideos(keywords: List, pageNumber: Int, pageSize: Int): ResponseGetSliceVideoDto - fun getPopularVideos(keywords: List, pageNumber: Int, pageSize: Int): ResponseGetPagingVideoDto - fun getUserVideos(otherUserId: Long, cursorId: Long, size: Int): ResponseGetSliceVideoDto - fun getFollowingVideos(userId: Long, cursorId: Long, size: Int): ResponseGetSliceVideoDto - fun getBookmarkVideos(cursorId: Long, size: Int): ResponseGetSliceVideoDto - fun bookmark(recordId: Long): Boolean + suspend fun getAllVideos(cursorId: Long, size: Int): List + suspend fun getRecentVideos(keywords: List, pageNumber: Int, pageSize: Int): ResponseGetSliceVideoDto + suspend fun getPopularVideos(keywords: List, pageNumber: Int, pageSize: Int): ResponseGetPagingVideoDto + suspend fun getUserVideos(otherUserId: Long, cursorId: Long, size: Int): ResponseGetSliceVideoDto + suspend fun getFollowingVideos(userId: Long, cursorId: Long, size: Int): ResponseGetSliceVideoDto + suspend fun getBookmarkVideos(cursorId: Long, size: Int): ResponseGetSliceVideoDto + suspend fun bookmark(recordId: Long): Boolean } diff --git a/domain/keyword/src/main/java/com/record/keyword/repository/KeywordRepository.kt b/domain/keyword/src/main/java/com/record/keyword/repository/KeywordRepository.kt index 18301397..8bfb380c 100644 --- a/domain/keyword/src/main/java/com/record/keyword/repository/KeywordRepository.kt +++ b/domain/keyword/src/main/java/com/record/keyword/repository/KeywordRepository.kt @@ -3,5 +3,5 @@ package com.record.keyword.repository import com.record.keyword.model.PreferenceKeyword interface KeywordRepository { - fun getKeywords(): Result + suspend fun getKeywords(): Result } diff --git a/domain/upload/src/main/java/com/record/upload/repository/UploadRepository.kt b/domain/upload/src/main/java/com/record/upload/repository/UploadRepository.kt index b323f74c..512a62db 100644 --- a/domain/upload/src/main/java/com/record/upload/repository/UploadRepository.kt +++ b/domain/upload/src/main/java/com/record/upload/repository/UploadRepository.kt @@ -4,6 +4,6 @@ import com.record.upload.model.UploadInfo import com.record.upload.model.VideoInfo interface UploadRepository { - fun getPresignedUrl(): Result - fun uploadRecord(videoInfo: VideoInfo): Result + suspend fun getPresignedUrl(): Result + suspend fun uploadRecord(videoInfo: VideoInfo): Result } diff --git a/domain/user/src/main/java/com/record/user/repository/UserRepository.kt b/domain/user/src/main/java/com/record/user/repository/UserRepository.kt index ab3c99cb..1897151a 100644 --- a/domain/user/src/main/java/com/record/user/repository/UserRepository.kt +++ b/domain/user/src/main/java/com/record/user/repository/UserRepository.kt @@ -6,23 +6,23 @@ import com.record.user.model.Profile import com.record.user.model.User interface UserRepository { - fun getFollowingList( + suspend fun getFollowingList( cursorId: Long, size: Int, ): Result> - fun getFollowerList( + suspend fun getFollowerList( cursorId: Long, size: Int, ): Result> - fun postFollow( + suspend fun postFollow( followingId: Long, ): Result - fun getUserProfile( + suspend fun getUserProfile( userId: Long, ): Result - fun getUserPreference(): Result> + suspend fun getUserPreference(): Result> } diff --git a/domain/video/src/main/java/com/record/video/repository/VideoCoreRepository.kt b/domain/video/src/main/java/com/record/video/repository/VideoCoreRepository.kt index 5c12cbd0..4ac88112 100644 --- a/domain/video/src/main/java/com/record/video/repository/VideoCoreRepository.kt +++ b/domain/video/src/main/java/com/record/video/repository/VideoCoreRepository.kt @@ -1,6 +1,6 @@ package com.record.video.repository interface VideoCoreRepository { - fun deleteVideo(id: Long): Result - fun watchVideo(id: Long): Result + suspend fun deleteVideo(id: Long): Result + suspend fun watchVideo(id: Long): Result } diff --git a/domain/video/src/main/java/com/record/video/repository/VideoRepository.kt b/domain/video/src/main/java/com/record/video/repository/VideoRepository.kt index 6968d82c..36f5695d 100644 --- a/domain/video/src/main/java/com/record/video/repository/VideoRepository.kt +++ b/domain/video/src/main/java/com/record/video/repository/VideoRepository.kt @@ -5,11 +5,11 @@ import com.record.model.Page import com.record.video.model.VideoData interface VideoRepository { - fun getAllVideos(cursorId: Long, pageSize: Int): Result> - fun getRecentVideos(keywords: List, pageNumber: Int, pageSize: Int): Result> - fun getPopularVideos(keywords: List, pageNumber: Int, pageSize: Int): Result> - fun getUserVideos(otherUserId: Long, cursorId: Long, size: Int): Result> - fun getFollowingVideos(userId: Long, cursorId: Long, size: Int): Result> - fun getBookmarkVideos(cursorId: Long, size: Int): Result> - fun bookmark(videoId: Long): Result + suspend fun getAllVideos(cursorId: Long, pageSize: Int): Result> + suspend fun getRecentVideos(keywords: List, pageNumber: Int, pageSize: Int): Result> + suspend fun getPopularVideos(keywords: List, pageNumber: Int, pageSize: Int): Result> + suspend fun getUserVideos(otherUserId: Long, cursorId: Long, size: Int): Result> + suspend fun getFollowingVideos(userId: Long, cursorId: Long, size: Int): Result> + suspend fun getBookmarkVideos(cursorId: Long, size: Int): Result> + suspend fun bookmark(videoId: Long): Result } diff --git a/remote/keyword/src/main/java/com/record/keyword/api/KeywordApi.kt b/remote/keyword/src/main/java/com/record/keyword/api/KeywordApi.kt index b44ac5ed..17f38537 100644 --- a/remote/keyword/src/main/java/com/record/keyword/api/KeywordApi.kt +++ b/remote/keyword/src/main/java/com/record/keyword/api/KeywordApi.kt @@ -4,5 +4,5 @@ import retrofit2.http.GET interface KeywordApi { @GET("/api/v1/keywords") - fun getKeywords(): List + suspend fun getKeywords(): List } diff --git a/remote/keyword/src/main/java/com/record/keyword/source/RemoteKeywordDataSourceImpl.kt b/remote/keyword/src/main/java/com/record/keyword/source/RemoteKeywordDataSourceImpl.kt index 9dd5023a..9b066082 100644 --- a/remote/keyword/src/main/java/com/record/keyword/source/RemoteKeywordDataSourceImpl.kt +++ b/remote/keyword/src/main/java/com/record/keyword/source/RemoteKeywordDataSourceImpl.kt @@ -6,5 +6,5 @@ import javax.inject.Inject class RemoteKeywordDataSourceImpl @Inject constructor( private val keywordApi: KeywordApi, ) : RemoteKeywordDataSource { - override fun getKeywords(): List = keywordApi.getKeywords() + override suspend fun getKeywords(): List = keywordApi.getKeywords() } diff --git a/remote/user/src/main/java/com/record/user/api/UserApi.kt b/remote/user/src/main/java/com/record/user/api/UserApi.kt index 5d270dca..9c136455 100644 --- a/remote/user/src/main/java/com/record/user/api/UserApi.kt +++ b/remote/user/src/main/java/com/record/user/api/UserApi.kt @@ -11,27 +11,27 @@ import retrofit2.http.Query interface UserApi { @GET("/api/v1/users/following") - fun getFollowingList( + suspend fun getFollowingList( @Query("cursorId") cursorId: Long, @Query("size") size: Int, ): ResponseGetFollowingListDto @GET("/api/v1/users/follower") - fun getFollowerList( + suspend fun getFollowerList( @Query("cursorId") cursorId: Long, @Query("size") size: Int, ): ResponseGetFollowerListDto @POST("/api/v1/users/follow/{followingId}") - fun postFollow( + suspend fun postFollow( @Path("followingId") followingId: Long, ): Boolean @GET("/api/v1/users/profile/{userId}") - fun getUserProfileDto( + suspend fun getUserProfileDto( @Path("userId") userId: Long, ): ResponseGetUserProfileDto @GET("/api/v1/preference") - fun getUserPreference(): ResponseGetUserPreferenceDto + suspend fun getUserPreference(): ResponseGetUserPreferenceDto } diff --git a/remote/user/src/main/java/com/record/user/datasource/RemoteUserDataSourceImpl.kt b/remote/user/src/main/java/com/record/user/datasource/RemoteUserDataSourceImpl.kt index a669d3f6..ace22e11 100644 --- a/remote/user/src/main/java/com/record/user/datasource/RemoteUserDataSourceImpl.kt +++ b/remote/user/src/main/java/com/record/user/datasource/RemoteUserDataSourceImpl.kt @@ -11,13 +11,13 @@ import javax.inject.Inject class RemoteUserDataSourceImpl @Inject constructor( private val userApi: UserApi, ) : RemoteUserDataSource { - override fun getFollowingList(cursorId: Long, size: Int): ResponseGetFollowingListDto = userApi.getFollowingList(cursorId, size) + override suspend fun getFollowingList(cursorId: Long, size: Int): ResponseGetFollowingListDto = userApi.getFollowingList(cursorId, size) - override fun getFollowerList(cursorId: Long, size: Int): ResponseGetFollowerListDto = userApi.getFollowerList(cursorId, size) + override suspend fun getFollowerList(cursorId: Long, size: Int): ResponseGetFollowerListDto = userApi.getFollowerList(cursorId, size) - override fun postFollow(followingId: Long): Boolean = userApi.postFollow(followingId) + override suspend fun postFollow(followingId: Long): Boolean = userApi.postFollow(followingId) - override fun getUserProfile(userId: Long): ResponseGetUserProfileDto = userApi.getUserProfileDto(userId) + override suspend fun getUserProfile(userId: Long): ResponseGetUserProfileDto = userApi.getUserProfileDto(userId) - override fun getUserPreference(): ResponseGetUserPreferenceDto = userApi.getUserPreference() + override suspend fun getUserPreference(): ResponseGetUserPreferenceDto = userApi.getUserPreference() } diff --git a/remote/video/src/main/java/com/record/video/api/UploadApi.kt b/remote/video/src/main/java/com/record/video/api/UploadApi.kt index 160fb3aa..57065b40 100644 --- a/remote/video/src/main/java/com/record/video/api/UploadApi.kt +++ b/remote/video/src/main/java/com/record/video/api/UploadApi.kt @@ -8,8 +8,8 @@ import retrofit2.http.POST interface UploadApi { @GET("/api/v1/records/presigned-url") - fun getPresignedUploadUrl(): ResponseGetPresignedUrlDto + suspend fun getPresignedUploadUrl(): ResponseGetPresignedUrlDto @POST("/api/v1/records") - fun postRecord(@Body requestPostVideoDto: RequestPostVideoDto) + suspend fun postRecord(@Body requestPostVideoDto: RequestPostVideoDto) } diff --git a/remote/video/src/main/java/com/record/video/api/VideoApi.kt b/remote/video/src/main/java/com/record/video/api/VideoApi.kt index da7f3e38..a72110a0 100644 --- a/remote/video/src/main/java/com/record/video/api/VideoApi.kt +++ b/remote/video/src/main/java/com/record/video/api/VideoApi.kt @@ -11,47 +11,47 @@ import retrofit2.http.Query interface VideoApi { @GET("/api/v1/records") - fun getAllVideos( + suspend fun getAllVideos( @Query("cursorId") cursorId: Long, @Query("size") size: Int, ): List @GET("/api/v1/records/recent") - fun getRecentVideos( + suspend fun getRecentVideos( @Query("keywords") keywords: List, @Query("pageNumber") pageNumber: Int, @Query("pageSize") pageSize: Int, ): ResponseGetSliceVideoDto @GET("/api/v1/records/famous") - fun getPopularVideos( + suspend fun getPopularVideos( @Query("keywords") keywords: List, @Query("pageNumber") pageNumber: Int, @Query("pageSize") pageSize: Int, ): ResponseGetPagingVideoDto @GET("/api/v1/records/user/{otherUserId}") - fun getUserVideos( + suspend fun getUserVideos( @Path("otherUserId") otherUserId: Long, @Query("cursorId") cursorId: Long, @Query("size") size: Int, ): ResponseGetSliceVideoDto @GET("/api/v1/records/following") - fun getFollowingVideos( + suspend fun getFollowingVideos( @Header("userId") userId: Long, @Query("cursorId") cursorId: Long, @Query("size") size: Int, ): ResponseGetSliceVideoDto @GET("/api/v1/records/bookmark") - fun getBookmarkVideos( + suspend fun getBookmarkVideos( @Query("cursorId") cursorId: Long, @Query("size") size: Int, ): ResponseGetSliceVideoDto @POST("/api/v1/bookmarks/{recordId}") - fun postBookmark( + suspend fun postBookmark( @Path("recordId") recordId: Long, ): Boolean } diff --git a/remote/video/src/main/java/com/record/video/api/VideoCoreApi.kt b/remote/video/src/main/java/com/record/video/api/VideoCoreApi.kt index f05536f0..275fbe65 100644 --- a/remote/video/src/main/java/com/record/video/api/VideoCoreApi.kt +++ b/remote/video/src/main/java/com/record/video/api/VideoCoreApi.kt @@ -6,12 +6,12 @@ import retrofit2.http.Path interface VideoCoreApi { @POST("/api/v1/records/{record_id}") - fun postWatchVideo( + suspend fun postWatchVideo( @Path("record_id") recordId: Long, ) @DELETE("/api/v1/records/{record_id}") - fun deleteVideo( + suspend fun deleteVideo( @Path("record_id") recordId: Long, ) } diff --git a/remote/video/src/main/java/com/record/video/datasource/RemoteUploadDataSourceImpl.kt b/remote/video/src/main/java/com/record/video/datasource/RemoteUploadDataSourceImpl.kt index f509e14e..127e7f0a 100644 --- a/remote/video/src/main/java/com/record/video/datasource/RemoteUploadDataSourceImpl.kt +++ b/remote/video/src/main/java/com/record/video/datasource/RemoteUploadDataSourceImpl.kt @@ -9,9 +9,9 @@ import javax.inject.Inject class RemoteUploadDataSourceImpl @Inject constructor( private val uploadApi: UploadApi, ) : RemoteUploadDataSource { - override fun getUploadUrl(): ResponseGetPresignedUrlDto = uploadApi.getPresignedUploadUrl() + override suspend fun getUploadUrl(): ResponseGetPresignedUrlDto = uploadApi.getPresignedUploadUrl() - override fun uploadRecord( + override suspend fun uploadRecord( requestPostVideoDto: RequestPostVideoDto, ) = uploadApi.postRecord(requestPostVideoDto) } diff --git a/remote/video/src/main/java/com/record/video/datasource/RemoteVideoCoreDataSourceImpl.kt b/remote/video/src/main/java/com/record/video/datasource/RemoteVideoCoreDataSourceImpl.kt index c1a48cf0..33a2e0ff 100644 --- a/remote/video/src/main/java/com/record/video/datasource/RemoteVideoCoreDataSourceImpl.kt +++ b/remote/video/src/main/java/com/record/video/datasource/RemoteVideoCoreDataSourceImpl.kt @@ -7,7 +7,7 @@ import javax.inject.Inject class RemoteVideoCoreDataSourceImpl @Inject constructor( private val videoCoreApi: VideoCoreApi, ) : RemoteVideoCoreDataSource { - override fun deleteVideo(recordId: Long) = videoCoreApi.deleteVideo(recordId) + override suspend fun deleteVideo(recordId: Long) = videoCoreApi.deleteVideo(recordId) - override fun watchVideo(recordId: Long) = videoCoreApi.postWatchVideo(recordId) + override suspend fun watchVideo(recordId: Long) = videoCoreApi.postWatchVideo(recordId) } diff --git a/remote/video/src/main/java/com/record/video/datasource/RemoteVideoDataSourceImpl.kt b/remote/video/src/main/java/com/record/video/datasource/RemoteVideoDataSourceImpl.kt index 7b0894fe..b46e2ee0 100644 --- a/remote/video/src/main/java/com/record/video/datasource/RemoteVideoDataSourceImpl.kt +++ b/remote/video/src/main/java/com/record/video/datasource/RemoteVideoDataSourceImpl.kt @@ -10,24 +10,24 @@ import javax.inject.Inject class RemoteVideoDataSourceImpl @Inject constructor( private val videoApi: VideoApi, ) : RemoteVideoDataSource { - override fun getAllVideos(cursorId: Long, size: Int): List = videoApi.getAllVideos(cursorId, size) + override suspend fun getAllVideos(cursorId: Long, size: Int): List = videoApi.getAllVideos(cursorId, size) - override fun getRecentVideos(keywords: List, pageNumber: Int, pageSize: Int): ResponseGetSliceVideoDto = videoApi.getRecentVideos( + override suspend fun getRecentVideos(keywords: List, pageNumber: Int, pageSize: Int): ResponseGetSliceVideoDto = videoApi.getRecentVideos( keywords, pageNumber, pageSize, ) - override fun getPopularVideos(keywords: List, pageNumber: Int, pageSize: Int): ResponseGetPagingVideoDto = + override suspend fun getPopularVideos(keywords: List, pageNumber: Int, pageSize: Int): ResponseGetPagingVideoDto = videoApi.getPopularVideos(keywords, pageNumber, pageSize) - override fun getUserVideos(otherUserId: Long, cursorId: Long, size: Int): ResponseGetSliceVideoDto = + override suspend fun getUserVideos(otherUserId: Long, cursorId: Long, size: Int): ResponseGetSliceVideoDto = videoApi.getUserVideos(otherUserId, cursorId, size) - override fun getFollowingVideos(userId: Long, cursorId: Long, size: Int): ResponseGetSliceVideoDto = + override suspend fun getFollowingVideos(userId: Long, cursorId: Long, size: Int): ResponseGetSliceVideoDto = videoApi.getFollowingVideos(userId, cursorId, size) - override fun getBookmarkVideos(cursorId: Long, size: Int): ResponseGetSliceVideoDto = videoApi.getBookmarkVideos(cursorId, size) + override suspend fun getBookmarkVideos(cursorId: Long, size: Int): ResponseGetSliceVideoDto = videoApi.getBookmarkVideos(cursorId, size) - override fun bookmark(recordId: Long): Boolean = videoApi.postBookmark(recordId) + override suspend fun bookmark(recordId: Long): Boolean = videoApi.postBookmark(recordId) } From f0d6ef6b86be5392eca04dd62879cd46bf9bf58b Mon Sep 17 00:00:00 2001 From: Sangwook123 Date: Wed, 17 Jul 2024 00:23:26 +0900 Subject: [PATCH 14/14] [chore] #92 di module singletoncomponent --- .../keyword/src/main/java/com/record/keyword/di/ApiModule.kt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/remote/keyword/src/main/java/com/record/keyword/di/ApiModule.kt b/remote/keyword/src/main/java/com/record/keyword/di/ApiModule.kt index b4d170d9..1f5dfec8 100644 --- a/remote/keyword/src/main/java/com/record/keyword/di/ApiModule.kt +++ b/remote/keyword/src/main/java/com/record/keyword/di/ApiModule.kt @@ -5,12 +5,13 @@ import com.record.network.di.Auth import dagger.Module import dagger.Provides import dagger.hilt.InstallIn +import dagger.hilt.components.SingletonComponent import retrofit2.Retrofit import retrofit2.create import javax.inject.Singleton @Module -@InstallIn +@InstallIn(SingletonComponent::class) object ApiModule { @Provides @Singleton