From 875f77579c7f386f643aa228a368bcb1d1d41188 Mon Sep 17 00:00:00 2001 From: boiledegg Date: Sat, 9 Nov 2024 16:13:24 +0900 Subject: [PATCH 01/17] =?UTF-8?q?[=EC=B6=94=EA=B0=80]=20LibraryArea=20?= =?UTF-8?q?=EB=8F=84=EB=A9=94=EC=9D=B8=20=EC=97=94=ED=8B=B0=ED=8B=B0=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/com/ku_stacks/ku_ring/domain/LibraryArea.kt | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 data/domain/src/main/java/com/ku_stacks/ku_ring/domain/LibraryArea.kt diff --git a/data/domain/src/main/java/com/ku_stacks/ku_ring/domain/LibraryArea.kt b/data/domain/src/main/java/com/ku_stacks/ku_ring/domain/LibraryArea.kt new file mode 100644 index 00000000..fe855c50 --- /dev/null +++ b/data/domain/src/main/java/com/ku_stacks/ku_ring/domain/LibraryArea.kt @@ -0,0 +1,8 @@ +package com.ku_stacks.ku_ring.domain + +data class LibraryArea( + val name: String, + val totalSeats: String, + val occupiedSeats: String, + val availableSeats: String +) From 38e48668ce51a95b436c1fcb858b6c676b5d1f9a Mon Sep 17 00:00:00 2001 From: boiledegg Date: Sat, 9 Nov 2024 16:26:37 +0900 Subject: [PATCH 02/17] =?UTF-8?q?[=EC=B6=94=EA=B0=80]=20=EB=8F=84=EC=84=9C?= =?UTF-8?q?=EA=B4=80=EC=9A=A9=20=EB=A0=88=ED=8A=B8=EB=A1=9C=ED=95=8F=20?= =?UTF-8?q?=EB=AA=A8=EB=93=88=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ku_stacks/ku_ring/remote/util/NetworkModule.kt | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/data/remote/src/main/java/com/ku_stacks/ku_ring/remote/util/NetworkModule.kt b/data/remote/src/main/java/com/ku_stacks/ku_ring/remote/util/NetworkModule.kt index 0d4dee0d..9c3292c0 100644 --- a/data/remote/src/main/java/com/ku_stacks/ku_ring/remote/util/NetworkModule.kt +++ b/data/remote/src/main/java/com/ku_stacks/ku_ring/remote/util/NetworkModule.kt @@ -71,4 +71,15 @@ object NetworkModule { } return KuringBotSSEClient(client) } + + @Provides + @Singleton + @Named("Library") + fun provideLibraryRetrofit(@Named("Default") okHttpClient: OkHttpClient): Retrofit { + return Retrofit.Builder() + .client(okHttpClient) + .baseUrl("https://library.konkuk.ac.kr/pyxis-api/") + .addConverterFactory(GsonConverterFactory.create()) + .build() + } } \ No newline at end of file From 3eb841d77d31f0704fc326a9d9886d209ae56c40 Mon Sep 17 00:00:00 2001 From: boiledegg Date: Sat, 9 Nov 2024 16:59:34 +0900 Subject: [PATCH 03/17] =?UTF-8?q?[=EC=B6=94=EA=B0=80]=20=EC=9D=91=EB=8B=B5?= =?UTF-8?q?=20dto=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../library/response/LibraryRoomBranchResponse.kt | 11 +++++++++++ .../library/response/LibraryRoomListResponse.kt | 10 ++++++++++ .../remote/library/response/LibraryRoomResponse.kt | 14 ++++++++++++++ .../library/response/LibraryRoomSeatResponse.kt | 8 ++++++++ .../library/response/LibraryRoomTypeResponse.kt | 9 +++++++++ .../remote/library/response/LibrarySeatResponse.kt | 8 ++++++++ 6 files changed, 60 insertions(+) create mode 100644 data/remote/src/main/java/com/ku_stacks/ku_ring/remote/library/response/LibraryRoomBranchResponse.kt create mode 100644 data/remote/src/main/java/com/ku_stacks/ku_ring/remote/library/response/LibraryRoomListResponse.kt create mode 100644 data/remote/src/main/java/com/ku_stacks/ku_ring/remote/library/response/LibraryRoomResponse.kt create mode 100644 data/remote/src/main/java/com/ku_stacks/ku_ring/remote/library/response/LibraryRoomSeatResponse.kt create mode 100644 data/remote/src/main/java/com/ku_stacks/ku_ring/remote/library/response/LibraryRoomTypeResponse.kt create mode 100644 data/remote/src/main/java/com/ku_stacks/ku_ring/remote/library/response/LibrarySeatResponse.kt diff --git a/data/remote/src/main/java/com/ku_stacks/ku_ring/remote/library/response/LibraryRoomBranchResponse.kt b/data/remote/src/main/java/com/ku_stacks/ku_ring/remote/library/response/LibraryRoomBranchResponse.kt new file mode 100644 index 00000000..f05e83de --- /dev/null +++ b/data/remote/src/main/java/com/ku_stacks/ku_ring/remote/library/response/LibraryRoomBranchResponse.kt @@ -0,0 +1,11 @@ +package com.ku_stacks.ku_ring.remote.library.response + +import com.google.gson.annotations.SerializedName + +data class LibraryRoomBranchResponse ( + val id: Int, + @SerializedName("name") val roomBranchName: String, + val alias: String, + val libraryCode: String, + val sortOrder: Int +) \ No newline at end of file diff --git a/data/remote/src/main/java/com/ku_stacks/ku_ring/remote/library/response/LibraryRoomListResponse.kt b/data/remote/src/main/java/com/ku_stacks/ku_ring/remote/library/response/LibraryRoomListResponse.kt new file mode 100644 index 00000000..356c2cc8 --- /dev/null +++ b/data/remote/src/main/java/com/ku_stacks/ku_ring/remote/library/response/LibraryRoomListResponse.kt @@ -0,0 +1,10 @@ +package com.ku_stacks.ku_ring.remote.library.response + +import com.google.gson.annotations.SerializedName + +data class LibraryRoomListResponse( + @SerializedName(value = "totalCount") + val resultCount: Int, + @SerializedName(value = "list") + val libraryRooms: List +) \ No newline at end of file diff --git a/data/remote/src/main/java/com/ku_stacks/ku_ring/remote/library/response/LibraryRoomResponse.kt b/data/remote/src/main/java/com/ku_stacks/ku_ring/remote/library/response/LibraryRoomResponse.kt new file mode 100644 index 00000000..e436fb3b --- /dev/null +++ b/data/remote/src/main/java/com/ku_stacks/ku_ring/remote/library/response/LibraryRoomResponse.kt @@ -0,0 +1,14 @@ +package com.ku_stacks.ku_ring.remote.library.response + +import com.google.gson.annotations.SerializedName + +data class LibraryRoomResponse( + val id: Int, + @SerializedName("name") val roomName: String, + val roomType: LibraryRoomTypeResponse, + val awaitable: Boolean, + val isChargeable: Boolean, + val branch: LibraryRoomBranchResponse, + val unableMessage: String?, + val seats: LibraryRoomSeatResponse +) \ No newline at end of file diff --git a/data/remote/src/main/java/com/ku_stacks/ku_ring/remote/library/response/LibraryRoomSeatResponse.kt b/data/remote/src/main/java/com/ku_stacks/ku_ring/remote/library/response/LibraryRoomSeatResponse.kt new file mode 100644 index 00000000..65542ef4 --- /dev/null +++ b/data/remote/src/main/java/com/ku_stacks/ku_ring/remote/library/response/LibraryRoomSeatResponse.kt @@ -0,0 +1,8 @@ +package com.ku_stacks.ku_ring.remote.library.response + +data class LibraryRoomSeatResponse( + val total: Int, + val occupied: Int, + val waiting: Int, + val available: Int +) diff --git a/data/remote/src/main/java/com/ku_stacks/ku_ring/remote/library/response/LibraryRoomTypeResponse.kt b/data/remote/src/main/java/com/ku_stacks/ku_ring/remote/library/response/LibraryRoomTypeResponse.kt new file mode 100644 index 00000000..852e380a --- /dev/null +++ b/data/remote/src/main/java/com/ku_stacks/ku_ring/remote/library/response/LibraryRoomTypeResponse.kt @@ -0,0 +1,9 @@ +package com.ku_stacks.ku_ring.remote.library.response + +import com.google.gson.annotations.SerializedName + +data class LibraryRoomTypeResponse( + val id : Int, + @SerializedName("name") val roomName: String, + val sortOrder: Int +) diff --git a/data/remote/src/main/java/com/ku_stacks/ku_ring/remote/library/response/LibrarySeatResponse.kt b/data/remote/src/main/java/com/ku_stacks/ku_ring/remote/library/response/LibrarySeatResponse.kt new file mode 100644 index 00000000..0362ab8f --- /dev/null +++ b/data/remote/src/main/java/com/ku_stacks/ku_ring/remote/library/response/LibrarySeatResponse.kt @@ -0,0 +1,8 @@ +package com.ku_stacks.ku_ring.remote.library.response + +data class LibrarySeatResponse( + val success: Boolean, + val code: String, + val message: String, + val data: LibraryRoomListResponse +) \ No newline at end of file From c0a455f31aa1a257a2c5716be87d6661cb5c4608 Mon Sep 17 00:00:00 2001 From: boiledegg Date: Sat, 9 Nov 2024 17:13:17 +0900 Subject: [PATCH 04/17] =?UTF-8?q?[=EC=B6=94=EA=B0=80]=20LibraryService=20?= =?UTF-8?q?=EB=B0=8F=20=ED=9E=90=ED=8A=B8=20=EB=AA=A8=EB=93=88=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ku_ring/remote/library/LibraryService.kt | 15 +++++++++++++++ .../remote/library/di/LibraryModule.kt | 19 +++++++++++++++++++ 2 files changed, 34 insertions(+) create mode 100644 data/remote/src/main/java/com/ku_stacks/ku_ring/remote/library/LibraryService.kt create mode 100644 data/remote/src/main/java/com/ku_stacks/ku_ring/remote/library/di/LibraryModule.kt diff --git a/data/remote/src/main/java/com/ku_stacks/ku_ring/remote/library/LibraryService.kt b/data/remote/src/main/java/com/ku_stacks/ku_ring/remote/library/LibraryService.kt new file mode 100644 index 00000000..8ffa8adc --- /dev/null +++ b/data/remote/src/main/java/com/ku_stacks/ku_ring/remote/library/LibraryService.kt @@ -0,0 +1,15 @@ +package com.ku_stacks.ku_ring.remote.library + +import com.ku_stacks.ku_ring.remote.library.request.LibrarySeatRequest +import com.ku_stacks.ku_ring.remote.library.response.LibrarySeatResponse +import retrofit2.http.GET +import retrofit2.http.Query + +interface LibraryService { + @GET("1/seat-rooms") + suspend fun fetchLibrarySeatStatus( + @Query("smufMethodCode") methodCode: String, + @Query("roomTypeId") roomTypeId: Int, + @Query("branchTypeId") branchTypeId: Int, + ): LibrarySeatResponse +} \ No newline at end of file diff --git a/data/remote/src/main/java/com/ku_stacks/ku_ring/remote/library/di/LibraryModule.kt b/data/remote/src/main/java/com/ku_stacks/ku_ring/remote/library/di/LibraryModule.kt new file mode 100644 index 00000000..e3870257 --- /dev/null +++ b/data/remote/src/main/java/com/ku_stacks/ku_ring/remote/library/di/LibraryModule.kt @@ -0,0 +1,19 @@ +package com.ku_stacks.ku_ring.remote.library.di + +import com.ku_stacks.ku_ring.remote.library.LibraryService +import dagger.Module +import dagger.Provides +import dagger.hilt.InstallIn +import dagger.hilt.components.SingletonComponent +import retrofit2.Retrofit +import javax.inject.Named +import javax.inject.Singleton + +@Module +@InstallIn(SingletonComponent::class) +object LibraryModule { + @Provides + @Singleton + fun provideLibraryService(@Named("Library") retrofit: Retrofit): LibraryService + = retrofit.create(LibraryService::class.java) +} \ No newline at end of file From ab4ada9ea533a55630dcba476b296638434ce072 Mon Sep 17 00:00:00 2001 From: boiledegg Date: Sat, 9 Nov 2024 17:16:21 +0900 Subject: [PATCH 05/17] =?UTF-8?q?[=EC=B6=94=EA=B0=80]=20LibraryClient=20?= =?UTF-8?q?=EB=B0=8F=20=EB=AA=A8=EB=93=88=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ku_ring/remote/library/LibraryClient.kt | 14 ++++++++++++++ .../ku_ring/remote/library/di/LibraryModule.kt | 7 +++++++ .../remote/library/request/LibrarySeatRequest.kt | 7 +++++++ 3 files changed, 28 insertions(+) create mode 100644 data/remote/src/main/java/com/ku_stacks/ku_ring/remote/library/LibraryClient.kt create mode 100644 data/remote/src/main/java/com/ku_stacks/ku_ring/remote/library/request/LibrarySeatRequest.kt diff --git a/data/remote/src/main/java/com/ku_stacks/ku_ring/remote/library/LibraryClient.kt b/data/remote/src/main/java/com/ku_stacks/ku_ring/remote/library/LibraryClient.kt new file mode 100644 index 00000000..56988c94 --- /dev/null +++ b/data/remote/src/main/java/com/ku_stacks/ku_ring/remote/library/LibraryClient.kt @@ -0,0 +1,14 @@ +package com.ku_stacks.ku_ring.remote.library + +import com.ku_stacks.ku_ring.remote.library.request.LibrarySeatRequest +import com.ku_stacks.ku_ring.remote.library.response.LibrarySeatResponse +import javax.inject.Inject + +class LibraryClient @Inject constructor(private val libraryService: LibraryService) { + + suspend fun fetchRoomSeatStatus(): LibrarySeatResponse = libraryService.fetchLibrarySeatStatus( + methodCode = LibrarySeatRequest.METHOD_CODE, + roomTypeId = LibrarySeatRequest.ROOM_TYPE_ID, + branchTypeId = LibrarySeatRequest.BRANCH_TYPE_ID, + ) +} \ No newline at end of file diff --git a/data/remote/src/main/java/com/ku_stacks/ku_ring/remote/library/di/LibraryModule.kt b/data/remote/src/main/java/com/ku_stacks/ku_ring/remote/library/di/LibraryModule.kt index e3870257..98d6ac86 100644 --- a/data/remote/src/main/java/com/ku_stacks/ku_ring/remote/library/di/LibraryModule.kt +++ b/data/remote/src/main/java/com/ku_stacks/ku_ring/remote/library/di/LibraryModule.kt @@ -1,5 +1,6 @@ package com.ku_stacks.ku_ring.remote.library.di +import com.ku_stacks.ku_ring.remote.library.LibraryClient import com.ku_stacks.ku_ring.remote.library.LibraryService import dagger.Module import dagger.Provides @@ -16,4 +17,10 @@ object LibraryModule { @Singleton fun provideLibraryService(@Named("Library") retrofit: Retrofit): LibraryService = retrofit.create(LibraryService::class.java) + + @Provides + @Singleton + fun provideLibraryClient(libraryService: LibraryService): LibraryClient + = LibraryClient(libraryService) + } \ No newline at end of file diff --git a/data/remote/src/main/java/com/ku_stacks/ku_ring/remote/library/request/LibrarySeatRequest.kt b/data/remote/src/main/java/com/ku_stacks/ku_ring/remote/library/request/LibrarySeatRequest.kt new file mode 100644 index 00000000..01469eca --- /dev/null +++ b/data/remote/src/main/java/com/ku_stacks/ku_ring/remote/library/request/LibrarySeatRequest.kt @@ -0,0 +1,7 @@ +package com.ku_stacks.ku_ring.remote.library.request + +object LibrarySeatRequest { + const val METHOD_CODE: String = "PC" + const val ROOM_TYPE_ID = 4 + const val BRANCH_TYPE_ID: Int = 1 +} \ No newline at end of file From 6e5ab880b81b67df39be89f2b4e24c4b5d42f47e Mon Sep 17 00:00:00 2001 From: boiledegg Date: Sat, 9 Nov 2024 17:17:30 +0900 Subject: [PATCH 06/17] =?UTF-8?q?[=EC=88=98=EC=A0=95]=20LibraryService=20?= =?UTF-8?q?=EB=AF=B8=EC=82=AC=EC=9A=A9=20=EB=9D=BC=EC=9D=B4=EB=B8=8C?= =?UTF-8?q?=EB=9F=AC=EB=A6=AC=20=EC=A0=9C=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/ku_stacks/ku_ring/remote/library/LibraryService.kt | 1 - 1 file changed, 1 deletion(-) diff --git a/data/remote/src/main/java/com/ku_stacks/ku_ring/remote/library/LibraryService.kt b/data/remote/src/main/java/com/ku_stacks/ku_ring/remote/library/LibraryService.kt index 8ffa8adc..c7126d80 100644 --- a/data/remote/src/main/java/com/ku_stacks/ku_ring/remote/library/LibraryService.kt +++ b/data/remote/src/main/java/com/ku_stacks/ku_ring/remote/library/LibraryService.kt @@ -1,6 +1,5 @@ package com.ku_stacks.ku_ring.remote.library -import com.ku_stacks.ku_ring.remote.library.request.LibrarySeatRequest import com.ku_stacks.ku_ring.remote.library.response.LibrarySeatResponse import retrofit2.http.GET import retrofit2.http.Query From 421b6a32ac5367550cb613ccf27dbea95831772e Mon Sep 17 00:00:00 2001 From: boiledegg Date: Sat, 9 Nov 2024 17:43:51 +0900 Subject: [PATCH 07/17] =?UTF-8?q?[=EC=B6=94=EA=B0=80]=20data:library=20?= =?UTF-8?q?=EB=AA=A8=EB=93=88=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- data/library/.gitignore | 1 + data/library/build.gradle.kts | 26 +++++++++++++++++++++++ data/library/consumer-rules.pro | 0 data/library/proguard-rules.pro | 21 ++++++++++++++++++ data/library/src/main/AndroidManifest.xml | 4 ++++ settings.gradle.kts | 1 + 6 files changed, 53 insertions(+) create mode 100644 data/library/.gitignore create mode 100644 data/library/build.gradle.kts create mode 100644 data/library/consumer-rules.pro create mode 100644 data/library/proguard-rules.pro create mode 100644 data/library/src/main/AndroidManifest.xml diff --git a/data/library/.gitignore b/data/library/.gitignore new file mode 100644 index 00000000..42afabfd --- /dev/null +++ b/data/library/.gitignore @@ -0,0 +1 @@ +/build \ No newline at end of file diff --git a/data/library/build.gradle.kts b/data/library/build.gradle.kts new file mode 100644 index 00000000..8f88cb49 --- /dev/null +++ b/data/library/build.gradle.kts @@ -0,0 +1,26 @@ +import com.ku_stacks.ku_ring.buildlogic.dsl.setNameSpace + +plugins { + kuring("feature") + kuringPrimitive("retrofit") + kuringPrimitive("test") +} + +android { + setNameSpace("library") + compileSdk = 34 + + testOptions { + unitTests { + isIncludeAndroidResources = true + } + } +} + +dependencies { + implementation(projects.core.util) + implementation(projects.data.domain) + implementation(projects.data.remote) + + testImplementation(libs.kotlinx.coroutines.test) +} \ No newline at end of file diff --git a/data/library/consumer-rules.pro b/data/library/consumer-rules.pro new file mode 100644 index 00000000..e69de29b diff --git a/data/library/proguard-rules.pro b/data/library/proguard-rules.pro new file mode 100644 index 00000000..481bb434 --- /dev/null +++ b/data/library/proguard-rules.pro @@ -0,0 +1,21 @@ +# Add project specific ProGuard rules here. +# You can control the set of applied configuration files using the +# proguardFiles setting in build.gradle. +# +# For more details, see +# http://developer.android.com/guide/developing/tools/proguard.html + +# If your project uses WebView with JS, uncomment the following +# and specify the fully qualified class name to the JavaScript interface +# class: +#-keepclassmembers class fqcn.of.javascript.interface.for.webview { +# public *; +#} + +# Uncomment this to preserve the line number information for +# debugging stack traces. +#-keepattributes SourceFile,LineNumberTable + +# If you keep the line number information, uncomment this to +# hide the original source file name. +#-renamesourcefileattribute SourceFile \ No newline at end of file diff --git a/data/library/src/main/AndroidManifest.xml b/data/library/src/main/AndroidManifest.xml new file mode 100644 index 00000000..a5918e68 --- /dev/null +++ b/data/library/src/main/AndroidManifest.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/settings.gradle.kts b/settings.gradle.kts index f2b9d80f..79b4eb36 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -51,3 +51,4 @@ include( ":feature:kuringbot", ":feature:edit_departments" ) +include(":data:library") From 435b015d262405b4e5824f2a438f7017cc74ec1d Mon Sep 17 00:00:00 2001 From: boiledegg Date: Sun, 10 Nov 2024 15:07:09 +0900 Subject: [PATCH 08/17] =?UTF-8?q?[=EC=88=98=EC=A0=95]=20=EB=8F=84=EB=A9=94?= =?UTF-8?q?=EC=9D=B8=20=EC=97=94=ED=8B=B0=ED=8B=B0=20=EC=9D=B4=EB=A6=84=20?= =?UTF-8?q?=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/com/ku_stacks/ku_ring/domain/LibraryArea.kt | 8 -------- .../main/java/com/ku_stacks/ku_ring/domain/LibraryRoom.kt | 8 ++++++++ 2 files changed, 8 insertions(+), 8 deletions(-) delete mode 100644 data/domain/src/main/java/com/ku_stacks/ku_ring/domain/LibraryArea.kt create mode 100644 data/domain/src/main/java/com/ku_stacks/ku_ring/domain/LibraryRoom.kt diff --git a/data/domain/src/main/java/com/ku_stacks/ku_ring/domain/LibraryArea.kt b/data/domain/src/main/java/com/ku_stacks/ku_ring/domain/LibraryArea.kt deleted file mode 100644 index fe855c50..00000000 --- a/data/domain/src/main/java/com/ku_stacks/ku_ring/domain/LibraryArea.kt +++ /dev/null @@ -1,8 +0,0 @@ -package com.ku_stacks.ku_ring.domain - -data class LibraryArea( - val name: String, - val totalSeats: String, - val occupiedSeats: String, - val availableSeats: String -) diff --git a/data/domain/src/main/java/com/ku_stacks/ku_ring/domain/LibraryRoom.kt b/data/domain/src/main/java/com/ku_stacks/ku_ring/domain/LibraryRoom.kt new file mode 100644 index 00000000..353b1b6b --- /dev/null +++ b/data/domain/src/main/java/com/ku_stacks/ku_ring/domain/LibraryRoom.kt @@ -0,0 +1,8 @@ +package com.ku_stacks.ku_ring.domain + +data class LibraryRoom( + val name: String, + val totalSeats: Int, + val occupiedSeats: Int, + val availableSeats: Int +) From 6b2dad6039d674693916baf122137af05141c9a5 Mon Sep 17 00:00:00 2001 From: boiledegg Date: Sun, 10 Nov 2024 15:07:52 +0900 Subject: [PATCH 09/17] =?UTF-8?q?[=EC=B6=94=EA=B0=80]=20Library=20Reposito?= =?UTF-8?q?ry=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../library/mapper/ResponseToDomain.kt | 15 +++++++++++++++ .../library/repository/LibraryRepository.kt | 7 +++++++ .../repository/LibraryRepositoryImpl.kt | 19 +++++++++++++++++++ 3 files changed, 41 insertions(+) create mode 100644 data/library/src/main/java/com/ku_stacks/ku_ring/library/mapper/ResponseToDomain.kt create mode 100644 data/library/src/main/java/com/ku_stacks/ku_ring/library/repository/LibraryRepository.kt create mode 100644 data/library/src/main/java/com/ku_stacks/ku_ring/library/repository/LibraryRepositoryImpl.kt diff --git a/data/library/src/main/java/com/ku_stacks/ku_ring/library/mapper/ResponseToDomain.kt b/data/library/src/main/java/com/ku_stacks/ku_ring/library/mapper/ResponseToDomain.kt new file mode 100644 index 00000000..c3ae8f03 --- /dev/null +++ b/data/library/src/main/java/com/ku_stacks/ku_ring/library/mapper/ResponseToDomain.kt @@ -0,0 +1,15 @@ +package com.ku_stacks.ku_ring.library.mapper + +import com.ku_stacks.ku_ring.domain.LibraryRoom +import com.ku_stacks.ku_ring.remote.library.response.LibrarySeatResponse + +fun LibrarySeatResponse.toLibraryAreaList(): List { + return data.libraryRooms.map { + LibraryRoom( + name = it.roomName, + totalSeats = it.seats.total, + availableSeats = it.seats.available, + occupiedSeats = it.seats.occupied + ) + } +} \ No newline at end of file diff --git a/data/library/src/main/java/com/ku_stacks/ku_ring/library/repository/LibraryRepository.kt b/data/library/src/main/java/com/ku_stacks/ku_ring/library/repository/LibraryRepository.kt new file mode 100644 index 00000000..e004569d --- /dev/null +++ b/data/library/src/main/java/com/ku_stacks/ku_ring/library/repository/LibraryRepository.kt @@ -0,0 +1,7 @@ +package com.ku_stacks.ku_ring.library.repository + +import com.ku_stacks.ku_ring.domain.LibraryRoom + +interface LibraryRepository { + suspend fun getRemainingSeats(): List +} \ No newline at end of file diff --git a/data/library/src/main/java/com/ku_stacks/ku_ring/library/repository/LibraryRepositoryImpl.kt b/data/library/src/main/java/com/ku_stacks/ku_ring/library/repository/LibraryRepositoryImpl.kt new file mode 100644 index 00000000..29bdee61 --- /dev/null +++ b/data/library/src/main/java/com/ku_stacks/ku_ring/library/repository/LibraryRepositoryImpl.kt @@ -0,0 +1,19 @@ +package com.ku_stacks.ku_ring.library.repository + +import com.ku_stacks.ku_ring.domain.LibraryRoom +import com.ku_stacks.ku_ring.library.mapper.toLibraryAreaList +import com.ku_stacks.ku_ring.remote.library.LibraryClient +import retrofit2.HttpException +import javax.inject.Inject + +class LibraryRepositoryImpl @Inject constructor( + private val libraryClient: LibraryClient +): LibraryRepository { + override suspend fun getRemainingSeats(): List { + return try { + libraryClient.fetchRoomSeatStatus().toLibraryAreaList() + } catch (e: HttpException) { + emptyList() + } + } +} \ No newline at end of file From f0f9525fd4d35bac1d1991cc232875c30fa8979e Mon Sep 17 00:00:00 2001 From: boiledegg Date: Sun, 10 Nov 2024 15:08:12 +0900 Subject: [PATCH 10/17] =?UTF-8?q?[=EC=B6=94=EA=B0=80]=20LibraryRepository?= =?UTF-8?q?=20DI=20=EB=AA=A8=EB=93=88=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ku_ring/library/di/RepositoryModule.kt | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 data/library/src/main/java/com/ku_stacks/ku_ring/library/di/RepositoryModule.kt diff --git a/data/library/src/main/java/com/ku_stacks/ku_ring/library/di/RepositoryModule.kt b/data/library/src/main/java/com/ku_stacks/ku_ring/library/di/RepositoryModule.kt new file mode 100644 index 00000000..de5c3e63 --- /dev/null +++ b/data/library/src/main/java/com/ku_stacks/ku_ring/library/di/RepositoryModule.kt @@ -0,0 +1,18 @@ +package com.ku_stacks.ku_ring.library.di + +import com.ku_stacks.ku_ring.library.repository.LibraryRepository +import com.ku_stacks.ku_ring.library.repository.LibraryRepositoryImpl +import dagger.Binds +import dagger.Module +import dagger.hilt.InstallIn +import dagger.hilt.components.SingletonComponent +import javax.inject.Singleton + +@InstallIn(SingletonComponent::class) +@Module +abstract class RepositoryModule { + @Binds + @Singleton + abstract fun provideLibraryRepository(repositoryImpl: LibraryRepositoryImpl): LibraryRepository + +} \ No newline at end of file From 7a0e0b38fbd77579bb91f8da373ecc3d53225516 Mon Sep 17 00:00:00 2001 From: boiledegg Date: Sat, 16 Nov 2024 01:15:44 +0900 Subject: [PATCH 11/17] =?UTF-8?q?[=EC=B6=94=EA=B0=80]=20=EB=A0=88=ED=8F=AC?= =?UTF-8?q?=EC=A7=80=ED=86=A0=EB=A6=AC=20=ED=85=8C=EC=8A=A4=ED=8A=B8=20?= =?UTF-8?q?=EC=BD=94=EB=93=9C=20=EC=9E=91=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ku_ring/library/LibraryRepositoryTest.kt | 38 +++++++++++++ .../ku_ring/library/LibraryTestUtil.kt | 57 +++++++++++++++++++ settings.gradle.kts | 2 +- 3 files changed, 96 insertions(+), 1 deletion(-) create mode 100644 data/library/src/test/java/com/ku_stacks/ku_ring/library/LibraryRepositoryTest.kt create mode 100644 data/library/src/test/java/com/ku_stacks/ku_ring/library/LibraryTestUtil.kt diff --git a/data/library/src/test/java/com/ku_stacks/ku_ring/library/LibraryRepositoryTest.kt b/data/library/src/test/java/com/ku_stacks/ku_ring/library/LibraryRepositoryTest.kt new file mode 100644 index 00000000..763d3ea4 --- /dev/null +++ b/data/library/src/test/java/com/ku_stacks/ku_ring/library/LibraryRepositoryTest.kt @@ -0,0 +1,38 @@ +package com.ku_stacks.ku_ring.library + +import com.ku_stacks.ku_ring.library.repository.LibraryRepository +import com.ku_stacks.ku_ring.library.repository.LibraryRepositoryImpl +import com.ku_stacks.ku_ring.remote.library.LibraryClient +import junit.framework.TestCase.assertEquals +import kotlinx.coroutines.test.runTest +import org.junit.Before +import org.junit.Test +import org.mockito.Mockito +import org.mockito.kotlin.times + +class LibraryRepositoryTest { + private lateinit var libraryRepository: LibraryRepository + private val client: LibraryClient = Mockito.mock(LibraryClient::class.java) + + @Before + fun setup() { + libraryRepository = LibraryRepositoryImpl(client) + } + + @Test + fun `get Library Seat Status From Remote Test`() = runTest { + val mockLibraryStatus = LibraryTestUtil.mockLibrarySeatResponse() + + Mockito.`when`(client.fetchRoomSeatStatus()).thenReturn(mockLibraryStatus) + + val mockResult = libraryRepository.getRemainingSeats() + val expectedResult = LibraryTestUtil.mockLibraryRoomList() + + Mockito.verify( + client, + times(1) + ).fetchRoomSeatStatus() + + assertEquals(mockResult, expectedResult) + } +} \ No newline at end of file diff --git a/data/library/src/test/java/com/ku_stacks/ku_ring/library/LibraryTestUtil.kt b/data/library/src/test/java/com/ku_stacks/ku_ring/library/LibraryTestUtil.kt new file mode 100644 index 00000000..39f51dbe --- /dev/null +++ b/data/library/src/test/java/com/ku_stacks/ku_ring/library/LibraryTestUtil.kt @@ -0,0 +1,57 @@ +package com.ku_stacks.ku_ring.library + +import com.ku_stacks.ku_ring.domain.LibraryRoom +import com.ku_stacks.ku_ring.remote.library.response.LibraryRoomBranchResponse +import com.ku_stacks.ku_ring.remote.library.response.LibraryRoomListResponse +import com.ku_stacks.ku_ring.remote.library.response.LibraryRoomResponse +import com.ku_stacks.ku_ring.remote.library.response.LibraryRoomSeatResponse +import com.ku_stacks.ku_ring.remote.library.response.LibraryRoomTypeResponse +import com.ku_stacks.ku_ring.remote.library.response.LibrarySeatResponse + +object LibraryTestUtil { + fun mockLibrarySeatResponse() = LibrarySeatResponse( + success = true, + code = "success.retrieved", + message = "조회되었습니다.", + data = LibraryRoomListResponse( + resultCount = 1, + libraryRooms = listOf( + LibraryRoomResponse( + id = 102, + roomName = "제 1 열람실 (23구역)", + roomType = LibraryRoomTypeResponse( + id = 1, + roomName = "열람실", + sortOrder = 1 + ), + awaitable = true, + isChargeable = true, + branch = LibraryRoomBranchResponse( + id = 1, + roomBranchName = "상허기념도서관", + alias = "상허", + libraryCode = "211004", + sortOrder = 1 + ), + unableMessage = null, + seats = LibraryRoomSeatResponse( + total = 219, + occupied = 82, + waiting = 0, + available = 137 + ) + ) + ) + ) + ) + + + fun mockLibraryRoomList() = listOf( + LibraryRoom( + name = "제 1 열람실 (A구역)", + totalSeats = 219, + occupiedSeats = 82, + availableSeats = 137 + ) + ) +} \ No newline at end of file diff --git a/settings.gradle.kts b/settings.gradle.kts index 79b4eb36..9f2ee090 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -32,6 +32,7 @@ include( ":data:staff", ":data:department", ":data:department:test", + ":data:library", ":data:local", ":data:local:test", ":data:remote", @@ -51,4 +52,3 @@ include( ":feature:kuringbot", ":feature:edit_departments" ) -include(":data:library") From bd1bebaa1d0162a4b63bd6c11e4f8a5391e2ea7e Mon Sep 17 00:00:00 2001 From: boiledegg Date: Tue, 19 Nov 2024 14:42:17 +0900 Subject: [PATCH 12/17] =?UTF-8?q?[=EC=B6=94=EA=B0=80]=20=EC=84=9C=EB=B9=84?= =?UTF-8?q?=EC=8A=A4=20=ED=85=8C=EC=8A=A4=ED=8A=B8=20=EC=BD=94=EB=93=9C=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 --- .../ku_ring/library/LibraryTestUtil.kt | 2 +- .../ku_ring/remote/LibraryServiceTest.kt | 47 +++++ .../api-response/LibrarySeatsResponse.json | 185 ++++++++++++++++++ 3 files changed, 233 insertions(+), 1 deletion(-) create mode 100644 data/remote/src/test/java/com/ku_stacks/ku_ring/remote/LibraryServiceTest.kt create mode 100644 data/remote/src/test/resources/api-response/LibrarySeatsResponse.json diff --git a/data/library/src/test/java/com/ku_stacks/ku_ring/library/LibraryTestUtil.kt b/data/library/src/test/java/com/ku_stacks/ku_ring/library/LibraryTestUtil.kt index 39f51dbe..c504d49d 100644 --- a/data/library/src/test/java/com/ku_stacks/ku_ring/library/LibraryTestUtil.kt +++ b/data/library/src/test/java/com/ku_stacks/ku_ring/library/LibraryTestUtil.kt @@ -18,7 +18,7 @@ object LibraryTestUtil { libraryRooms = listOf( LibraryRoomResponse( id = 102, - roomName = "제 1 열람실 (23구역)", + roomName = "제 1 열람실 (A구역)", roomType = LibraryRoomTypeResponse( id = 1, roomName = "열람실", diff --git a/data/remote/src/test/java/com/ku_stacks/ku_ring/remote/LibraryServiceTest.kt b/data/remote/src/test/java/com/ku_stacks/ku_ring/remote/LibraryServiceTest.kt new file mode 100644 index 00000000..9534dd0c --- /dev/null +++ b/data/remote/src/test/java/com/ku_stacks/ku_ring/remote/LibraryServiceTest.kt @@ -0,0 +1,47 @@ +package com.ku_stacks.ku_ring.remote + +import com.ku_stacks.ku_ring.remote.library.LibraryService +import kotlinx.coroutines.test.runTest +import org.junit.After +import org.junit.Assert.assertEquals +import org.junit.Before +import org.junit.Test + +class LibraryServiceTest : ApiAbstract() { + + private lateinit var service: LibraryService + + @Before + fun initService() { + super.createMockServer() + service = createService(LibraryService::class.java) + } + + @After + fun tearDown() { + super.stopServer() + } + + @Test + fun `fetch Library Seat Status From Network Test`() = runTest { + // given + enqueueResponse("/LibrarySeatsResponse.json") + + // when + val response = service.fetchLibrarySeatStatus( + methodCode = "PC", + roomTypeId = 4, + branchTypeId = 1, + ) + mockWebServer.takeRequest() + + // then + assertEquals(true, response.success) + assertEquals("조회되었습니다.", response.message) + assertEquals(7, response.data.resultCount) + assertEquals("제 1열람실 (A구역)", response.data.libraryRooms[0].roomName) + assertEquals(true, response.data.libraryRooms[0].isChargeable) + } + + +} \ No newline at end of file diff --git a/data/remote/src/test/resources/api-response/LibrarySeatsResponse.json b/data/remote/src/test/resources/api-response/LibrarySeatsResponse.json new file mode 100644 index 00000000..3798b3c5 --- /dev/null +++ b/data/remote/src/test/resources/api-response/LibrarySeatsResponse.json @@ -0,0 +1,185 @@ +{ + "success": true, + "code": "success.retrieved", + "message": "조회되었습니다.", + "data": { + "totalCount": 7, + "list": [ + { + "id": 102, + "name": "제 1열람실 (A구역)", + "roomType": { + "id": 4, + "name": "열람실", + "sortOrder": 1 + }, + "awaitable": false, + "isChargeable": true, + "branch": { + "id": 1, + "name": "상허기념도서관", + "alias": "상허", + "libraryCode": "211004", + "sortOrder": 1 + }, + "unableMessage": null, + "seats": { + "total": 219, + "occupied": 177, + "waiting": 0, + "available": 42 + } + }, + { + "id": 101, + "name": "제 1열람실 (B구역)", + "roomType": { + "id": 4, + "name": "열람실", + "sortOrder": 1 + }, + "awaitable": false, + "isChargeable": true, + "branch": { + "id": 1, + "name": "상허기념도서관", + "alias": "상허", + "libraryCode": "211004", + "sortOrder": 1 + }, + "unableMessage": null, + "seats": { + "total": 189, + "occupied": 147, + "waiting": 0, + "available": 42 + } + }, + { + "id": 103, + "name": "제 2 열람실", + "roomType": { + "id": 4, + "name": "열람실", + "sortOrder": 1 + }, + "awaitable": false, + "isChargeable": true, + "branch": { + "id": 1, + "name": "상허기념도서관", + "alias": "상허", + "libraryCode": "211004", + "sortOrder": 1 + }, + "unableMessage": null, + "seats": { + "total": 147, + "occupied": 64, + "waiting": 0, + "available": 83 + } + }, + { + "id": 104, + "name": "제 3열람실 (A구역)", + "roomType": { + "id": 4, + "name": "열람실", + "sortOrder": 1 + }, + "awaitable": false, + "isChargeable": true, + "branch": { + "id": 1, + "name": "상허기념도서관", + "alias": "상허", + "libraryCode": "211004", + "sortOrder": 1 + }, + "unableMessage": null, + "seats": { + "total": 332, + "occupied": 72, + "waiting": 0, + "available": 260 + } + }, + { + "id": 105, + "name": "제 3열람실 (B구역)", + "roomType": { + "id": 4, + "name": "열람실", + "sortOrder": 1 + }, + "awaitable": false, + "isChargeable": true, + "branch": { + "id": 1, + "name": "상허기념도서관", + "alias": "상허", + "libraryCode": "211004", + "sortOrder": 1 + }, + "unableMessage": null, + "seats": { + "total": 284, + "occupied": 54, + "waiting": 0, + "available": 230 + } + }, + { + "id": 106, + "name": "제 4 열람실", + "roomType": { + "id": 4, + "name": "열람실", + "sortOrder": 1 + }, + "awaitable": false, + "isChargeable": true, + "branch": { + "id": 1, + "name": "상허기념도서관", + "alias": "상허", + "libraryCode": "211004", + "sortOrder": 1 + }, + "unableMessage": null, + "seats": { + "total": 172, + "occupied": 15, + "waiting": 0, + "available": 157 + } + }, + { + "id": 107, + "name": "제 5 열람실", + "roomType": { + "id": 4, + "name": "열람실", + "sortOrder": 1 + }, + "awaitable": false, + "isChargeable": true, + "branch": { + "id": 1, + "name": "상허기념도서관", + "alias": "상허", + "libraryCode": "211004", + "sortOrder": 1 + }, + "unableMessage": null, + "seats": { + "total": 168, + "occupied": 27, + "waiting": 0, + "available": 141 + } + } + ] + } +} \ No newline at end of file From ff2768ca064eea3b7960d4edfc8cfa95af5bf24e Mon Sep 17 00:00:00 2001 From: boiledegg Date: Sat, 23 Nov 2024 12:30:37 +0900 Subject: [PATCH 13/17] =?UTF-8?q?[=EC=B6=94=EA=B0=80]=20DTO=20SerializedNa?= =?UTF-8?q?me=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../library/response/LibraryRoomBranchResponse.kt | 7 ++++++- .../remote/library/response/LibraryRoomResponse.kt | 10 +++++++++- .../remote/library/response/LibraryRoomSeatResponse.kt | 6 ++++++ .../remote/library/response/LibraryRoomTypeResponse.kt | 7 +++++-- .../remote/library/response/LibrarySeatResponse.kt | 6 ++++++ 5 files changed, 32 insertions(+), 4 deletions(-) diff --git a/data/remote/src/main/java/com/ku_stacks/ku_ring/remote/library/response/LibraryRoomBranchResponse.kt b/data/remote/src/main/java/com/ku_stacks/ku_ring/remote/library/response/LibraryRoomBranchResponse.kt index f05e83de..d27213e6 100644 --- a/data/remote/src/main/java/com/ku_stacks/ku_ring/remote/library/response/LibraryRoomBranchResponse.kt +++ b/data/remote/src/main/java/com/ku_stacks/ku_ring/remote/library/response/LibraryRoomBranchResponse.kt @@ -3,9 +3,14 @@ package com.ku_stacks.ku_ring.remote.library.response import com.google.gson.annotations.SerializedName data class LibraryRoomBranchResponse ( + @SerializedName("id") val id: Int, - @SerializedName("name") val roomBranchName: String, + @SerializedName("name") + val roomBranchName: String, + @SerializedName("alias") val alias: String, + @SerializedName("libraryCode") val libraryCode: String, + @SerializedName("sortOrder") val sortOrder: Int ) \ No newline at end of file diff --git a/data/remote/src/main/java/com/ku_stacks/ku_ring/remote/library/response/LibraryRoomResponse.kt b/data/remote/src/main/java/com/ku_stacks/ku_ring/remote/library/response/LibraryRoomResponse.kt index e436fb3b..55913c5a 100644 --- a/data/remote/src/main/java/com/ku_stacks/ku_ring/remote/library/response/LibraryRoomResponse.kt +++ b/data/remote/src/main/java/com/ku_stacks/ku_ring/remote/library/response/LibraryRoomResponse.kt @@ -3,12 +3,20 @@ package com.ku_stacks.ku_ring.remote.library.response import com.google.gson.annotations.SerializedName data class LibraryRoomResponse( + @SerializedName("id") val id: Int, - @SerializedName("name") val roomName: String, + @SerializedName("name") + val roomName: String, + @SerializedName("roomType") val roomType: LibraryRoomTypeResponse, + @SerializedName("awaitable") val awaitable: Boolean, + @SerializedName("isChargeable") val isChargeable: Boolean, + @SerializedName("branch") val branch: LibraryRoomBranchResponse, + @SerializedName("unableMessage") val unableMessage: String?, + @SerializedName("seats") val seats: LibraryRoomSeatResponse ) \ No newline at end of file diff --git a/data/remote/src/main/java/com/ku_stacks/ku_ring/remote/library/response/LibraryRoomSeatResponse.kt b/data/remote/src/main/java/com/ku_stacks/ku_ring/remote/library/response/LibraryRoomSeatResponse.kt index 65542ef4..c51afc59 100644 --- a/data/remote/src/main/java/com/ku_stacks/ku_ring/remote/library/response/LibraryRoomSeatResponse.kt +++ b/data/remote/src/main/java/com/ku_stacks/ku_ring/remote/library/response/LibraryRoomSeatResponse.kt @@ -1,8 +1,14 @@ package com.ku_stacks.ku_ring.remote.library.response +import com.google.gson.annotations.SerializedName + data class LibraryRoomSeatResponse( + @SerializedName("total") val total: Int, + @SerializedName("occupied") val occupied: Int, + @SerializedName("waiting") val waiting: Int, + @SerializedName("available") val available: Int ) diff --git a/data/remote/src/main/java/com/ku_stacks/ku_ring/remote/library/response/LibraryRoomTypeResponse.kt b/data/remote/src/main/java/com/ku_stacks/ku_ring/remote/library/response/LibraryRoomTypeResponse.kt index 852e380a..f5f55b36 100644 --- a/data/remote/src/main/java/com/ku_stacks/ku_ring/remote/library/response/LibraryRoomTypeResponse.kt +++ b/data/remote/src/main/java/com/ku_stacks/ku_ring/remote/library/response/LibraryRoomTypeResponse.kt @@ -3,7 +3,10 @@ package com.ku_stacks.ku_ring.remote.library.response import com.google.gson.annotations.SerializedName data class LibraryRoomTypeResponse( - val id : Int, - @SerializedName("name") val roomName: String, + @SerializedName("id") + val id: Int, + @SerializedName("name") + val roomName: String, + @SerializedName("sortOrder") val sortOrder: Int ) diff --git a/data/remote/src/main/java/com/ku_stacks/ku_ring/remote/library/response/LibrarySeatResponse.kt b/data/remote/src/main/java/com/ku_stacks/ku_ring/remote/library/response/LibrarySeatResponse.kt index 0362ab8f..770fc1fd 100644 --- a/data/remote/src/main/java/com/ku_stacks/ku_ring/remote/library/response/LibrarySeatResponse.kt +++ b/data/remote/src/main/java/com/ku_stacks/ku_ring/remote/library/response/LibrarySeatResponse.kt @@ -1,8 +1,14 @@ package com.ku_stacks.ku_ring.remote.library.response +import com.google.gson.annotations.SerializedName + data class LibrarySeatResponse( + @SerializedName("success") val success: Boolean, + @SerializedName("code") val code: String, + @SerializedName("message") val message: String, + @SerializedName("data") val data: LibraryRoomListResponse ) \ No newline at end of file From b6eecb80ac7e12ef02448e62192465d48182f7f6 Mon Sep 17 00:00:00 2001 From: boiledegg Date: Sat, 23 Nov 2024 12:34:23 +0900 Subject: [PATCH 14/17] =?UTF-8?q?[=EC=88=98=EC=A0=95]=20Repository=20?= =?UTF-8?q?=EC=98=88=EC=99=B8=EC=B2=98=EB=A6=AC=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ku_ring/library/repository/LibraryRepository.kt | 2 +- .../library/repository/LibraryRepositoryImpl.kt | 11 +++-------- 2 files changed, 4 insertions(+), 9 deletions(-) diff --git a/data/library/src/main/java/com/ku_stacks/ku_ring/library/repository/LibraryRepository.kt b/data/library/src/main/java/com/ku_stacks/ku_ring/library/repository/LibraryRepository.kt index e004569d..09f23029 100644 --- a/data/library/src/main/java/com/ku_stacks/ku_ring/library/repository/LibraryRepository.kt +++ b/data/library/src/main/java/com/ku_stacks/ku_ring/library/repository/LibraryRepository.kt @@ -3,5 +3,5 @@ package com.ku_stacks.ku_ring.library.repository import com.ku_stacks.ku_ring.domain.LibraryRoom interface LibraryRepository { - suspend fun getRemainingSeats(): List + suspend fun getRemainingSeats(): Result> } \ No newline at end of file diff --git a/data/library/src/main/java/com/ku_stacks/ku_ring/library/repository/LibraryRepositoryImpl.kt b/data/library/src/main/java/com/ku_stacks/ku_ring/library/repository/LibraryRepositoryImpl.kt index 29bdee61..aa08a744 100644 --- a/data/library/src/main/java/com/ku_stacks/ku_ring/library/repository/LibraryRepositoryImpl.kt +++ b/data/library/src/main/java/com/ku_stacks/ku_ring/library/repository/LibraryRepositoryImpl.kt @@ -3,17 +3,12 @@ package com.ku_stacks.ku_ring.library.repository import com.ku_stacks.ku_ring.domain.LibraryRoom import com.ku_stacks.ku_ring.library.mapper.toLibraryAreaList import com.ku_stacks.ku_ring.remote.library.LibraryClient -import retrofit2.HttpException import javax.inject.Inject class LibraryRepositoryImpl @Inject constructor( private val libraryClient: LibraryClient -): LibraryRepository { - override suspend fun getRemainingSeats(): List { - return try { - libraryClient.fetchRoomSeatStatus().toLibraryAreaList() - } catch (e: HttpException) { - emptyList() - } +) : LibraryRepository { + override suspend fun getRemainingSeats(): Result> = runCatching { + libraryClient.fetchRoomSeatStatus().toLibraryAreaList() } } \ No newline at end of file From cdbb761983b1d2e593674f3c4f8ef1ef4fd68afe Mon Sep 17 00:00:00 2001 From: boiledegg Date: Sat, 23 Nov 2024 12:38:30 +0900 Subject: [PATCH 15/17] =?UTF-8?q?[=EC=B6=94=EA=B0=80]=20dto=20trailing=20c?= =?UTF-8?q?omma=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../remote/library/response/LibraryRoomBranchResponse.kt | 2 +- .../ku_ring/remote/library/response/LibraryRoomListResponse.kt | 2 +- .../ku_ring/remote/library/response/LibraryRoomResponse.kt | 2 +- .../ku_ring/remote/library/response/LibraryRoomSeatResponse.kt | 2 +- .../ku_ring/remote/library/response/LibraryRoomTypeResponse.kt | 2 +- .../ku_ring/remote/library/response/LibrarySeatResponse.kt | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/data/remote/src/main/java/com/ku_stacks/ku_ring/remote/library/response/LibraryRoomBranchResponse.kt b/data/remote/src/main/java/com/ku_stacks/ku_ring/remote/library/response/LibraryRoomBranchResponse.kt index d27213e6..f85b583e 100644 --- a/data/remote/src/main/java/com/ku_stacks/ku_ring/remote/library/response/LibraryRoomBranchResponse.kt +++ b/data/remote/src/main/java/com/ku_stacks/ku_ring/remote/library/response/LibraryRoomBranchResponse.kt @@ -12,5 +12,5 @@ data class LibraryRoomBranchResponse ( @SerializedName("libraryCode") val libraryCode: String, @SerializedName("sortOrder") - val sortOrder: Int + val sortOrder: Int, ) \ No newline at end of file diff --git a/data/remote/src/main/java/com/ku_stacks/ku_ring/remote/library/response/LibraryRoomListResponse.kt b/data/remote/src/main/java/com/ku_stacks/ku_ring/remote/library/response/LibraryRoomListResponse.kt index 356c2cc8..3d4696f7 100644 --- a/data/remote/src/main/java/com/ku_stacks/ku_ring/remote/library/response/LibraryRoomListResponse.kt +++ b/data/remote/src/main/java/com/ku_stacks/ku_ring/remote/library/response/LibraryRoomListResponse.kt @@ -6,5 +6,5 @@ data class LibraryRoomListResponse( @SerializedName(value = "totalCount") val resultCount: Int, @SerializedName(value = "list") - val libraryRooms: List + val libraryRooms: List, ) \ No newline at end of file diff --git a/data/remote/src/main/java/com/ku_stacks/ku_ring/remote/library/response/LibraryRoomResponse.kt b/data/remote/src/main/java/com/ku_stacks/ku_ring/remote/library/response/LibraryRoomResponse.kt index 55913c5a..2b7ec27c 100644 --- a/data/remote/src/main/java/com/ku_stacks/ku_ring/remote/library/response/LibraryRoomResponse.kt +++ b/data/remote/src/main/java/com/ku_stacks/ku_ring/remote/library/response/LibraryRoomResponse.kt @@ -18,5 +18,5 @@ data class LibraryRoomResponse( @SerializedName("unableMessage") val unableMessage: String?, @SerializedName("seats") - val seats: LibraryRoomSeatResponse + val seats: LibraryRoomSeatResponse, ) \ No newline at end of file diff --git a/data/remote/src/main/java/com/ku_stacks/ku_ring/remote/library/response/LibraryRoomSeatResponse.kt b/data/remote/src/main/java/com/ku_stacks/ku_ring/remote/library/response/LibraryRoomSeatResponse.kt index c51afc59..fb2f00d2 100644 --- a/data/remote/src/main/java/com/ku_stacks/ku_ring/remote/library/response/LibraryRoomSeatResponse.kt +++ b/data/remote/src/main/java/com/ku_stacks/ku_ring/remote/library/response/LibraryRoomSeatResponse.kt @@ -10,5 +10,5 @@ data class LibraryRoomSeatResponse( @SerializedName("waiting") val waiting: Int, @SerializedName("available") - val available: Int + val available: Int, ) diff --git a/data/remote/src/main/java/com/ku_stacks/ku_ring/remote/library/response/LibraryRoomTypeResponse.kt b/data/remote/src/main/java/com/ku_stacks/ku_ring/remote/library/response/LibraryRoomTypeResponse.kt index f5f55b36..b7439a16 100644 --- a/data/remote/src/main/java/com/ku_stacks/ku_ring/remote/library/response/LibraryRoomTypeResponse.kt +++ b/data/remote/src/main/java/com/ku_stacks/ku_ring/remote/library/response/LibraryRoomTypeResponse.kt @@ -8,5 +8,5 @@ data class LibraryRoomTypeResponse( @SerializedName("name") val roomName: String, @SerializedName("sortOrder") - val sortOrder: Int + val sortOrder: Int, ) diff --git a/data/remote/src/main/java/com/ku_stacks/ku_ring/remote/library/response/LibrarySeatResponse.kt b/data/remote/src/main/java/com/ku_stacks/ku_ring/remote/library/response/LibrarySeatResponse.kt index 770fc1fd..492ca719 100644 --- a/data/remote/src/main/java/com/ku_stacks/ku_ring/remote/library/response/LibrarySeatResponse.kt +++ b/data/remote/src/main/java/com/ku_stacks/ku_ring/remote/library/response/LibrarySeatResponse.kt @@ -10,5 +10,5 @@ data class LibrarySeatResponse( @SerializedName("message") val message: String, @SerializedName("data") - val data: LibraryRoomListResponse + val data: LibraryRoomListResponse, ) \ No newline at end of file From 4db7c8bb5dadf8c5d13cd3751e50c40bc0cb0408 Mon Sep 17 00:00:00 2001 From: boiledegg Date: Sat, 23 Nov 2024 12:39:32 +0900 Subject: [PATCH 16/17] =?UTF-8?q?[=EC=B6=94=EA=B0=80]=20=EC=97=94=ED=8B=B0?= =?UTF-8?q?=ED=8B=B0=20trailing=20comma=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/com/ku_stacks/ku_ring/domain/LibraryRoom.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/data/domain/src/main/java/com/ku_stacks/ku_ring/domain/LibraryRoom.kt b/data/domain/src/main/java/com/ku_stacks/ku_ring/domain/LibraryRoom.kt index 353b1b6b..36238cb9 100644 --- a/data/domain/src/main/java/com/ku_stacks/ku_ring/domain/LibraryRoom.kt +++ b/data/domain/src/main/java/com/ku_stacks/ku_ring/domain/LibraryRoom.kt @@ -4,5 +4,5 @@ data class LibraryRoom( val name: String, val totalSeats: Int, val occupiedSeats: Int, - val availableSeats: Int + val availableSeats: Int, ) From 80eec3bd10bdbd568a71951c14777df1bfca4e5d Mon Sep 17 00:00:00 2001 From: boiledegg Date: Sat, 23 Nov 2024 13:24:35 +0900 Subject: [PATCH 17/17] =?UTF-8?q?[=EC=88=98=EC=A0=95]=20=EB=A0=88=ED=8F=AC?= =?UTF-8?q?=EC=A7=80=ED=86=A0=EB=A6=AC=20=ED=85=8C=EC=8A=A4=ED=8A=B8=20?= =?UTF-8?q?=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ku_ring/library/LibraryRepositoryTest.kt | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/data/library/src/test/java/com/ku_stacks/ku_ring/library/LibraryRepositoryTest.kt b/data/library/src/test/java/com/ku_stacks/ku_ring/library/LibraryRepositoryTest.kt index 763d3ea4..a18c1a69 100644 --- a/data/library/src/test/java/com/ku_stacks/ku_ring/library/LibraryRepositoryTest.kt +++ b/data/library/src/test/java/com/ku_stacks/ku_ring/library/LibraryRepositoryTest.kt @@ -25,14 +25,15 @@ class LibraryRepositoryTest { Mockito.`when`(client.fetchRoomSeatStatus()).thenReturn(mockLibraryStatus) - val mockResult = libraryRepository.getRemainingSeats() - val expectedResult = LibraryTestUtil.mockLibraryRoomList() + libraryRepository.getRemainingSeats().onSuccess { mockResult -> + val expectedResult = LibraryTestUtil.mockLibraryRoomList() - Mockito.verify( - client, - times(1) - ).fetchRoomSeatStatus() + Mockito.verify( + client, + times(1) + ).fetchRoomSeatStatus() - assertEquals(mockResult, expectedResult) + assertEquals(mockResult, expectedResult) + } } } \ No newline at end of file