-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'feat/#9-goods-api' of https://github.com/SOPT-all/35-CO…
…LLABORATION-ANDROID-MARKETKURLY into feat/#11-review-wishlist-api
- Loading branch information
Showing
19 changed files
with
291 additions
and
150 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 0 additions & 50 deletions
50
app/src/main/java/com/example/market_kurly/core/dummymodel/GoodsDetailData.kt
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
app/src/main/java/com/example/market_kurly/data/dto/response/ResponseGoodsDetailDto.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package com.example.market_kurly.data.dto.response | ||
|
||
import kotlinx.serialization.Serializable | ||
|
||
|
||
//TODO: 서버쌤들이 null 반환 고쳐주면 수정 필요 | ||
@Serializable | ||
data class ResponseGoodsDetailDto( | ||
val name: String, | ||
val price: Int, | ||
val discount: Int, | ||
val discountedPrice: Int, | ||
val image: String, | ||
val membersDiscount: Int, | ||
val membersDiscountedPrice: Int, | ||
val deliveryType: String, | ||
val seller: String, | ||
val origin: String, | ||
val packagingType: String, | ||
val sellingUnit: String, | ||
val weight: String, | ||
val expiration: String? = null, | ||
val brix: Float? = null, | ||
val notification: String, | ||
val category: String, | ||
val allergy: String, | ||
val isInterest: Boolean, | ||
) |
27 changes: 27 additions & 0 deletions
27
app/src/main/java/com/example/market_kurly/data/mapper/GoodsDetailMapper.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package com.example.market_kurly.data.mapper | ||
|
||
import com.example.market_kurly.data.dto.response.ResponseGoodsDetailDto | ||
import com.example.market_kurly.domain.model.GoodsInfoData | ||
import com.example.market_kurly.domain.model.GoodsUiData | ||
fun ResponseGoodsDetailDto.toGoodsUiData() = GoodsUiData( | ||
deliverType = this.deliveryType, | ||
discount = this.discount, | ||
image = this.image, | ||
membersDiscount = this.membersDiscount, | ||
discountedPrice = this.discountedPrice, | ||
membersDiscountedPrice = this.membersDiscountedPrice, | ||
name = this.name, | ||
price = this.price, | ||
seller = this.seller, | ||
origin = this.origin, | ||
isInterest = this.isInterest, | ||
infoData = GoodsInfoData( | ||
allergy = this.allergy, | ||
brix = this.brix, | ||
expiration = this.expiration, | ||
notification = this.notification, | ||
packagingType = this.packagingType, | ||
sellingUnit = this.sellingUnit, | ||
weight = this.weight, | ||
), | ||
) |
19 changes: 19 additions & 0 deletions
19
app/src/main/java/com/example/market_kurly/data/service/GoodsService.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package com.example.market_kurly.data.service | ||
|
||
import com.example.market_kurly.data.dto.base.BaseResponse | ||
import com.example.market_kurly.data.dto.response.ResponseGoodsDetailDto | ||
import retrofit2.http.GET | ||
import retrofit2.http.Header | ||
import retrofit2.http.Path | ||
|
||
interface GoodsService { | ||
companion object { | ||
const val PRODUCTS = "products" | ||
} | ||
|
||
@GET("$PRODUCTS/{productId}") | ||
suspend fun getGoodsDetailById( | ||
@Path("productId") productsId : Int, | ||
@Header("memberId") memberId : Int, | ||
): BaseResponse<ResponseGoodsDetailDto> | ||
} |
26 changes: 26 additions & 0 deletions
26
app/src/main/java/com/example/market_kurly/data/service/LikeService.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package com.example.market_kurly.data.service | ||
|
||
import com.example.market_kurly.data.dto.base.BaseResponse | ||
import retrofit2.http.DELETE | ||
import retrofit2.http.Header | ||
import retrofit2.http.POST | ||
import retrofit2.http.Path | ||
|
||
interface LikeService { | ||
companion object { | ||
const val LIKES = "likes" | ||
const val PRODUCTS = "products" | ||
} | ||
|
||
@POST("$LIKES/$PRODUCTS/{productId}") | ||
suspend fun like( | ||
@Path("productId") productsId : Int, | ||
@Header("memberId") memberId : Int, | ||
): BaseResponse<String?> | ||
|
||
@DELETE("$LIKES/$PRODUCTS/{productId}") | ||
suspend fun unLike( | ||
@Path("productId") productsId : Int, | ||
@Header("memberId") memberId : Int, | ||
): BaseResponse<String?> | ||
} |
2 changes: 1 addition & 1 deletion
2
...t_kurly/core/dummymodel/AlsoViewedData.kt → ...rket_kurly/domain/model/AlsoViewedData.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 7 additions & 5 deletions
12
...rket_kurly/core/dummymodel/GoodsUiData.kt → .../market_kurly/domain/model/GoodsUiData.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 3 additions & 3 deletions
6
app/src/main/java/com/example/market_kurly/domain/repository/GoodsRepository.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,9 @@ | ||
package com.example.market_kurly.domain.repository | ||
|
||
import com.example.market_kurly.core.dummymodel.AlsoViewedData | ||
import com.example.market_kurly.core.dummymodel.GoodsUiData | ||
import com.example.market_kurly.domain.model.AlsoViewedData | ||
import com.example.market_kurly.domain.model.GoodsUiData | ||
|
||
interface GoodsRepository { | ||
fun getDummyAlsoViewedList(): List<AlsoViewedData> | ||
fun getDummyGoodsDetail(): GoodsUiData | ||
suspend fun getGoodsDetailById(productsId : Int, memberId : Int): Result<GoodsUiData?> | ||
} |
6 changes: 6 additions & 0 deletions
6
app/src/main/java/com/example/market_kurly/domain/repository/LikeRepository.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
package com.example.market_kurly.domain.repository | ||
|
||
interface LikeRepository { | ||
suspend fun like(productsId : Int, memberId : Int): Result<String?> | ||
suspend fun unLike(productsId : Int, memberId : Int): Result<String?> | ||
} |
69 changes: 37 additions & 32 deletions
69
app/src/main/java/com/example/market_kurly/domain/repositoryimpl/GoodsRepositoryImpl.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,41 +1,46 @@ | ||
package com.example.market_kurly.domain.repositoryimpl | ||
|
||
import com.example.market_kurly.core.dummymodel.AlsoViewedData | ||
import com.example.market_kurly.core.dummymodel.GoodsDetailData | ||
import com.example.market_kurly.core.dummymodel.GoodsUiData | ||
import com.example.market_kurly.core.dummymodel.toGoodsUiData | ||
import com.example.market_kurly.data.mapper.toGoodsUiData | ||
import com.example.market_kurly.data.service.GoodsService | ||
import com.example.market_kurly.domain.model.AlsoViewedData | ||
import com.example.market_kurly.domain.model.GoodsUiData | ||
import com.example.market_kurly.domain.repository.GoodsRepository | ||
import okhttp3.internal.immutableListOf | ||
|
||
class GoodsRepositoryImpl() : GoodsRepository { | ||
class GoodsRepositoryImpl( | ||
private val goodsService: GoodsService, | ||
) : GoodsRepository { | ||
override fun getDummyAlsoViewedList(): List<AlsoViewedData> = | ||
immutableListOf( | ||
AlsoViewedData("https://product-image.kurly.com/hdims/resize/%5E%3E720x%3E936/cropcenter/720x936/quality/85/src/product/image/59526651-9c34-4a39-9cd0-e30669a9ec4f.jpg", "[KF365] 유명산지 고당도사과 1.5kg (5~6입)", 16, 19900), | ||
AlsoViewedData("https://product-image.kurly.com/hdims/resize/%5E%3E720x%3E936/cropcenter/720x936/quality/85/src/product/image/d79e3f0a-2739-4d54-a5b3-3dbd1d5b4388.jpeg", "고랭지 햇사과 1.3kg (4~6입)", 13, 14900), | ||
AlsoViewedData("https://img-cf.kurly.com/hdims/resize/%5E%3E720x%3E936/cropcenter/720x936/quality/85/src/shop/data/goods/160342712083l0.jpg", "감홍 사과 1.3kg (4~6입)", 25, 19900), | ||
AlsoViewedData("https://product-image.kurly.com/hdims/resize/%5E%3E720x%3E936/cropcenter/720x936/quality/85/src/product/image/30b30de4-14f7-438a-844d-604b5a2acde9.jpg", "세척 사과 1.4kg (7입)", 16, 14900), | ||
AlsoViewedData( | ||
"https://product-image.kurly.com/hdims/resize/%5E%3E720x%3E936/cropcenter/720x936/quality/85/src/product/image/59526651-9c34-4a39-9cd0-e30669a9ec4f.jpg", | ||
"[KF365] 유명산지 고당도사과 1.5kg (5~6입)", | ||
16, | ||
19900 | ||
), | ||
AlsoViewedData( | ||
"https://product-image.kurly.com/hdims/resize/%5E%3E720x%3E936/cropcenter/720x936/quality/85/src/product/image/d79e3f0a-2739-4d54-a5b3-3dbd1d5b4388.jpeg", | ||
"고랭지 햇사과 1.3kg (4~6입)", | ||
13, | ||
14900 | ||
), | ||
AlsoViewedData( | ||
"https://img-cf.kurly.com/hdims/resize/%5E%3E720x%3E936/cropcenter/720x936/quality/85/src/shop/data/goods/160342712083l0.jpg", | ||
"감홍 사과 1.3kg (4~6입)", | ||
25, | ||
19900 | ||
), | ||
AlsoViewedData( | ||
"https://product-image.kurly.com/hdims/resize/%5E%3E720x%3E936/cropcenter/720x936/quality/85/src/product/image/30b30de4-14f7-438a-844d-604b5a2acde9.jpg", | ||
"세척 사과 1.4kg (7입)", | ||
16, | ||
14900 | ||
), | ||
) | ||
|
||
override fun getDummyGoodsDetail(): GoodsUiData = | ||
GoodsDetailData( | ||
allergy = "0", | ||
brix = "13.5 Brix 이상", | ||
category = "과일, 견과, 쌀", | ||
deliverType = "샛별배송", | ||
discount = 13, | ||
expiration = "농산물로 별도의 소비기한은 없으나 가급적 빠르게 드시기 바랍니다.", | ||
image = "https://img-cf.kurly.com/hdims/resize/%5E%3E720x%3E936/cropcenter/720x936/quality/85/src/shop/data/goods/1538466010000_l.jpg", | ||
livestock = "0", | ||
membersDiscount = 26, | ||
name = "아삭하고 달콤한 황금사과1.3kg (5~7입)[품종:시나노골드]", | ||
notification = "식품 특성상 중량은 3% 내외의 차이가 발생할 수 있습니다.\n신선식품 특성상 원물마다 크기 및 형태가 일정하지 않을 수 있습니다.", | ||
origin = "국산", | ||
packagingType = "냉장 (종이포장)", | ||
price = 14900, | ||
seller = "컬리", | ||
sellingUnit = "1봉", | ||
view = 156327, | ||
weight = "1.3kg 내외", | ||
isFavorite = true, | ||
).toGoodsUiData() | ||
} | ||
override suspend fun getGoodsDetailById(productsId: Int, memberId: Int): Result<GoodsUiData?> = | ||
runCatching { | ||
val response = goodsService.getGoodsDetailById(productsId, memberId) | ||
response.data?.toGoodsUiData() | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
app/src/main/java/com/example/market_kurly/domain/repositoryimpl/LikeRepositoryImpl.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package com.example.market_kurly.domain.repositoryimpl | ||
|
||
import com.example.market_kurly.data.service.LikeService | ||
import com.example.market_kurly.domain.repository.LikeRepository | ||
|
||
class LikeRepositoryImpl( | ||
private val likeService: LikeService, | ||
) : LikeRepository { | ||
|
||
override suspend fun like(productsId: Int, memberId: Int): Result<String?> = runCatching { | ||
val response = likeService.like(productsId, memberId) | ||
response.data | ||
} | ||
|
||
override suspend fun unLike(productsId: Int, memberId: Int): Result<String?> = runCatching { | ||
val response = likeService.unLike(productsId, memberId) | ||
response.data | ||
} | ||
} |
Oops, something went wrong.