-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
33 changed files
with
411 additions
and
170 deletions.
There are no files selected for viewing
2 changes: 1 addition & 1 deletion
2
...va/co/orange/ddanzi/di/AuthInterceptor.kt → .../ddanzi/di/interceptor/AuthInterceptor.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
26 changes: 26 additions & 0 deletions
26
app/src/main/java/co/orange/ddanzi/di/interceptor/DeviceTokenInterceptor.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 co.orange.ddanzi.di.interceptor | ||
|
||
import co.orange.data.local.UserSharedPref | ||
import okhttp3.Interceptor | ||
import okhttp3.Response | ||
import javax.inject.Inject | ||
|
||
class DeviceTokenInterceptor | ||
@Inject | ||
constructor( | ||
private val sharedPref: UserSharedPref, | ||
) : Interceptor { | ||
override fun intercept(chain: Interceptor.Chain): Response { | ||
val originalRequest = chain.request() | ||
val newRequest = | ||
originalRequest.newBuilder() | ||
.header(AUTHORIZATION, "$BEARER ${sharedPref.accessToken}") | ||
.build() | ||
return chain.proceed(newRequest) | ||
} | ||
|
||
companion object { | ||
private const val BEARER = "Bearer" | ||
private const val AUTHORIZATION = "Authorization" | ||
} | ||
} |
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
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
2 changes: 1 addition & 1 deletion
2
...a/co/orange/ddanzi/di/SharedPrefModule.kt → ...ange/ddanzi/di/module/SharedPrefModule.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
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
8 changes: 8 additions & 0 deletions
8
data/src/main/java/co/orange/data/dataSource/DetailDataSource.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,8 @@ | ||
package co.orange.data.dataSource | ||
|
||
import co.orange.data.dto.BaseResponse | ||
import co.orange.data.dto.response.ProductDetailDto | ||
|
||
interface DetailDataSource { | ||
suspend fun getHomeData(id: String): BaseResponse<ProductDetailDto> | ||
} |
15 changes: 15 additions & 0 deletions
15
data/src/main/java/co/orange/data/dataSourceImpl/DetailDataSourceImpl.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,15 @@ | ||
package co.orange.data.dataSourceImpl | ||
|
||
import co.orange.data.dataSource.DetailDataSource | ||
import co.orange.data.dto.BaseResponse | ||
import co.orange.data.dto.response.ProductDetailDto | ||
import co.orange.data.service.DetailService | ||
import javax.inject.Inject | ||
|
||
data class DetailDataSourceImpl | ||
@Inject | ||
constructor( | ||
private val detailService: DetailService, | ||
) : DetailDataSource { | ||
override suspend fun getHomeData(id: String): BaseResponse<ProductDetailDto> = detailService.getProductDetail(id) | ||
} |
40 changes: 40 additions & 0 deletions
40
data/src/main/java/co/orange/data/dto/response/ProductDetailDto.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,40 @@ | ||
package co.orange.data.dto.response | ||
|
||
import co.orange.domain.entity.response.ProductDetailModel | ||
import kotlinx.serialization.SerialName | ||
import kotlinx.serialization.Serializable | ||
|
||
@Serializable | ||
data class ProductDetailDto( | ||
@SerialName("name") | ||
val name: String, | ||
@SerialName("category") | ||
val category: String, | ||
@SerialName("isOptionExist") | ||
val isOptionExist: Boolean, | ||
@SerialName("isImminent") | ||
val isImminent: Boolean, | ||
@SerialName("discountRate") | ||
val discountRate: Int, | ||
@SerialName("stockCount") | ||
val stockCount: Int, | ||
@SerialName("infoUrl") | ||
val infoUrl: String, | ||
@SerialName("interestCount") | ||
val interestCount: Int, | ||
@SerialName("optionList") | ||
val optionList: List<ProductOptionDto>, | ||
) { | ||
fun toModel() = | ||
ProductDetailModel( | ||
name, | ||
category, | ||
isOptionExist, | ||
isImminent, | ||
discountRate, | ||
stockCount, | ||
infoUrl, | ||
interestCount, | ||
optionList.map { it.toModel() }, | ||
) | ||
} |
29 changes: 29 additions & 0 deletions
29
data/src/main/java/co/orange/data/dto/response/ProductOptionDto.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,29 @@ | ||
package co.orange.data.dto.response | ||
|
||
import co.orange.domain.entity.response.ProductOptionModel | ||
import kotlinx.serialization.SerialName | ||
import kotlinx.serialization.Serializable | ||
|
||
@Serializable | ||
data class ProductOptionDto( | ||
@SerialName("optionId") | ||
val optionId: Long, | ||
@SerialName("type") | ||
val type: String, | ||
@SerialName("optionDetailList") | ||
val optionDetailList: List<OptionDetailDto>, | ||
) { | ||
@Serializable | ||
data class OptionDetailDto( | ||
@SerialName("optionDetailId") | ||
val optionDetailId: Long, | ||
@SerialName("content") | ||
val content: String, | ||
@SerialName("isAvailable") | ||
val isAvailable: Boolean, | ||
) { | ||
fun toModel() = ProductOptionModel.OptionDetailModel(optionDetailId, content, isAvailable) | ||
} | ||
|
||
fun toModel() = ProductOptionModel(optionId, type, optionDetailList.map { it.toModel() }) | ||
} |
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
17 changes: 17 additions & 0 deletions
17
data/src/main/java/co/orange/data/repositoryImpl/DetailRepositoryImpl.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,17 @@ | ||
package co.orange.data.repositoryImpl | ||
|
||
import co.orange.data.dataSource.DetailDataSource | ||
import co.orange.domain.entity.response.ProductDetailModel | ||
import co.orange.domain.repository.DetailRepository | ||
import javax.inject.Inject | ||
|
||
class DetailRepositoryImpl | ||
@Inject | ||
constructor( | ||
private val detailDataSource: DetailDataSource, | ||
) : DetailRepository { | ||
override suspend fun getProductDetail(id: String): Result<ProductDetailModel> = | ||
runCatching { | ||
detailDataSource.getHomeData(id).data.toModel() | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
data/src/main/java/co/orange/data/service/DetailService.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,13 @@ | ||
package co.orange.data.service | ||
|
||
import co.orange.data.dto.BaseResponse | ||
import co.orange.data.dto.response.ProductDetailDto | ||
import retrofit2.http.GET | ||
import retrofit2.http.Path | ||
|
||
interface DetailService { | ||
@GET("/api/v1/home/product/{id}") | ||
suspend fun getProductDetail( | ||
@Path("id") id: String, | ||
): BaseResponse<ProductDetailDto> | ||
} |
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
5 changes: 3 additions & 2 deletions
5
...nge/domain/entity/response/OptionModel.kt → ...ain/entity/response/ProductOptionModel.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,12 +1,13 @@ | ||
package co.orange.domain.entity.response | ||
|
||
data class OptionModel( | ||
data class ProductOptionModel( | ||
val optionId: Long, | ||
val type: String, | ||
val optionDetailList: List<OptionDetailModel>, | ||
) { | ||
data class OptionDetailModel( | ||
val optionDetailId: Long, | ||
val content: String, | ||
val isAvailable: Boolean, | ||
) | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
domain/src/main/kotlin/co/orange/domain/repository/DetailRepository.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,7 @@ | ||
package co.orange.domain.repository | ||
|
||
import co.orange.domain.entity.response.ProductDetailModel | ||
|
||
interface DetailRepository { | ||
suspend fun getProductDetail(id: String): Result<ProductDetailModel> | ||
} |
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
Oops, something went wrong.