新增趋势动态功能
实现了趋势动态功能,包括前端和后端支持。允许用户查看和获取趋势动态。
This commit is contained in:
@@ -24,7 +24,8 @@ class MomentPagingSource(
|
||||
private val remoteDataSource: MomentRemoteDataSource,
|
||||
private val author: Int? = null,
|
||||
private val timelineId: Int? = null,
|
||||
private val contentSearch: String? = null
|
||||
private val contentSearch: String? = null,
|
||||
private val trend: Boolean? = false
|
||||
) : PagingSource<Int, MomentEntity>() {
|
||||
override suspend fun load(params: LoadParams<Int>): LoadResult<Int, MomentEntity> {
|
||||
return try {
|
||||
@@ -33,7 +34,8 @@ class MomentPagingSource(
|
||||
pageNumber = currentPage,
|
||||
author = author,
|
||||
timelineId = timelineId,
|
||||
contentSearch = contentSearch
|
||||
contentSearch = contentSearch,
|
||||
trend = trend
|
||||
)
|
||||
|
||||
LoadResult.Page(
|
||||
@@ -59,9 +61,16 @@ class MomentRemoteDataSource(
|
||||
pageNumber: Int,
|
||||
author: Int?,
|
||||
timelineId: Int?,
|
||||
contentSearch: String?
|
||||
contentSearch: String?,
|
||||
trend: Boolean?
|
||||
): ListContainer<MomentEntity> {
|
||||
return momentService.getMoments(pageNumber, author, timelineId, contentSearch)
|
||||
return momentService.getMoments(
|
||||
pageNumber = pageNumber,
|
||||
author = author,
|
||||
timelineId = timelineId,
|
||||
contentSearch = contentSearch,
|
||||
trend = trend
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -72,9 +81,16 @@ class MomentServiceImpl() : MomentService {
|
||||
pageNumber: Int,
|
||||
author: Int?,
|
||||
timelineId: Int?,
|
||||
contentSearch: String?
|
||||
contentSearch: String?,
|
||||
trend: Boolean?
|
||||
): ListContainer<MomentEntity> {
|
||||
return momentBackend.fetchMomentItems(pageNumber, author, timelineId, contentSearch)
|
||||
return momentBackend.fetchMomentItems(
|
||||
pageNumber = pageNumber,
|
||||
author = author,
|
||||
timelineId = timelineId,
|
||||
contentSearch = contentSearch,
|
||||
trend = trend
|
||||
)
|
||||
}
|
||||
|
||||
override suspend fun getMomentById(id: Int): MomentEntity {
|
||||
@@ -115,14 +131,16 @@ class MomentBackend {
|
||||
pageNumber: Int,
|
||||
author: Int? = null,
|
||||
timelineId: Int?,
|
||||
contentSearch: String?
|
||||
contentSearch: String?,
|
||||
trend: Boolean?
|
||||
): ListContainer<MomentEntity> {
|
||||
val resp = ApiClient.api.getPosts(
|
||||
pageSize = DataBatchSize,
|
||||
page = pageNumber,
|
||||
timelineId = timelineId,
|
||||
authorId = author,
|
||||
contentSearch = contentSearch
|
||||
contentSearch = contentSearch,
|
||||
trend = if (trend == true) "true" else ""
|
||||
)
|
||||
val body = resp.body() ?: throw ServiceException("Failed to get moments")
|
||||
return ListContainer(
|
||||
|
||||
Reference in New Issue
Block a user