-
Notifications
You must be signed in to change notification settings - Fork 3
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
[feat] #172 popup #173
base: develop
Are you sure you want to change the base?
[feat] #172 popup #173
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package org.sopt.model.home | ||
|
||
data class PopupInfo( | ||
val popupId: Int, | ||
val popupImage: String, | ||
val popupActiveStartDate: String, | ||
val popupActiveEndDate: String, | ||
val popupLinkUrl: String, | ||
) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
package org.sopt.model.home | ||
|
||
data class PopupInvisible( | ||
val popupId: Int, | ||
val popupHideUntil: String, | ||
) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package org.sopt.remote.home.api | ||
|
||
import org.sopt.network.model.response.base.BaseResponse | ||
import org.sopt.remote.home.request.RequestPopupInvisibleDto | ||
import org.sopt.remote.home.response.ResponsePopupInfoDto | ||
import org.sopt.remote.home.response.ResponsePopupInvisibleDto | ||
import retrofit2.http.Body | ||
import retrofit2.http.GET | ||
import retrofit2.http.PATCH | ||
|
||
interface PopupService { | ||
companion object { | ||
const val API = "api" | ||
const val V2 = "v2" | ||
const val POPUP = "popup" | ||
} | ||
|
||
@PATCH("/$API/$V2/$POPUP") | ||
suspend fun patchPopupInvisible( | ||
@Body requestPopupInvisibleDto: RequestPopupInvisibleDto, | ||
): BaseResponse<ResponsePopupInvisibleDto> | ||
|
||
@GET("/$API/$V2/$POPUP") | ||
suspend fun getPopupInfo(): BaseResponse<ResponsePopupInfoDto> | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package org.sopt.remote.home.datasource | ||
|
||
import org.sopt.home.datasource.RemotePopupDataSource | ||
import org.sopt.model.home.PopupInfo | ||
import org.sopt.model.home.PopupInvisible | ||
import org.sopt.remote.home.api.PopupService | ||
import org.sopt.remote.home.request.RequestPopupInvisibleDto | ||
import org.sopt.remote.home.response.toCoreModel | ||
import javax.inject.Inject | ||
|
||
class RemotePopupDatasourceImpl @Inject constructor( | ||
private val popupService: PopupService, | ||
) : RemotePopupDataSource { | ||
override suspend fun patchPopupInvisible(popupId: Long, hideDate: Long): PopupInvisible = | ||
popupService.patchPopupInvisible(RequestPopupInvisibleDto(popupId, hideDate)).data!!.toCoreModel() | ||
|
||
override suspend fun getPopupInfo(): List<PopupInfo> = | ||
popupService.getPopupInfo().data!!.popupList.map { it.toCoreModel() } | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package org.sopt.remote.home.request | ||
|
||
import kotlinx.serialization.SerialName | ||
import kotlinx.serialization.Serializable | ||
|
||
@Serializable | ||
data class RequestPopupInvisibleDto( | ||
@SerialName("popupId") | ||
val popupId: Long, | ||
@SerialName("hideDate") | ||
val hideDate: Long, | ||
) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package org.sopt.remote.home.response | ||
|
||
import kotlinx.serialization.SerialName | ||
import kotlinx.serialization.Serializable | ||
import org.sopt.model.home.PopupInfo | ||
|
||
@Serializable | ||
data class ResponsePopupInfoDto( | ||
@SerialName("popupList") | ||
val popupList: List<ResponsePopupInfo>, | ||
) | ||
|
||
@Serializable | ||
data class ResponsePopupInfo( | ||
@SerialName("id") | ||
val id: Int, | ||
@SerialName("image") | ||
val image: String, | ||
@SerialName("activeStartDate") | ||
val activeStartDate: String, | ||
@SerialName("activeEndDate") | ||
val activeEndDate: String, | ||
@SerialName("linkUrl") | ||
val linkUrl: String, | ||
) | ||
|
||
internal fun ResponsePopupInfoDto.toCoreModel() = popupList.map { | ||
it.toCoreModel() | ||
} | ||
|
||
internal fun ResponsePopupInfo.toCoreModel() = PopupInfo( | ||
popupId = id, | ||
popupImage = image, | ||
popupActiveStartDate = activeStartDate, | ||
popupActiveEndDate = activeEndDate, | ||
popupLinkUrl = linkUrl, | ||
) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package org.sopt.remote.home.response | ||
|
||
import kotlinx.serialization.SerialName | ||
import kotlinx.serialization.Serializable | ||
import org.sopt.model.home.PopupInvisible | ||
|
||
@Serializable | ||
data class ResponsePopupInvisibleDto( | ||
@SerialName("popupId") | ||
val popupId: Int, | ||
@SerialName("hideUntil") | ||
val hideUntil: String, | ||
) | ||
|
||
internal fun ResponsePopupInvisibleDto.toCoreModel() = PopupInvisible( | ||
popupId = popupId, | ||
popupHideUntil = hideUntil, | ||
) | ||
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package org.sopt.home.datasource | ||
|
||
import org.sopt.model.home.PopupInfo | ||
import org.sopt.model.home.PopupInvisible | ||
|
||
interface RemotePopupDataSource { | ||
suspend fun patchPopupInvisible(popupId: Long, hideDate: Long): PopupInvisible | ||
suspend fun getPopupInfo(): List<PopupInfo> | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package org.sopt.home.repository | ||
|
||
import org.sopt.home.datasource.RemotePopupDataSource | ||
import org.sopt.model.home.PopupInfo | ||
import org.sopt.model.home.PopupInvisible | ||
import javax.inject.Inject | ||
|
||
class PopupRepoImpl @Inject constructor( | ||
private val remotePopupDataSource: RemotePopupDataSource, | ||
) : PopupRepository { | ||
override suspend fun patchPopupInvisible(popupId: Long, hideDate: Long): Result<PopupInvisible> = | ||
runCatching { remotePopupDataSource.patchPopupInvisible(popupId, hideDate) } | ||
|
||
override suspend fun getPopupInfo(): Result<List<PopupInfo>> = | ||
runCatching { remotePopupDataSource.getPopupInfo() } | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package org.sopt.home.repository | ||
|
||
import org.sopt.model.home.PopupInfo | ||
import org.sopt.model.home.PopupInvisible | ||
|
||
interface PopupRepository { | ||
suspend fun patchPopupInvisible(popupId: Long, hideDate: Long): Result<PopupInvisible> | ||
suspend fun getPopupInfo(): Result<List<PopupInfo>> | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package org.sopt.home.usecase | ||
|
||
import org.sopt.home.repository.PopupRepository | ||
import org.sopt.model.home.PopupInfo | ||
import javax.inject.Inject | ||
|
||
class GetPopupInfo @Inject constructor( | ||
private val popupRepository: PopupRepository, | ||
) { | ||
suspend operator fun invoke(): Result<List<PopupInfo>> = popupRepository.getPopupInfo() | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package org.sopt.home.usecase | ||
|
||
import org.sopt.home.repository.PopupRepository | ||
import org.sopt.model.home.PopupInvisible | ||
import javax.inject.Inject | ||
|
||
class PatchPopupInvisible @Inject constructor( | ||
private val popupRepository: PopupRepository, | ||
) { | ||
suspend operator fun invoke(popupId: Long, hideDate: Long): Result<PopupInvisible> = | ||
popupRepository.patchPopupInvisible(popupId, hideDate) | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
package org.sopt.home | ||
|
||
import org.sopt.model.category.Category | ||
import org.sopt.model.home.PopupInfo | ||
import org.sopt.model.home.RecommendLink | ||
import org.sopt.model.home.WeekBestLink | ||
|
||
|
@@ -14,6 +15,7 @@ data class HomeState( | |
val url: String = "", | ||
val categoryId: Long? = 0, | ||
val categoryName: String? = "์ ์ฒด ํด๋ฆฝ", | ||
val popupList: List<PopupInfo> = emptyList(), | ||
Comment on lines
15
to
+18
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. emptyList๋ฅผ ์ด ์ด์ ๊ฐ ์๋์? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ๊ธฐ๋ณธ๊ฐ์ null๋ก ๋๊ฒ๋๋ฉด state๋ฅผ ํ์ธํ ๋๋ง๋ค null ์ฒดํฌ๋ฅผ ํด์ผํ๊ธฐ ๋๋ฌธ์, emtpyList๋ก ๋์ด popupList๊ฐ ์ด๊ธฐํ ๋์ง ์์๋๋ผ๊ณ ์ ๊ทผ์ด ๊ฐ๋ฅํ๊ฒ ํด์ผํ๋ค๊ณ ์๊ฐํ์ต๋๋ค์. |
||
) { | ||
fun calculateProgress(): Int { | ||
if (readToastNum > allToastNum) return 0 | ||
|
@@ -31,4 +33,5 @@ sealed interface HomeSideEffect { | |
data object NavigateClipLink : HomeSideEffect | ||
data object NavigateWebView : HomeSideEffect | ||
data object ShowBottomSheet : HomeSideEffect | ||
data object ShowPopupInfo : HomeSideEffect | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
internal ์ ์ฐ์ ์ด์ ๊ฐ ์๋์ฅ!?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
๋งคํํจ์๋๊น data-remote ๋ชจ๋ ์์์๋ง ์ฌ์ฉ๋๊ฒ ํ๋ ค๊ณ ํ์ต๋๋ค