Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

정보수정제안 v1 MR #172

Merged
merged 16 commits into from
Dec 19, 2023
Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,12 @@ public fun FileEntity.toModel(): File =

public fun Image.toEntity(): ImageEntity =
ImageEntity(
files = files.map { it.toEntity() },
files = files?.map { it.toEntity() },
)

public fun ImageEntity.toModel(): Image =
Image(
files = files.map { it.toModel() },
files = files?.map { it.toModel() },
)

internal fun ProfileImage.toEntity() =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,11 @@ internal fun UpsertPlaceEntity.toModel() =
UpsertPlaceRequest(
address1 = address1,
address2 = address2,
image = image.toModel(),
image = image?.toModel(),
info = info.toModel(),
latitude = latitude,
longitude = longitude,
menu = menu.toModel(),
menu = menu?.toModel(),
name = name,
placeId = placeId,
remarks = remarks,
Expand Down Expand Up @@ -94,12 +94,12 @@ public fun InfoEntity.toModel(): Info =

public fun Menu.toEntity(): MenuEntity =
MenuEntity(
products = products.map { it.toEntity() },
products = products?.map { it.toEntity() },
)

public fun MenuEntity.toModel(): Menu =
Menu(
products = products.map { it.toModel() },
products = products?.map { it.toModel() },
)

public fun Product.toEntity(): ProductEntity =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,5 @@ public data class File(
val uploadFileId: Int,

@SerialName("url")
val url: String,
val url: String?,
)
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,5 @@ import us.wedemy.eggeum.android.data.model.File
@Serializable
public data class Image(
@SerialName("files")
val files: List<File>,
val files: List<File>?,
)
Original file line number Diff line number Diff line change
Expand Up @@ -58,44 +58,44 @@ import kotlinx.serialization.Serializable
@Serializable
public data class Info(
@SerialName("areaSize")
val areaSize: String,
val areaSize: String?,

@SerialName("blogUri")
val blogUri: String,
val blogUri: String?,

@SerialName("businessHours")
val businessHours: List<String>,
val businessHours: List<String>?,

@SerialName("existsSmokingArea")
val existsSmokingArea: Boolean,
val existsSmokingArea: Boolean?,

@SerialName("existsWifi")
val existsWifi: Boolean,
val existsWifi: Boolean?,

@SerialName("instagramUri")
val instagramUri: String,
val instagramUri: String?,

@SerialName("meetingRoomCount")
val meetingRoomCount: Int,
val meetingRoomCount: Int?,

@SerialName("mobileCharging")
val mobileCharging: String,
val mobileCharging: String?,

@SerialName("multiSeatCount")
val multiSeatCount: Int,
val multiSeatCount: Int?,

@SerialName("parking")
val parking: String,
val parking: String?,

@SerialName("phone")
val phone: String,
val phone: String?,

@SerialName("restRoom")
val restRoom: String,
val restRoom: String?,

@SerialName("singleSeatCount")
val singleSeatCount: Int,
val singleSeatCount: Int?,

@SerialName("websiteUri")
val websiteUri: String,
val websiteUri: String?,
)
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,5 @@ import kotlinx.serialization.Serializable
@Serializable
public data class Menu(
@SerialName("products")
val products: List<Product>,
val products: List<Product>?,
)
Original file line number Diff line number Diff line change
Expand Up @@ -10,46 +10,13 @@ package us.wedemy.eggeum.android.data.model.place
import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable

// @JsonClass(generateAdapter = true)
// public data class PlaceResponse(
// @Json(name = "address1")
// val address1: String,
//
// @Json(name = "address2")
// val address2: String,
//
// @Json(name = "id")
// val id: Int,
//
// @Json(name = "image")
// val image: Image,
//
// @Json(name = "info")
// val info: Info,
//
// @Json(name = "latitude")
// val latitude: Double,
//
// @Json(name = "longitude")
// val longitude: Double,
//
// @Json(name = "menu")
// val menu: Menu,
//
// @Json(name = "name")
// val name: String,
//
// @Json(name = "type")
// val type: String,
// )

@Serializable
public data class PlaceResponse(
@SerialName("address1")
val address1: String,
val address1: String?,

@SerialName("address2")
val address2: String,
val address2: String?,

@SerialName("id")
val id: Int,
Expand All @@ -61,10 +28,10 @@ public data class PlaceResponse(
val info: Info,

@SerialName("latitude")
val latitude: Double,
val latitude: Double?,

@SerialName("longitude")
val longitude: Double,
val longitude: Double?,

@SerialName("menu")
val menu: Menu,
Expand All @@ -73,5 +40,5 @@ public data class PlaceResponse(
val name: String,

@SerialName("type")
val type: String,
val type: String?,
)
Original file line number Diff line number Diff line change
Expand Up @@ -49,35 +49,35 @@ import kotlinx.serialization.Serializable
@Serializable
public data class UpsertPlaceRequest(
@SerialName("address1")
val address1: String,
val address1: String?,

@SerialName("address2")
val address2: String,
val address2: String?,

@SerialName("image")
val image: Image,
val image: Image?,

@SerialName("info")
val info: Info,

@SerialName("latitude")
val latitude: Double,
val latitude: Double?,

@SerialName("longitude")
val longitude: Double,
val longitude: Double?,

@SerialName("menu")
val menu: Menu,
val menu: Menu?,

@SerialName("name")
val name: String,
val name: String?,

@SerialName("placeId")
val placeId: Int,

@SerialName("remarks")
val remarks: String,
val remarks: String?,

@SerialName("type")
val type: String,
val type: String?,
)
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ package us.wedemy.eggeum.android.data.service
import retrofit2.Response
import retrofit2.http.Body
import retrofit2.http.GET
import retrofit2.http.POST
import retrofit2.http.Path
import retrofit2.http.Query
import us.wedemy.eggeum.android.data.model.place.PlaceResponse
Expand Down Expand Up @@ -37,7 +38,7 @@ public interface PlaceService {
@Query("type") type: String? = null,
): PlaceListResponse

@GET("app/place/edits")
@POST("app/place/edits")
public suspend fun upsertPlace(
@Body upsertPlaceRequest: UpsertPlaceRequest,
): Response<Unit>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ package us.wedemy.eggeum.android.domain.model

public data class FileEntity(
public val uploadFileId: Int,
val url: String,
val url: String?,
)
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,15 @@ package us.wedemy.eggeum.android.domain.model.place
import us.wedemy.eggeum.android.domain.model.FileEntity

public data class ImageEntity(
val files: List<FileEntity>,
)
val files: List<FileEntity>?,
) {
public companion object {
public fun of(
files: List<FileEntity>? = null,
): ImageEntity {
return ImageEntity(
files = files,
)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,54 @@
package us.wedemy.eggeum.android.domain.model.place

public data class InfoEntity(
val areaSize: String,
val blogUri: String,
val businessHours: List<String>,
val existsSmokingArea: Boolean,
val existsWifi: Boolean,
val instagramUri: String,
val meetingRoomCount: Int,
val mobileCharging: String,
val multiSeatCount: Int,
val parking: String,
val phone: String,
val restRoom: String,
val singleSeatCount: Int,
val websiteUri: String,
)
val areaSize: String?,
val blogUri: String?,
val businessHours: List<String>?,
val existsSmokingArea: Boolean?,
val existsWifi: Boolean?,
val instagramUri: String?,
val meetingRoomCount: Int?,
val mobileCharging: String?,
val multiSeatCount: Int?,
val parking: String?,
val phone: String?,
val restRoom: String?,
val singleSeatCount: Int?,
val websiteUri: String?,
) {
public companion object {
public fun of(
Copy link
Collaborator

@easyhooon easyhooon Dec 18, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

해당 companion object 내에 함수(of) 가 잘 이해가 안되는데 어떤 역할을 하는 함수인가요?
mapper 의 역할이라면 기존의 방식과 동일하게 바꾸면 좋을것 같아요 (mapper 패키지내에 mapper 를 만들어주는)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

viewModel에서 데이터 관리하면, 없어져야 할 부분이라 생각하는데
이렇게 많은 변수를 다뤄본 적이 없어서 그냥 빌더패턴으로 객체 만들어서 넘겼습니다.

areaSize: String? = null,
blogUri: String? = null,
businessHours: List<String>? = null,
existsSmokingArea: Boolean? = null,
existsWifi: Boolean? = null,
instagramUri: String? = null,
meetingRoomCount: Int? = null,
mobileCharging: String? = null,
multiSeatCount: Int? = null,
parking: String? = null,
phone: String? = null,
restRoom: String? = null,
singleSeatCount: Int? = null,
websiteUri: String? = null,
): InfoEntity {
return InfoEntity(
areaSize = areaSize,
blogUri = blogUri,
businessHours = businessHours,
existsSmokingArea = existsSmokingArea,
existsWifi = existsWifi,
instagramUri = instagramUri,
meetingRoomCount = meetingRoomCount,
mobileCharging = mobileCharging,
multiSeatCount = multiSeatCount,
parking = parking,
phone = phone,
restRoom = restRoom,
singleSeatCount = singleSeatCount,
websiteUri = websiteUri,
)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,15 @@
package us.wedemy.eggeum.android.domain.model.place

public data class MenuEntity(
val products: List<ProductEntity>,
)
var products: List<ProductEntity>?,
) {
public companion object {
public fun of(
products: List<ProductEntity>? = null,
): MenuEntity {
return MenuEntity(
products = products,
)
}
}
}
Loading