From a9ae776c83a66cf277cad4e2fdf1c721e3fcb5ec Mon Sep 17 00:00:00 2001 From: Yu Jin Date: Thu, 28 Nov 2024 17:54:54 +0900 Subject: [PATCH 1/2] chore: change dto --- .../android/data/dto/response/MealResponse.kt | 8 +++---- .../data/dto/response/MenuOfMealResponse.kt | 4 ++-- .../android/data/dto/response/MenuResponse.kt | 21 +++++-------------- .../android/data/service/MealService.kt | 10 +++++++-- .../android/data/service/MenuService.kt | 6 +++++- 5 files changed, 24 insertions(+), 25 deletions(-) diff --git a/app/src/main/java/com/eatssu/android/data/dto/response/MealResponse.kt b/app/src/main/java/com/eatssu/android/data/dto/response/MealResponse.kt index 44cb5d1c..f3cf49ea 100644 --- a/app/src/main/java/com/eatssu/android/data/dto/response/MealResponse.kt +++ b/app/src/main/java/com/eatssu/android/data/dto/response/MealResponse.kt @@ -7,8 +7,8 @@ data class GetMealResponse( @SerializedName("mealId") var mealId: Long? = null, @SerializedName("price") var price: Int? = null, - @SerializedName("mainRating") var mainRating: Double? = null, - @SerializedName("menusInformationList") var menusInformationList: ArrayList = arrayListOf(), + @SerializedName("rating") var rating: Double? = null, + @SerializedName("briefMenus") var briefMenus: ArrayList = arrayListOf(), ) data class MenusInformationList( @@ -23,10 +23,10 @@ fun ArrayList.mapTodayMenuResponseToMenu(): List { this.forEach { mealResponse -> val menuNames = - mealResponse.menusInformationList.joinToString(separator = "+") { it.name ?: "" } + mealResponse.briefMenus.joinToString(separator = "+") { it.name ?: "" } val mealId = mealResponse.mealId ?: -1 val price = mealResponse.price ?: 0 - val mainRating = mealResponse.mainRating ?: 0.0 + val mainRating = mealResponse.rating ?: 0.0 val menu = Menu(mealId, menuNames, price, mainRating) diff --git a/app/src/main/java/com/eatssu/android/data/dto/response/MenuOfMealResponse.kt b/app/src/main/java/com/eatssu/android/data/dto/response/MenuOfMealResponse.kt index 8787cafd..78d69a72 100644 --- a/app/src/main/java/com/eatssu/android/data/dto/response/MenuOfMealResponse.kt +++ b/app/src/main/java/com/eatssu/android/data/dto/response/MenuOfMealResponse.kt @@ -4,7 +4,7 @@ import com.eatssu.android.domain.model.MenuMini import com.google.gson.annotations.SerializedName data class MenuOfMealResponse( - @SerializedName("menusInformation") var menusInformation: ArrayList = arrayListOf(), + @SerializedName("briefMenus") var briefMenus: ArrayList = arrayListOf(), ) data class MenusInformation( @@ -15,7 +15,7 @@ data class MenusInformation( ) fun MenuOfMealResponse.toMenuMiniList(): List { - return menusInformation.map { it.toMenuMini() } + return briefMenus.map { it.toMenuMini() } } fun MenusInformation.toMenuMini(): MenuMini { diff --git a/app/src/main/java/com/eatssu/android/data/dto/response/MenuResponse.kt b/app/src/main/java/com/eatssu/android/data/dto/response/MenuResponse.kt index 2a01da2a..efe2a7fc 100644 --- a/app/src/main/java/com/eatssu/android/data/dto/response/MenuResponse.kt +++ b/app/src/main/java/com/eatssu/android/data/dto/response/MenuResponse.kt @@ -1,8 +1,8 @@ package com.eatssu.android.data.dto.response -import android.util.Log import com.eatssu.android.domain.model.Menu import com.google.gson.annotations.SerializedName +import timber.log.Timber data class GetFixedMenuResponse( @@ -14,7 +14,7 @@ data class GetFixedMenuResponse( data class CategoryMenuListCollection( @SerializedName("category") var category: String? = null, - @SerializedName("menuInformationList") var menuInformationList: ArrayList = arrayListOf(), + @SerializedName("menus") var menus: ArrayList = arrayListOf(), ) @@ -23,28 +23,17 @@ data class MenuInformationList( @SerializedName("menuId") var menuId: Long? = null, @SerializedName("name") var name: String? = null, @SerializedName("price") var price: Int? = null, - @SerializedName("mainRating") var mainRating: Double? = null, + @SerializedName("rating") var mainRating: Double? = null, ) -//fun GetFixedMenuResponse.mapFixedMenuResponseToMenu(): List { -// return this.map { fixMenuInfo -> -// Menu( -// id = fixMenuInfo.menuId ?: 0, -// name = fixMenuInfo.name ?: "", -// price = fixMenuInfo.price ?: 0, -// rate = fixMenuInfo.mainRating ?: 0.0 -// ) -// } -//} - fun GetFixedMenuResponse.mapFixedMenuResponseToMenu(): List { val menus = mutableListOf() categoryMenuListCollection.forEach { categoryMenuList -> val categoryName = categoryMenuList.category ?: "" - categoryMenuList.menuInformationList.forEach { menuInfo -> + categoryMenuList.menus.forEach { menuInfo -> val menu = Menu( id = menuInfo.menuId ?: 0, name = menuInfo.name ?: "", @@ -54,7 +43,7 @@ fun GetFixedMenuResponse.mapFixedMenuResponseToMenu(): List { menus.add(menu) } } - Log.d("mapFixedMenuResponseToMenu", menus.toString()) + Timber.d(menus.toString()) return menus } diff --git a/app/src/main/java/com/eatssu/android/data/service/MealService.kt b/app/src/main/java/com/eatssu/android/data/service/MealService.kt index a1323f58..af604ecd 100644 --- a/app/src/main/java/com/eatssu/android/data/service/MealService.kt +++ b/app/src/main/java/com/eatssu/android/data/service/MealService.kt @@ -9,14 +9,20 @@ import retrofit2.http.Path import retrofit2.http.Query interface MealService { - @GET("meals") //변동메뉴 식단 리스트 조회 By 식당 + /** + * 변동메뉴 식단 리스트 조회 By 식당 + */ + @GET("meals") fun getTodayMeal( @Query("date") date: String, @Query("restaurant") restaurant: String, @Query("time") time: String, ): Call>> - @GET("meals/{mealId}/menus-info") //메뉴 정보 리스트 조회 + /** + * 메뉴 정보 리스트 조회 + */ + @GET("meals/{mealId}/menus-info") suspend fun getMenuInfoByMealId( @Path("mealId") mealId: Long, ): BaseResponse diff --git a/app/src/main/java/com/eatssu/android/data/service/MenuService.kt b/app/src/main/java/com/eatssu/android/data/service/MenuService.kt index 7cac0a7d..5e17695e 100644 --- a/app/src/main/java/com/eatssu/android/data/service/MenuService.kt +++ b/app/src/main/java/com/eatssu/android/data/service/MenuService.kt @@ -7,7 +7,11 @@ import retrofit2.http.GET import retrofit2.http.Query interface MenuService { - @GET("menus") //고정 메뉴 리스트 조회 + + /** + * 고정 메뉴 리스트 조회 + */ + @GET("menus") fun getFixMenu( @Query("restaurant") restaurant: String, ): Call> From 0e734f2ea130e462171abb71ad27100d88476a2d Mon Sep 17 00:00:00 2001 From: Yu Jin Date: Thu, 28 Nov 2024 17:54:54 +0900 Subject: [PATCH 2/2] chore: change dto --- .../android/data/dto/response/MealResponse.kt | 8 +++---- .../data/dto/response/MenuOfMealResponse.kt | 4 ++-- .../android/data/dto/response/MenuResponse.kt | 23 +++++-------------- .../android/data/service/MealService.kt | 10 ++++++-- .../android/data/service/MenuService.kt | 6 ++++- 5 files changed, 25 insertions(+), 26 deletions(-) diff --git a/app/src/main/java/com/eatssu/android/data/dto/response/MealResponse.kt b/app/src/main/java/com/eatssu/android/data/dto/response/MealResponse.kt index 44cb5d1c..f3cf49ea 100644 --- a/app/src/main/java/com/eatssu/android/data/dto/response/MealResponse.kt +++ b/app/src/main/java/com/eatssu/android/data/dto/response/MealResponse.kt @@ -7,8 +7,8 @@ data class GetMealResponse( @SerializedName("mealId") var mealId: Long? = null, @SerializedName("price") var price: Int? = null, - @SerializedName("mainRating") var mainRating: Double? = null, - @SerializedName("menusInformationList") var menusInformationList: ArrayList = arrayListOf(), + @SerializedName("rating") var rating: Double? = null, + @SerializedName("briefMenus") var briefMenus: ArrayList = arrayListOf(), ) data class MenusInformationList( @@ -23,10 +23,10 @@ fun ArrayList.mapTodayMenuResponseToMenu(): List { this.forEach { mealResponse -> val menuNames = - mealResponse.menusInformationList.joinToString(separator = "+") { it.name ?: "" } + mealResponse.briefMenus.joinToString(separator = "+") { it.name ?: "" } val mealId = mealResponse.mealId ?: -1 val price = mealResponse.price ?: 0 - val mainRating = mealResponse.mainRating ?: 0.0 + val mainRating = mealResponse.rating ?: 0.0 val menu = Menu(mealId, menuNames, price, mainRating) diff --git a/app/src/main/java/com/eatssu/android/data/dto/response/MenuOfMealResponse.kt b/app/src/main/java/com/eatssu/android/data/dto/response/MenuOfMealResponse.kt index 8787cafd..78d69a72 100644 --- a/app/src/main/java/com/eatssu/android/data/dto/response/MenuOfMealResponse.kt +++ b/app/src/main/java/com/eatssu/android/data/dto/response/MenuOfMealResponse.kt @@ -4,7 +4,7 @@ import com.eatssu.android.domain.model.MenuMini import com.google.gson.annotations.SerializedName data class MenuOfMealResponse( - @SerializedName("menusInformation") var menusInformation: ArrayList = arrayListOf(), + @SerializedName("briefMenus") var briefMenus: ArrayList = arrayListOf(), ) data class MenusInformation( @@ -15,7 +15,7 @@ data class MenusInformation( ) fun MenuOfMealResponse.toMenuMiniList(): List { - return menusInformation.map { it.toMenuMini() } + return briefMenus.map { it.toMenuMini() } } fun MenusInformation.toMenuMini(): MenuMini { diff --git a/app/src/main/java/com/eatssu/android/data/dto/response/MenuResponse.kt b/app/src/main/java/com/eatssu/android/data/dto/response/MenuResponse.kt index 2a01da2a..1118e758 100644 --- a/app/src/main/java/com/eatssu/android/data/dto/response/MenuResponse.kt +++ b/app/src/main/java/com/eatssu/android/data/dto/response/MenuResponse.kt @@ -1,8 +1,8 @@ package com.eatssu.android.data.dto.response -import android.util.Log import com.eatssu.android.domain.model.Menu import com.google.gson.annotations.SerializedName +import timber.log.Timber data class GetFixedMenuResponse( @@ -14,7 +14,7 @@ data class GetFixedMenuResponse( data class CategoryMenuListCollection( @SerializedName("category") var category: String? = null, - @SerializedName("menuInformationList") var menuInformationList: ArrayList = arrayListOf(), + @SerializedName("menus") var menus: ArrayList = arrayListOf(), ) @@ -23,38 +23,27 @@ data class MenuInformationList( @SerializedName("menuId") var menuId: Long? = null, @SerializedName("name") var name: String? = null, @SerializedName("price") var price: Int? = null, - @SerializedName("mainRating") var mainRating: Double? = null, + @SerializedName("rating") var rating: Double? = null, ) -//fun GetFixedMenuResponse.mapFixedMenuResponseToMenu(): List { -// return this.map { fixMenuInfo -> -// Menu( -// id = fixMenuInfo.menuId ?: 0, -// name = fixMenuInfo.name ?: "", -// price = fixMenuInfo.price ?: 0, -// rate = fixMenuInfo.mainRating ?: 0.0 -// ) -// } -//} - fun GetFixedMenuResponse.mapFixedMenuResponseToMenu(): List { val menus = mutableListOf() categoryMenuListCollection.forEach { categoryMenuList -> val categoryName = categoryMenuList.category ?: "" - categoryMenuList.menuInformationList.forEach { menuInfo -> + categoryMenuList.menus.forEach { menuInfo -> val menu = Menu( id = menuInfo.menuId ?: 0, name = menuInfo.name ?: "", price = menuInfo.price ?: 0, - rate = menuInfo.mainRating ?: 0.0 + rate = menuInfo.rating ?: 0.0 ) menus.add(menu) } } - Log.d("mapFixedMenuResponseToMenu", menus.toString()) + Timber.d(menus.toString()) return menus } diff --git a/app/src/main/java/com/eatssu/android/data/service/MealService.kt b/app/src/main/java/com/eatssu/android/data/service/MealService.kt index a1323f58..af604ecd 100644 --- a/app/src/main/java/com/eatssu/android/data/service/MealService.kt +++ b/app/src/main/java/com/eatssu/android/data/service/MealService.kt @@ -9,14 +9,20 @@ import retrofit2.http.Path import retrofit2.http.Query interface MealService { - @GET("meals") //변동메뉴 식단 리스트 조회 By 식당 + /** + * 변동메뉴 식단 리스트 조회 By 식당 + */ + @GET("meals") fun getTodayMeal( @Query("date") date: String, @Query("restaurant") restaurant: String, @Query("time") time: String, ): Call>> - @GET("meals/{mealId}/menus-info") //메뉴 정보 리스트 조회 + /** + * 메뉴 정보 리스트 조회 + */ + @GET("meals/{mealId}/menus-info") suspend fun getMenuInfoByMealId( @Path("mealId") mealId: Long, ): BaseResponse diff --git a/app/src/main/java/com/eatssu/android/data/service/MenuService.kt b/app/src/main/java/com/eatssu/android/data/service/MenuService.kt index 7cac0a7d..5e17695e 100644 --- a/app/src/main/java/com/eatssu/android/data/service/MenuService.kt +++ b/app/src/main/java/com/eatssu/android/data/service/MenuService.kt @@ -7,7 +7,11 @@ import retrofit2.http.GET import retrofit2.http.Query interface MenuService { - @GET("menus") //고정 메뉴 리스트 조회 + + /** + * 고정 메뉴 리스트 조회 + */ + @GET("menus") fun getFixMenu( @Query("restaurant") restaurant: String, ): Call>